Class JMapNetworkConnectionPool

java.lang.Object
com.kheops.util.KObjectPool<JMapNetworkConnection>
com.kheops.jmap.net.JMapNetworkConnectionPool
All Implemented Interfaces:
KSchedulerClient

public class JMapNetworkConnectionPool extends KObjectPool<JMapNetworkConnection>
This class manage a pool of JMapNetworkConnection. It extends KObjectPool
See Also:
  • Constructor Details

    • JMapNetworkConnectionPool

      public JMapNetworkConnectionPool()
    • JMapNetworkConnectionPool

      public JMapNetworkConnectionPool(String host, int port, int initialSize) throws Exception
      Constructs a JMapNetworkConnectionPool instance.
      Parameters:
      host - the url to connect to the JMap Server
      port - the port to connect to the JMap Server
      initialSize - the initial pool size
      Throws:
      Exception
    • JMapNetworkConnectionPool

      public JMapNetworkConnectionPool(String protocol, String host, int port, int httpPort, String proxyPath, String serverId, int connectionMode, int initialSize) throws Exception
      Constructs a JMapNetworkConnectionPool instance.
      Parameters:
      protocol - the protocol (http, https)
      host - the url to connect to the JMap Server
      port - the port to connect to the JMap Server
      httpPort - the http port to connect to the JMap Server
      proxyPath - the path of the proxy servlet
      serverId - the server to connect to behind the proxyconnectionMode
      connectionMode - the connection mode (proxy, direct)
      initialSize - the initial pool size
      Throws:
      Exception
  • Method Details

    • create

      public JMapNetworkConnection create() throws IOException
      Constructs a new instance of JMapNetworkConnection and opens a connection
      Specified by:
      create in class KObjectPool<JMapNetworkConnection>
      Returns:
      the newly created connection
      Throws:
      IOException
    • validate

      public boolean validate(JMapNetworkConnection connection)
      This method checks if the specified object qualifies for connections
      Specified by:
      validate in class KObjectPool<JMapNetworkConnection>
      Parameters:
      connection - the corresponding object
      Returns:
      true if the object qualifies for connection false otherwise
    • expire

      public void expire(JMapNetworkConnection connection)
      Closes the specified connection object
      Specified by:
      expire in class KObjectPool<JMapNetworkConnection>
      Parameters:
      connection - the connection object to be closed
    • borrowConnection

      public JMapNetworkConnection borrowConnection() throws IOException
      Gets a free connection from the connection pool
      Returns:
      a free JMapNetworkConnection instance from the connection pool
      Throws:
      IOException
    • borrowConnection

      public JMapNetworkConnection borrowConnection(long timeout, TimeUnit unit) throws IOException
      Gets a free connection from the connection pool
      Parameters:
      timeout - the maximum time to wait
      unit - the time unit of the timeout argument
      Returns:
      a free JMapNetworkConnection instance from the connection pool
      Throws:
      IOException
    • returnConnection

      public void returnConnection(JMapNetworkConnection connection)
      This method will free up the specified JMapSvrConnection instance
      Parameters:
      connection - the corresponding JMapSvrConnection instance to be freed
    • addConnectionListener

      public void addConnectionListener(JMapConnectionListener listener)
    • removeConnectionListener

      public void removeConnectionListener(JMapConnectionListener listener)
    • close

      public void close()
      Description copied from class: KObjectPool
      This method closes one by one all the objects currently opened for this the pool
      Overrides:
      close in class KObjectPool<JMapNetworkConnection>
    • getReadTimeout

      public int getReadTimeout()
    • setReadTimeout

      public void setReadTimeout(int readTimeout)