![JAR search and dependency download from the Maven repository](/logo.png)
netflix.karyon.transport.tcp.KaryonTcpModule Maven / Gradle / Ivy
package netflix.karyon.transport.tcp;
import com.google.inject.Key;
import com.google.inject.binder.LinkedBindingBuilder;
import com.google.inject.multibindings.MapBinder;
import io.reactivex.netty.channel.ConnectionHandler;
import io.reactivex.netty.server.RxServer;
import netflix.karyon.transport.AbstractServerModule;
import netflix.karyon.transport.AbstractServerModule.ServerConfigBuilder;
import static netflix.karyon.utils.TypeUtils.keyFor;
/**
* @author Tomasz Bak
*/
@SuppressWarnings("rawtypes")
public abstract class KaryonTcpModule extends AbstractServerModule {
protected final Key> connectionHandlerKey;
protected final Key> serverKey;
protected KaryonTcpModule(String moduleName, Class iType, Class oType) {
super(moduleName, iType, oType);
connectionHandlerKey = keyFor(ConnectionHandler.class, iType, oType, nameAnnotation);
serverKey = keyFor(RxServer.class, iType, oType, nameAnnotation);
}
@Override
protected void configure() {
configureServer();
bind(serverConfigKey).toInstance(serverConfigBuilder.build());
MapBinder.newMapBinder(binder(), String.class, RxServer.class).addBinding(nameAnnotation.value()).toProvider(
new TcpRxServerProvider>(nameAnnotation.value(), iType, oType)
).asEagerSingleton();
}
@Override
protected ServerConfigBuilder newServerConfigBuilder() {
return new ServerConfigBuilder();
}
public LinkedBindingBuilder> bindConnectionHandler() {
return bind(connectionHandlerKey);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy