Class ManagedObjectPool<K,​O>

  • Type Parameters:
    K - Key type of the pooled objects
    O - Type of the pooled objects
    All Implemented Interfaces:
    SelfRegistering, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.jmx.export.naming.SelfNaming
    Direct Known Subclasses:
    LibreOfficeInstancePool, MSOfficeConverterPool, XSLTransformerPool

    @ManagedResource
    public abstract class ManagedObjectPool<K,​O>
    extends Object
    implements org.springframework.jmx.export.naming.SelfNaming, SelfRegistering, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
    A generic keyed pool that exposes all management functions and some statistical data via JMX.
    • Constructor Detail

      • ManagedObjectPool

        public ManagedObjectPool()
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        Exception
      • destroy

        public void destroy()
        Specified by:
        destroy in interface org.springframework.beans.factory.DisposableBean
      • getName

        protected abstract String getName()
      • getLogger

        protected abstract org.jadice.util.log.Logger getLogger()
      • doBorrowObject

        protected abstract O doBorrowObject​(K key)
                                     throws Exception
        Throws:
        Exception
      • returnObject

        public final void returnObject​(O object)
                                throws Exception
        Throws:
        Exception
      • doReturnObject

        protected abstract void doReturnObject​(O object)
                                        throws Exception
        Throws:
        Exception
      • invalidateObject

        public final void invalidateObject​(O object)
                                    throws Exception
        Throws:
        Exception
      • doInvalidateObject

        protected abstract void doInvalidateObject​(O object)
                                            throws Exception
        Throws:
        Exception
      • getPool

        protected abstract org.apache.commons.pool.impl.GenericKeyedObjectPool getPool()
      • getObjectName

        public ObjectName getObjectName()
        Specified by:
        getObjectName in interface org.springframework.jmx.export.naming.SelfNaming
      • getNumActive

        @ManagedAttribute(description="Current number of active instances")
        public int getNumActive()
      • getNumIdle

        @ManagedAttribute(description="Current number of idle instances")
        public int getNumIdle()
      • getNumReturned

        @ManagedAttribute(description="Number of instances returned normally")
        public long getNumReturned()
      • getNumInvalidated

        @ManagedAttribute(description="Number of instances returned abnormally")
        public long getNumInvalidated()
      • getMaxIdle

        @ManagedAttribute(description="Maximum number of idle instances")
        public int getMaxIdle()
      • setMaxIdle

        @ManagedAttribute(description="Maximum number of idle instances")
        public void setMaxIdle​(int maxIdle)
      • getMaxActive

        @ManagedAttribute(description="Maximum number of active instances")
        public int getMaxActive()
      • setMaxActive

        @ManagedAttribute(description="Maximum number of active instances")
        public void setMaxActive​(int maxActive)
      • clearPool

        @ManagedOperation(description="Clear all instances from the pool")
        public void clearPool()
      • clearOldest

        @ManagedOperation(description="Clear oldest 15% of instances from the pool.")
        public void clearOldest()
      • getTimeBetweenEvictionRunsMillis

        @ManagedAttribute(description="Period time when eviction thread should examine idle objects. (Value <= 0 deactivates eviction)")
        public long getTimeBetweenEvictionRunsMillis()
      • setTimeBetweenEvictionRunsMillis

        @ManagedAttribute(description="Period time when eviction thread should examine idle objects. (Value <= 0 deactivates eviction)")
        public void setTimeBetweenEvictionRunsMillis​(long timeBetweenEvictionRunsMillis)
      • evictPool

        @ManagedOperation(description="Run the pool eviction thread manually. This will remove instances which have become eligible for eviction.")
        public void evictPool()
                       throws Exception
        Throws:
        Exception
      • getMinEvictableIdleTimeMillis

        @ManagedAttribute(description="Minimum time after which an idle instance is evicted from the pool")
        public long getMinEvictableIdleTimeMillis()
      • setMinEvictableIdleTimeMillis

        @ManagedAttribute(description="Minimum time after which an idle instance is evicted from the pool")
        public void setMinEvictableIdleTimeMillis​(long minEvictableIdleTimeMillis)
      • getMinIdle

        @ManagedAttribute(description="Minimum number of idle instances that should survive the eviction")
        public int getMinIdle()
      • setMinIdle

        @ManagedAttribute(description="Minimum number of idle instances that should survive the eviction")
        public void setMinIdle​(int minIdle)
      • getRecentAvgWaitingTime

        @ManagedAttribute(description="Avg. time taken for the last 10 accesses to the pool [milliseconds]")
        public long getRecentAvgWaitingTime()
      • getRecentMinWaitingTime

        @ManagedAttribute(description="Min. time taken for the last 10 accesses to the pool [milliseconds]")
        public long getRecentMinWaitingTime()
      • getRecentMaxWaitingTime

        @ManagedAttribute(description="Max. time taken for the last 10 accesses to the pool [milliseconds]")
        public long getRecentMaxWaitingTime()
      • getAvgWaitingTime

        @ManagedAttribute(description="Avg. time taken to access the pool [milliseconds]")
        public long getAvgWaitingTime()
      • clearWaitingTimes

        @ManagedOperation(description="Clear all statistical data about pool access times")
        public void clearWaitingTimes()