com.ibm.jtopenlite

Class HostServerConnectionPool<T extends HostServerConnection>

  • java.lang.Object
    • com.ibm.jtopenlite.HostServerConnectionPool<T>


  • public class HostServerConnectionPool<T extends HostServerConnection>
    extends java.lang.Object
    Used to pool HostServerConnections of a specific type to a specific system. For example:
       // Get the SystemInfo object used to seed our pool.
       SignonConnection signon = SignonConnection.getConnection("system", "user", "password");
       SystemInfo info = signon.getInfo();
       signon.close();
    
       // Construct the pool (initially empty).
       HostServerConnectionPool<CommandConnection> commandPool = new HostServerConnectionPool<CommandConnection>(info);
    
       // To populate the pool, create connections and check them in.
       // To use the pool, check out connections from the pool.
       CommandConnection conn = CommandConnection.getConnection(info, "FRED", "password");
       commandPool.checkin(conn);
       conn = commandPool.checkout("FRED");
       commandPool.checkin(conn);
    
       // You can check the current size of the pool.
       int used = commandPool.getUsedConnectionCount();
       int free = commandPool.getFreeConnectionCount();
    
       // You can check the number of connections per user.
       int fredUsed = commandPool.getUsedConnectionCount("FRED");
       int fredFree = commandPool.getFreeConnectionCount("FRED");
    
       // Closing the pool will close all connections in the pool, both free and in use.
       commandPool.close();
     
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void checkin(T conn)
      Adds or returns a connection to this pool.
      T checkout(java.lang.String user)
      Obtains a free connection from this pool for the specified user.
      void close()
      Closes and removes all connections in this pool, both free and in use.
      void close(java.lang.String user)
      Closes and removes all connections for the specified user in this pool, both free and in use.
      void closeFree()
      Closes and removes all free connections in this pool.
      void closeFree(java.lang.String user)
      Closes and removes all free connections for the specified user in this pool.
      void closeUsed()
      Closes and removes all in-use connections in this pool.
      void closeUsed(java.lang.String user)
      Closes and removes all in-use connections for the specified user in this pool.
      protected void finalize() 
      int getConnectionCount()
      Returns the total number of connections in this pool, both free and in use.
      int getConnectionCount(java.lang.String user)
      Returns the total number of connections for the specified user in this pool, both free and in use.
      int getFreeConnectionCount()
      Returns the number of free connections in this pool.
      int getFreeConnectionCount(java.lang.String user)
      Returns the number of free connections for the specified user in this pool.
      SystemInfo getInfo()
      Returns the system information for this pool.
      int getUsedConnectionCount()
      Returns the number of in-use connections in this pool.
      int getUsedConnectionCount(java.lang.String user)
      Returns the number of used connections for the specified user in this pool.
      java.lang.String[] getUsers()
      Returns an array of users of connections in this pool, both free and in use.
      void remove(T conn)
      Removes the specified connection from this pool, regardless if it is free or in use.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HostServerConnectionPool

        public HostServerConnectionPool(SystemInfo info)
        Constructs a new connection pool for the specified system. All connections checked into this pool must have a matching SystemInfo object.
    • Method Detail

      • getInfo

        public SystemInfo getInfo()
        Returns the system information for this pool.
      • finalize

        protected void finalize()
                         throws java.lang.Throwable
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.lang.Throwable
      • checkin

        public void checkin(T conn)
                     throws java.io.IOException
        Adds or returns a connection to this pool. If the connection is closed or its SystemInfo does not match what was defined for this pool, the connection is removed from this pool if it already exists in this pool, but is otherwise ignored.
        Throws:
        java.io.IOException
      • checkout

        public T checkout(java.lang.String user)
                                                throws java.io.IOException
        Obtains a free connection from this pool for the specified user. If there are no free connections in the pool for the specified user, null is returned.
        Throws:
        java.io.IOException
      • remove

        public void remove(T conn)
        Removes the specified connection from this pool, regardless if it is free or in use. If the connection is not in the pool, it is ignored.
      • close

        public void close()
                   throws java.io.IOException
        Closes and removes all connections in this pool, both free and in use.
        Throws:
        java.io.IOException
      • closeFree

        public void closeFree()
                       throws java.io.IOException
        Closes and removes all free connections in this pool.
        Throws:
        java.io.IOException
      • closeUsed

        public void closeUsed()
                       throws java.io.IOException
        Closes and removes all in-use connections in this pool.
        Throws:
        java.io.IOException
      • close

        public void close(java.lang.String user)
                   throws java.io.IOException
        Closes and removes all connections for the specified user in this pool, both free and in use.
        Throws:
        java.io.IOException
      • closeFree

        public void closeFree(java.lang.String user)
                       throws java.io.IOException
        Closes and removes all free connections for the specified user in this pool.
        Throws:
        java.io.IOException
      • closeUsed

        public void closeUsed(java.lang.String user)
                       throws java.io.IOException
        Closes and removes all in-use connections for the specified user in this pool.
        Throws:
        java.io.IOException
      • getConnectionCount

        public int getConnectionCount()
        Returns the total number of connections in this pool, both free and in use.
      • getFreeConnectionCount

        public int getFreeConnectionCount()
        Returns the number of free connections in this pool.
      • getUsedConnectionCount

        public int getUsedConnectionCount()
        Returns the number of in-use connections in this pool.
      • getConnectionCount

        public int getConnectionCount(java.lang.String user)
        Returns the total number of connections for the specified user in this pool, both free and in use.
      • getFreeConnectionCount

        public int getFreeConnectionCount(java.lang.String user)
        Returns the number of free connections for the specified user in this pool.
      • getUsedConnectionCount

        public int getUsedConnectionCount(java.lang.String user)
        Returns the number of used connections for the specified user in this pool.
      • getUsers

        public java.lang.String[] getUsers()
        Returns an array of users of connections in this pool, both free and in use.