org.mule.util.pool
Class CommonsPoolObjectPool

java.lang.Object
  extended by org.mule.util.pool.CommonsPoolObjectPool
All Implemented Interfaces:
Disposable, Initialisable, ObjectPool
Direct Known Subclasses:
DefaultLifecycleEnabledObjectPool

public class CommonsPoolObjectPool
extends Object
implements ObjectPool

CommonsPoolProxyPool is an implementation of ObjectPool that internally uses the commons-pool GenericObjectPool and uses a ObjectFactory for creating new pooled instances.


Field Summary
protected static Log logger
          logger used by this class
protected  MuleContext muleContext
           
protected  ObjectFactory objectFactory
          The ObjectFactory used to create new pool instances
protected  GenericObjectPool pool
          The pool
protected  PoolingProfile poolingProfile
          The pooling profile used to configure and initialise pool
 
Fields inherited from interface org.mule.api.lifecycle.Initialisable
PHASE_NAME
 
Fields inherited from interface org.mule.api.lifecycle.Disposable
PHASE_NAME
 
Constructor Summary
CommonsPoolObjectPool(ObjectFactory objectFactory, PoolingProfile poolingProfile, MuleContext muleContext)
          Creates a new pool and an Object factory with the ServiceDescriptor
 
Method Summary
protected  void applyInitialisationPolicy()
           
 Object borrowObject()
           
 void clear()
           
 void close()
           
 void dispose()
          A lifecycle method where implementor should free up any resources.
 int getMaxActive()
           
 int getNumActive()
           
 ObjectFactory getObjectFactory()
           
protected  PoolableObjectFactory getPooledObjectFactory()
          Template method to be overridden by implementations that do more than just invoke objectFactory
 void initialise()
          Method used to perform any initialisation work.
 void returnObject(Object object)
           
 void setObjectFactory(ObjectFactory objectFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Log logger
logger used by this class


pool

protected GenericObjectPool pool
The pool


objectFactory

protected ObjectFactory objectFactory
The ObjectFactory used to create new pool instances


poolingProfile

protected PoolingProfile poolingProfile
The pooling profile used to configure and initialise pool


muleContext

protected MuleContext muleContext
Constructor Detail

CommonsPoolObjectPool

public CommonsPoolObjectPool(ObjectFactory objectFactory,
                             PoolingProfile poolingProfile,
                             MuleContext muleContext)
Creates a new pool and an Object factory with the ServiceDescriptor

Method Detail

initialise

public void initialise()
                throws InitialisationException
Description copied from interface: Initialisable
Method used to perform any initialisation work. If a fatal error occurs during initialisation an InitialisationException should be thrown, causing the Mule instance to shutdown. If the error is recoverable, say by retrying to connect, a RecoverableException should be thrown. There is no guarantee that by throwing a Recoverable exception that the Mule instance will not shut down.

Specified by:
initialise in interface Initialisable
Throws:
InitialisationException - if a fatal error occurs causing the Mule instance to shutdown
RecoverableException - if an error occurs that can be recovered from

getPooledObjectFactory

protected PoolableObjectFactory getPooledObjectFactory()
Template method to be overridden by implementations that do more than just invoke objectFactory


applyInitialisationPolicy

protected void applyInitialisationPolicy()
                                  throws Exception
Throws:
Exception

borrowObject

public Object borrowObject()
                    throws Exception
Specified by:
borrowObject in interface ObjectPool
Throws:
Exception

returnObject

public void returnObject(Object object)
Specified by:
returnObject in interface ObjectPool

getNumActive

public int getNumActive()
Specified by:
getNumActive in interface ObjectPool

getMaxActive

public int getMaxActive()
Specified by:
getMaxActive in interface ObjectPool

dispose

public void dispose()
Description copied from interface: Disposable
A lifecycle method where implementor should free up any resources. If an exception is thrown it should just be logged and processing should continue. This method should not throw Runtime exceptions.

Specified by:
dispose in interface Disposable

clear

public void clear()
Specified by:
clear in interface ObjectPool

close

public void close()
Specified by:
close in interface ObjectPool

setObjectFactory

public void setObjectFactory(ObjectFactory objectFactory)
Specified by:
setObjectFactory in interface ObjectPool

getObjectFactory

public ObjectFactory getObjectFactory()
Specified by:
getObjectFactory in interface ObjectPool


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.