org.sadun.util.pool
Class ManagedObjectPool

java.lang.Object
  extended byorg.sadun.util.pool.ManagedObjectPool
All Implemented Interfaces:
ManagedObjectPoolMBean, javax.management.MBeanRegistration

public class ManagedObjectPool
extends java.lang.Object
implements ManagedObjectPoolMBean, javax.management.MBeanRegistration

Author:
Cristiano Sadun

Constructor Summary
  ManagedObjectPool()
           
protected ManagedObjectPool(int size, java.lang.String factoryClassName)
          Subclasses (which handles more specific object pools) may directly specify default size and factory class name.
 
Method Summary
 java.lang.String getClassName()
           
 java.lang.String getFactoryClassName()
          Return the name of the pool's factory class, or null if no factory class is employed.
 int getFreeCount()
          Return the number of available objects in the pool
 java.lang.Class getObjectType()
          Return the object type pooled by this pool
 int getSize()
          Return the size of the pool
 int getUsedCount()
          Return the number of used objects in the pool
 void postDeregister()
           
 void postRegister(java.lang.Boolean registrationDone)
           
 void preDeregister()
           
 javax.management.ObjectName preRegister(javax.management.MBeanServer arg0, javax.management.ObjectName arg1)
           
 void setClassName(java.lang.String className)
          Set the name of the class to produce.
 void setFactoryClassName(java.lang.String factoryClassName)
          Set the name of the pool's factory class.
 void setSize(int size)
          Set the pool size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagedObjectPool

public ManagedObjectPool()

ManagedObjectPool

protected ManagedObjectPool(int size,
                            java.lang.String factoryClassName)
Subclasses (which handles more specific object pools) may directly specify default size and factory class name.

Parameters:
size -
factoryClassName -
Method Detail

getFactoryClassName

public java.lang.String getFactoryClassName()
Return the name of the pool's factory class, or null if no factory class is employed.

Specified by:
getFactoryClassName in interface ManagedObjectPoolMBean
Returns:
the name of the pool's factory class, or null if no factory class is employed.

setFactoryClassName

public void setFactoryClassName(java.lang.String factoryClassName)
                         throws javax.management.MBeanException
Set the name of the pool's factory class. The pool is reset, using the given factory to populate it.

This property cannot be changed if some client has already acquired pooled objects.

Specified by:
setFactoryClassName in interface ManagedObjectPoolMBean
Parameters:
factoryClassName - the new factory class name
Throws:
javax.management.MBeanException

setSize

public void setSize(int size)
             throws javax.management.MBeanException
Set the pool size. If the specified size is different than the current size, the pool is reset to the given size.

This property cannot be changed if some client has already acquired pooled objects.

Specified by:
setSize in interface ManagedObjectPoolMBean
Parameters:
size - the new size
Throws:
javax.management.MBeanException

setClassName

public void setClassName(java.lang.String className)
                  throws javax.management.MBeanException
Set the name of the class to produce. This nullifies the factory class name, if defined.

This property cannot be changed if some client has already acquired pooled objects.

Parameters:
className - the name of the class of the objects to pool.
Throws:
javax.management.MBeanException

getFreeCount

public int getFreeCount()
Description copied from interface: ManagedObjectPoolMBean
Return the number of available objects in the pool

Specified by:
getFreeCount in interface ManagedObjectPoolMBean
Returns:
the number of available objects in the pool
See Also:
ManagedObjectPoolMBean.getFreeCount()

getObjectType

public java.lang.Class getObjectType()
Description copied from interface: ManagedObjectPoolMBean
Return the object type pooled by this pool

Specified by:
getObjectType in interface ManagedObjectPoolMBean

getSize

public int getSize()
Description copied from interface: ManagedObjectPoolMBean
Return the size of the pool

Specified by:
getSize in interface ManagedObjectPoolMBean
Returns:
the size of the pool

getUsedCount

public int getUsedCount()
Description copied from interface: ManagedObjectPoolMBean
Return the number of used objects in the pool

Specified by:
getUsedCount in interface ManagedObjectPoolMBean
Returns:
the number of used objects in the pool

getClassName

public java.lang.String getClassName()
Returns:

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface javax.management.MBeanRegistration

postRegister

public void postRegister(java.lang.Boolean registrationDone)
Specified by:
postRegister in interface javax.management.MBeanRegistration

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Specified by:
preDeregister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception

preRegister

public javax.management.ObjectName preRegister(javax.management.MBeanServer arg0,
                                               javax.management.ObjectName arg1)
                                        throws java.lang.Exception
Specified by:
preRegister in interface javax.management.MBeanRegistration
Throws:
java.lang.Exception