All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sportradar.livedata.sdk.di.LiveScoutInjectionModule Maven / Gradle / Ivy

Go to download

Livedata SDK is a client library that enables easier integration with the Livedata XML feed. SDK exposes XML feed service interface in a more user-friendly way and isolates the client from having to do XML feed parsing, proper connection handling, error recovery, event queuing and dispatching. It also makes a client solution more stable and robust when it comes to feed handling, especially with the release of new and updated XML feed versions.

There is a newer version: 2.0.11
Show newest version
package com.sportradar.livedata.sdk.di;

import com.google.inject.*;
import com.sportradar.livedata.sdk.common.networking.Gateway;
import com.sportradar.livedata.sdk.common.classes.jmx.LiveScoutStatisticsCounter;
import com.sportradar.livedata.sdk.common.classes.jmx.SimpleJMX;
import com.sportradar.livedata.sdk.common.interfaces.SdkLogger;
import com.sportradar.livedata.sdk.common.settings.LiveScoutSettings;
import com.sportradar.livedata.sdk.dispatch.livescout.LiveScoutDispatcher;
import com.sportradar.livedata.sdk.feed.common.EntityMapper;
import com.sportradar.livedata.sdk.feed.common.ProtocolManager;
import com.sportradar.livedata.sdk.feed.common.TestManager;
import com.sportradar.livedata.sdk.feed.livescout.classes.LiveScoutEntityMapper;
import com.sportradar.livedata.sdk.feed.livescout.classes.LiveScoutUserRequestManagerImpl;
import com.sportradar.livedata.sdk.feed.livescout.entities.JaxbLiveScoutEntityFactory;
import com.sportradar.livedata.sdk.feed.livescout.entities.LiveScoutEntityBase;
import com.sportradar.livedata.sdk.feed.livescout.interfaces.LiveScoutEntityFactory;
import com.sportradar.livedata.sdk.feed.livescout.interfaces.LiveScoutFeed;
import com.sportradar.livedata.sdk.feed.livescout.interfaces.LiveScoutUserRequestManager;
import com.sportradar.livedata.sdk.proto.common.Protocol;
import com.sportradar.livedata.sdk.proto.dto.IncomingMessage;
import com.sportradar.livedata.sdk.proto.dto.OutgoingMessage;
import com.sportradar.livedata.sdk.proto.livescout.LiveScoutClientAliveProducer;
import com.sportradar.livedata.sdk.proto.livescout.LiveScoutOutgoingMessageInspector;
import com.sportradar.livedata.sdk.proto.livescout.LiveScoutStatusFactory;
import org.apache.commons.net.DefaultSocketFactory;

import jakarta.inject.Provider;
import jakarta.inject.Singleton;
import javax.net.ssl.SSLSocketFactory;
import jakarta.xml.bind.JAXBException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;

/**
 * A {@link com.google.inject.Module} implementation used by Guice to set up live-scout dependency tree.
 */
public class LiveScoutInjectionModule extends LiveScoutInjectionModuleBase {

    /**
     * Initializes a new instance of the {@link LiveScoutInjectionModule} class.
     *
     * @param settings The {@link LiveScoutSettings} containing live-scout configurable values.
     */
    public LiveScoutInjectionModule(LiveScoutSettings settings) {
        super(settings);
    }

    /**
     * 

* Contributes bindings and other configurations for this module to {@code binder}. *

*

Do not invoke this method directly to install submodules. Instead use * {@link com.google.inject.Binder#install(com.google.inject.Module)}, which ensures that {@link com.google.inject.Provides provider methods} are * discovered. *

*/ @Override public void configure(Binder binder) { binder.bind(LiveScoutEntityFactory.class) .to(JaxbLiveScoutEntityFactory.class) .in(Singleton.class); binder.bind(new TypeLiteral>() {}) .to(LiveScoutEntityMapper.class) .in(Singleton.class); binder.bind(LiveScoutStatusFactory.class) .in(Singleton.class); binder.bind(LiveScoutUserRequestManager.class) .to(Key.get(LiveScoutUserRequestManagerImpl.class)) .in(Singleton.class); } @Override @Provides @Singleton protected SdkLogger provideSdkLogger(ScheduledExecutorService scheduledExecutorService) { return super.provideSdkLogger(scheduledExecutorService); } @Override @Provides @Singleton protected Gateway provideGateway( ExecutorService executorService, ScheduledExecutorService scheduledExecutorService, DefaultSocketFactory socketFactory, SSLSocketFactory sslSocketFactory) { return super.provideGateway(executorService, scheduledExecutorService, socketFactory, sslSocketFactory); } @Override @Provides @Singleton protected LiveScoutUserRequestManagerImpl provideUserRequestManager(LiveScoutStatusFactory factory, TestManager testManager, SdkLogger sdkLogger) { return super.provideUserRequestManager(factory, testManager, sdkLogger); } @Override @Provides @Singleton protected LiveScoutClientAliveProducer provideAliveProducer( LiveScoutStatusFactory entityFactory, ScheduledExecutorService executor) { return super.provideAliveProducer(entityFactory, executor); } @Override @Provides @Singleton protected ProtocolManager provideProtocolManager( Protocol protocol, EntityMapper entityMapper, LiveScoutUserRequestManagerImpl userRequestManager, LiveScoutClientAliveProducer aliveProducer, SdkLogger sdkLogger) throws JAXBException { return super.provideProtocolManager(protocol, entityMapper, userRequestManager, aliveProducer, sdkLogger); } @Provides @Singleton protected LiveScoutDispatcher provideDispatcher( ExecutorService executorService, SimpleJMX jmxManager, SdkLogger sdkLogger) { LiveScoutStatisticsCounter counter = new LiveScoutStatisticsCounter(); return super.provideDispatcher(executorService, sdkLogger, jmxManager, counter); } @Provides @Singleton protected LiveScoutFeed provideFeed( Provider> protocolManagerProvider, Provider userRequestManagerProvider, Provider dispatcherProvider, Provider sdkLoggerProvider) { return super.provideFeed( protocolManagerProvider, userRequestManagerProvider, dispatcherProvider, sdkLoggerProvider, settings); } @Provides @Singleton protected Protocol provideProtocol( LiveScoutStatusFactory statusFactory, ScheduledExecutorService scheduledExecutorService, Gateway gateway, SdkLogger sdkLogger) throws JAXBException { return super.buildProtocol( scheduledExecutorService, gateway, new LiveScoutOutgoingMessageInspector(), statusFactory, sdkLogger); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy