Class ConnectionPoolUtil

java.lang.Object
com.saperion.connector.pool.ConnectionPoolUtil

public class ConnectionPoolUtil extends Object
This SessionPoolUtil is used to handle and create the connection poolUtil. Internally the GenericKeyedObjectPool (Apache Commons Pool) is used. Pleas refer to the following website to get more information about the GenericKeyedObjectPool: http://commons.apache.org/pool/apidocs/org/apache/commons/pool/impl/GenericKeyedObjectPool.html
Following properties are needed in given property maps to initialize the pool properly: - poolUtil.test.on.return -> default = false
- poolUtil.test.while.idle -> default = false
- pool.min.idle -> default = 0
- pool.max.idle -> default = 8
- pool.max.active -> default = 10
- pool.max.total -> default = -1
- pool.max.wait -> default = -1
- pool.idle.test.count -> default = 3
- pool.exhausted.action -> default = 1
- pool.time.between.eviction -> default = 120000 // 2min - pool.idle.test.count -> default = 3 - pool.idle.min.evictable.time -> default = 120000 // 2min
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.saperion.connector.authentication.Session
    borrowObject(com.lexmark.saperion.remote.common.authentication.Credentials key)
    Borrows an object from the keyed pool associated with the given key.
    static org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig
    buildPoolConfig(Properties poolConfiguration)
     
    void
    Clears the used object poolUtil.
    org.apache.commons.pool2.impl.GenericKeyedObjectPool<com.lexmark.saperion.remote.common.authentication.Credentials,com.saperion.connector.authentication.Session>
    Gets the object pool.
    void
    initialize(Properties configuration)
    C'tor taking the pool- and saperion classic connector configuration as combined Properties object.
    void
    initialize(Properties poolConfiguration, GenericKeyedSessionPoolFactory sessionPoolFactory, String saperionPropertiesPath)
    Initializes the pool with the given configurations and properties.
    void
    initialize(Properties poolConfiguration, String saperionPropertiesPath)
    Initializes the pool with the given configurations and properties.
    void
    initialize(Properties poolConfiguration, Properties saperionProperties)
    Initializes the pool with the given configurations and properties.
    void
    initialize(org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig poolConfiguration, GenericKeyedSessionPoolFactory sessionPoolFactory, String saperionPropertiesPath)
    Initializes the pool with the given configurations and properties.
    void
    initialize(org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig poolConfiguration, String saperionPropertiesPath)
    Initializes the pool with the given configurations and properties.
    void
    initialize(org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig poolConfiguration, Properties saperionProperties)
    Initializes the pool with the given configurations and properties.
    void
    logStatisticPeriodically(String poolName, long initDelay, long period, TimeUnit unit)
    INFO-logs the pool statistics periodically in an extra Thread.
    void
    Prints the pool statistic.
    void
    returnObject(com.lexmark.saperion.remote.common.authentication.Credentials key, com.saperion.connector.authentication.Session value)
    Returns an object to a keyed pool.
    void
    Closes the poolUtil.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConnectionPoolUtil

      public ConnectionPoolUtil()
  • Method Details

    • buildPoolConfig

      public static org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig buildPoolConfig(Properties poolConfiguration)
    • initialize

      public void initialize(Properties poolConfiguration, String saperionPropertiesPath) throws Exception
      Initializes the pool with the given configurations and properties.
      Parameters:
      poolConfiguration - The Properties object which is used to build the poolUtil configuration.
      saperionPropertiesPath - the path to the configuration files
      Throws:
      Exception - if an error occurs.
    • initialize

      public void initialize(Properties poolConfiguration, GenericKeyedSessionPoolFactory sessionPoolFactory, String saperionPropertiesPath) throws Exception
      Initializes the pool with the given configurations and properties.
      Parameters:
      poolConfiguration - The Properties object which is used to build the poolUtil configuration.
      saperionPropertiesPath - the path to the configuration files
      Throws:
      Exception - if an error occurs.
    • initialize

      public void initialize(org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig poolConfiguration, String saperionPropertiesPath) throws Exception
      Initializes the pool with the given configurations and properties.
      Parameters:
      poolConfiguration - The pool configuration object.
      saperionPropertiesPath - the path to the configuration files
      Throws:
      Exception - if an error occurs.
    • initialize

      public void initialize(org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig poolConfiguration, GenericKeyedSessionPoolFactory sessionPoolFactory, String saperionPropertiesPath) throws Exception
      Initializes the pool with the given configurations and properties.
      Parameters:
      poolConfiguration - The pool configuration object.
      sessionPoolFactory - factory which is responsible to create the pool objects e.g. GenericKeyedSessionPoolFactory or TechUserKeyedSessionPoolFactory
      saperionPropertiesPath - the path to the configuration files
      Throws:
      Exception - if an error occurs.
    • initialize

      public void initialize(Properties poolConfiguration, Properties saperionProperties) throws Exception
      Initializes the pool with the given configurations and properties.
      Parameters:
      poolConfiguration - The pool configuration object.
      saperionProperties - the classic connector configuration
      Throws:
      Exception - if an error occurs.
    • initialize

      public void initialize(org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig poolConfiguration, Properties saperionProperties) throws Exception
      Initializes the pool with the given configurations and properties.
      Parameters:
      poolConfiguration - The pool configuration object.
      saperionProperties - the classic connector configuration
      Throws:
      Exception - if an error occurs.
    • initialize

      public void initialize(Properties configuration)
      C'tor taking the pool- and saperion classic connector configuration as combined Properties object.
      Parameters:
      configuration - the pool- and saperion classic connector configuration.
    • clearPool

      public void clearPool() throws FactoryException
      Clears the used object poolUtil.
      Throws:
      FactoryException - if an connection factory failure occurs.
    • shutdown

      public void shutdown() throws FactoryException
      Closes the poolUtil.
      Throws:
      FactoryException - if an connection factory failure occurs.
    • getObjectPool

      public org.apache.commons.pool2.impl.GenericKeyedObjectPool<com.lexmark.saperion.remote.common.authentication.Credentials,com.saperion.connector.authentication.Session> getObjectPool()
      Gets the object pool.
      Returns:
      the object pool.
    • printPoolStatistic

      public void printPoolStatistic()
      Prints the pool statistic.
    • logStatisticPeriodically

      public void logStatisticPeriodically(String poolName, long initDelay, long period, TimeUnit unit)
      INFO-logs the pool statistics periodically in an extra Thread.
      Parameters:
      poolName -
      initDelay -
      period -
      unit -
    • borrowObject

      public com.saperion.connector.authentication.Session borrowObject(com.lexmark.saperion.remote.common.authentication.Credentials key) throws Exception
      Borrows an object from the keyed pool associated with the given key.
      Parameters:
      key - the key to identify the object
      Returns:
      the object (Session) associated with the key
      Throws:
      Exception - when make object throws an exception
      See Also:
      • GenericKeyedObjectPool.borrowObject(Object)
    • returnObject

      public void returnObject(com.lexmark.saperion.remote.common.authentication.Credentials key, com.saperion.connector.authentication.Session value) throws Exception
      Returns an object to a keyed pool.
      Parameters:
      key - the objects key
      value - the object (Session) to return
      Throws:
      Exception - when returning the session failed