public class MdbInstanceFactory
A MdbInstanceFactory creates instances of message driven beans for a single instance. This class differs from other
instance managers in OpenEJB as it doesn't do pooling and it creates instances for only a single EJB deployment.
The MdbContainer assumes that the resouce adapter is pooling message endpoints so a second level of pooling in the
container would be inefficient. This is true of all known resouce adapters in opensource (ActiveMQ), so if this is
a poor assumption for your resource adapter, contact the OpenEJB developers.
This class can optionally limit the number of bean instances and therefore the message endpoints available to the
Gets the maximal number of instances that can exist at any time.
the maximum number of instances or <= 0 if unlimitied
public int getInstanceCount()
Gets the current number of created instances.
the current number of instances created
public java.lang.Object createInstance(boolean ignoreInstanceCount)
Creates a new mdb instance preforming all necessary lifecycle callbacks
a new message driven bean instance
UnavailableException - if the instance limit has been exceeded or
if an exception occurs while creating the bean instance
public void freeInstance(Instance instance,
Frees an instance no longer needed by the resource adapter. This method makes all the necessary lifecycle
callbacks and decrements the instance count. This method should not be used to disposed of beans that have
thrown a system exception. Instead the discardInstance method should be called.
instance - the bean instance to free
public java.lang.Object recreateInstance(java.lang.Object bean)
Recreates a bean instance that has thrown a system exception. As required by the EJB specification, lifecycle
callbacks are not invoked. To normally free a bean instance call the freeInstance method.