Class NettyConnectionAdpater
java.lang.Object
org.serviceconnector.net.req.netty.NettyConnectionAdpater
- All Implemented Interfaces:
IConnection
- Direct Known Subclasses:
NettyHttpConnection,NettyTcpConnection
The Class NettyConnectionAdpater.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BasicConfigurationThe base conf.protected io.netty.bootstrap.BootstrapThe bootstrap.protected io.netty.channel.ChannelThe channel.protected ConnectionContextThe connection context.protected IEncoderDecoderThe encoder decoder.protected StringThe host.protected intThe idle timeout.protected NettyOperationListenerThe operation listener.protected intThe port.protected InetSocketAddressThe remote socket address.protected static io.netty.channel.EventLoopGroupThe channel factory. -
Constructor Summary
ConstructorsConstructorDescriptionNettyConnectionAdpater(io.netty.channel.EventLoopGroup workerGroup) Instantiates a new NETTY connection adapter. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidconnect()Connect.voiddestroy()Destroys connection.voidDisconnect.Gets the context.getHost()Gets the host.intGets the nr of idles in sequence.intgetPort()Gets the port.voidIncrement nr of idles.booleanChecks if is connected.voidReset nr of idles.abstract voidsend(SCMPMessage scmp, ISCMPMessageCallback callback) Send and receive asynchronous operation.voidsetContext(ConnectionContext connectionContext) Sets the context.voidSets the host.voidsetIdleTimeoutSeconds(int idleTimeout) Sets the idle timeout.voidsetPort(int port) Sets the port.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.serviceconnector.net.connection.IConnection
setQuietDisconnect
-
Field Details
-
baseConf
The base conf. -
connectionContext
The connection context. -
port
protected int portThe port. -
host
The host. -
remotSocketAddress
The remote socket address. -
encoderDecoder
The encoder decoder. -
operationListener
The operation listener. -
channel
protected io.netty.channel.Channel channelThe channel. -
bootstrap
protected io.netty.bootstrap.Bootstrap bootstrapThe bootstrap. -
idleTimeout
protected int idleTimeoutThe idle timeout. -
workerGroup
protected static io.netty.channel.EventLoopGroup workerGroupThe channel factory. Configures client with Thread Pool, Boss Threads and Worker Threads. A boss thread accepts incoming connections on a socket. A worker thread performs non-blocking read and write on a channel.
-
-
Constructor Details
-
NettyConnectionAdpater
public NettyConnectionAdpater(io.netty.channel.EventLoopGroup workerGroup) Instantiates a new NETTY connection adapter.- Parameters:
workerGroup- the workerGroup
-
-
Method Details
-
connect
Connect.- Specified by:
connectin interfaceIConnection- Throws:
Exception- the exception
-
send
Send and receive asynchronous operation.- Specified by:
sendin interfaceIConnection- Parameters:
scmp- the scmpcallback- the callback- Throws:
Exception- the exception
-
destroy
public void destroy()Destroys connection.- Specified by:
destroyin interfaceIConnection
-
disconnect
Disconnect.- Specified by:
disconnectin interfaceIConnection- Throws:
Exception- the exception
-
getContext
Gets the context.- Specified by:
getContextin interfaceIConnection- Returns:
- the context
-
setContext
Sets the context.- Specified by:
setContextin interfaceIConnection- Parameters:
connectionContext- the new context
-
isConnected
public boolean isConnected()Checks if is connected.- Specified by:
isConnectedin interfaceIConnection- Returns:
- true, if is connected
-
getNrOfIdlesInSequence
public int getNrOfIdlesInSequence()Gets the nr of idles in sequence.- Specified by:
getNrOfIdlesInSequencein interfaceIConnection- Returns:
- the nr of idles in sequence
-
incrementNrOfIdles
public void incrementNrOfIdles()Increment nr of idles.- Specified by:
incrementNrOfIdlesin interfaceIConnection
-
resetNrOfIdles
public void resetNrOfIdles()Reset nr of idles.- Specified by:
resetNrOfIdlesin interfaceIConnection
-
setPort
public void setPort(int port) Sets the port.- Specified by:
setPortin interfaceIConnection- Parameters:
port- the port
-
setHost
Sets the host.- Specified by:
setHostin interfaceIConnection- Parameters:
host- the host
-
getPort
public int getPort()Description copied from interface:IConnectionGets the port.- Specified by:
getPortin interfaceIConnection- Returns:
- the port
-
getHost
Description copied from interface:IConnectionGets the host.- Specified by:
getHostin interfaceIConnection- Returns:
- the host
-
setIdleTimeoutSeconds
public void setIdleTimeoutSeconds(int idleTimeout) Sets the idle timeout.- Specified by:
setIdleTimeoutSecondsin interfaceIConnection- Parameters:
idleTimeout- the new idle timeout
-