Class NettyConnectionAdpater

java.lang.Object
org.serviceconnector.net.req.netty.NettyConnectionAdpater
All Implemented Interfaces:
IConnection
Direct Known Subclasses:
NettyHttpConnection, NettyTcpConnection

public abstract class NettyConnectionAdpater extends Object implements IConnection
The Class NettyConnectionAdpater.
  • Field Details

    • baseConf

      protected final BasicConfiguration baseConf
      The base conf.
    • connectionContext

      protected ConnectionContext connectionContext
      The connection context.
    • port

      protected int port
      The port.
    • host

      protected String host
      The host.
    • remotSocketAddress

      protected InetSocketAddress remotSocketAddress
      The remote socket address.
    • encoderDecoder

      protected IEncoderDecoder encoderDecoder
      The encoder decoder.
    • operationListener

      protected NettyOperationListener operationListener
      The operation listener.
    • channel

      protected io.netty.channel.Channel channel
      The channel.
    • bootstrap

      protected io.netty.bootstrap.Bootstrap bootstrap
      The bootstrap.
    • idleTimeout

      protected int idleTimeout
      The idle timeout.
    • workerGroup

      protected static io.netty.channel.EventLoopGroup workerGroup
      The 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

      public abstract void connect() throws Exception
      Connect.
      Specified by:
      connect in interface IConnection
      Throws:
      Exception - the exception
    • send

      public abstract void send(SCMPMessage scmp, ISCMPMessageCallback callback) throws Exception
      Send and receive asynchronous operation.
      Specified by:
      send in interface IConnection
      Parameters:
      scmp - the scmp
      callback - the callback
      Throws:
      Exception - the exception
    • destroy

      public void destroy()
      Destroys connection.
      Specified by:
      destroy in interface IConnection
    • disconnect

      public void disconnect() throws Exception
      Disconnect.
      Specified by:
      disconnect in interface IConnection
      Throws:
      Exception - the exception
    • getContext

      public ConnectionContext getContext()
      Gets the context.
      Specified by:
      getContext in interface IConnection
      Returns:
      the context
    • setContext

      public void setContext(ConnectionContext connectionContext)
      Sets the context.
      Specified by:
      setContext in interface IConnection
      Parameters:
      connectionContext - the new context
    • isConnected

      public boolean isConnected()
      Checks if is connected.
      Specified by:
      isConnected in interface IConnection
      Returns:
      true, if is connected
    • getNrOfIdlesInSequence

      public int getNrOfIdlesInSequence()
      Gets the nr of idles in sequence.
      Specified by:
      getNrOfIdlesInSequence in interface IConnection
      Returns:
      the nr of idles in sequence
    • incrementNrOfIdles

      public void incrementNrOfIdles()
      Increment nr of idles.
      Specified by:
      incrementNrOfIdles in interface IConnection
    • resetNrOfIdles

      public void resetNrOfIdles()
      Reset nr of idles.
      Specified by:
      resetNrOfIdles in interface IConnection
    • setPort

      public void setPort(int port)
      Sets the port.
      Specified by:
      setPort in interface IConnection
      Parameters:
      port - the port
    • setHost

      public void setHost(String host)
      Sets the host.
      Specified by:
      setHost in interface IConnection
      Parameters:
      host - the host
    • getPort

      public int getPort()
      Description copied from interface: IConnection
      Gets the port.
      Specified by:
      getPort in interface IConnection
      Returns:
      the port
    • getHost

      public String getHost()
      Description copied from interface: IConnection
      Gets the host.
      Specified by:
      getHost in interface IConnection
      Returns:
      the host
    • setIdleTimeoutSeconds

      public void setIdleTimeoutSeconds(int idleTimeout)
      Sets the idle timeout.
      Specified by:
      setIdleTimeoutSeconds in interface IConnection
      Parameters:
      idleTimeout - the new idle timeout