JBoss.org Community Documentation

11.3.2.3. org.jboss.ejb.InstancePool

An InstancePool is used to manage the EJB instances that are not associated with any identity. The pools actually manage subclasses of the org.jboss.ejb.EnterpriseContext objects that aggregate unassociated bean instances and related data.

public interface InstancePool
						extends ContainerPlugin
						{
						/** 
						* Get an instance without identity. Can be used
						* by finders and create-methods, or stateless beans
						*
						* @return Context /w instance
						* @exception RemoteException
						*/
						public EnterpriseContext get() throws Exception;
						
						/** Return an anonymous instance after invocation.
						*
						* @param ctx
						*/
						public void free(EnterpriseContext ctx);
						
						/**
						* Discard an anonymous instance after invocation.
						* This is called if the instance should not be reused,
						* perhaps due to some exception being thrown from it.
						*
						* @param ctx
						*/
						public void discard(EnterpriseContext ctx);
						
						/**
						* Return the size of the pool.
						*
						* @return the size of the pool.
						*/
						public int getCurrentSize();
						
						/**
						* Get the maximum size of the pool.
						*
						* @return the size of the pool.
						*/
						public int getMaxSize();
						}
					

Example 11.6. The org.jboss.ejb.InstancePool interface


Depending on the configuration, a container may choose to have a certain size of the pool contain recycled instances, or it may choose to instantiate and initialize an instance on demand.

The pool is used by the InstanceCache implementation to acquire free instances for activation, and it is used by interceptors to acquire instances to be used for Home interface methods (create and finder calls).