org.openejb.core.stateful
Class StatefulInstanceManager

java.lang.Object
  |
  +--org.openejb.core.stateful.StatefulInstanceManager

public class StatefulInstanceManager
extends java.lang.Object

Version:
$Revision: 1.3 $ $Date: 2002/04/05 23:41:31 $

Inner Class Summary
(package private)  class StatefulInstanceManager.BeanEntryQue
          INNER CLASSS
 
Field Summary
protected  java.util.Hashtable beanINDEX
          This index keeps track of all beans that are not passivated.
protected  int BULK_PASSIVATION_SIZE
          Timeout Manager
 org.apache.log4j.Category logger
           
protected  StatefulInstanceManager.BeanEntryQue lruQUE
          This colleciton keeps track of all beans that are in the method ready pool and are not passivated.
protected  PassivationStrategy passivator
          The passivator is responsible for writing beans to disk at passivation time.
protected  long timeOUT
          Represents the time-out period for a stateful bean instance in milliseconds.
protected  SafeToolkit toolkit
           
 
Constructor Summary
StatefulInstanceManager()
          CONSTRUCTOR METHODS
 
Method Summary
protected  BeanEntry activate(java.lang.Object primaryKey)
           
protected  InvalidateReferenceException destroy(BeanEntry entry, java.lang.Exception t)
           
 javax.ejb.EnterpriseBean freeInstance(java.lang.Object primaryKey)
          Permanently removes the bean instance with the specified primaryKey from this instance manager's pool.
 java.lang.Object getAncillaryState(java.lang.Object primaryKey)
          Gets the ancillary state object of the instance with the specified primaryKey.
protected  BeanEntry getBeanEntry(java.lang.Object primaryKey)
          Used by get/setAncillaryState( ) methods
protected  javax.transaction.TransactionManager getTxMngr()
           
protected  void handleCallbackException(java.lang.Throwable e, javax.ejb.EnterpriseBean instance, ThreadContext callContext, java.lang.String callBack)
           
 void init(java.util.Properties props)
          Fully instaniates this instance manager and assigns it to the specified ContainerManager.
protected  void markTxRollbackOnly(javax.transaction.Transaction tx)
           
 javax.ejb.EnterpriseBean newInstance(java.lang.Object primaryKey, java.lang.Class beanClass)
          Instantiates and returns an new instance of the specified bean class.
 javax.ejb.EnterpriseBean newInstance(java.lang.Object primaryKey, java.lang.Object ancillaryState, java.lang.Class beanClass)
          Instantiates and returns an new instance of the specified bean class.
 javax.ejb.EnterpriseBean obtainInstance(java.lang.Object primaryKey)
          Gets a previously instantiated instance of the bean class with the specified primaryKey
protected  void passivate()
          PASSIVATION
 void poolInstance(java.lang.Object primaryKey, javax.ejb.EnterpriseBean bean)
          Hands an instance of the bean class over to this instance manager to be managed until the instace is needed again.
 void setAncillaryState(java.lang.Object primaryKey, java.lang.Object ancillaryState)
          Sets the ancillary state of the bean instance with the specified primaryKey Setting the ancillary state after modifing it is not necessary, because getAncillary state returns an object reference.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeOUT

protected long timeOUT
Represents the time-out period for a stateful bean instance in milliseconds. Measured as the time between method invocations.

beanINDEX

protected java.util.Hashtable beanINDEX
This index keeps track of all beans that are not passivated. A bean in the method ready or "method ready in transaction" pools will be in this index. Passivated beans are not in this index.

lruQUE

protected StatefulInstanceManager.BeanEntryQue lruQUE
This colleciton keeps track of all beans that are in the method ready pool and are not passivated. Beans that are enrolled in a current transaction are NOT elements of this collection. Only beans in the lruQUE may be passivated or timeout.

passivator

protected PassivationStrategy passivator
The passivator is responsible for writing beans to disk at passivation time. Different passivators can be used and are chosen by setting the EnvProps.IM_PASSIVATOR property used in initialization of this instance to a the fully qualified class name of the PassivationStrategy. The passivator is not responsible for invoking any callbacks or other processing. Its only responsibly is to write the bean state to disk.

BULK_PASSIVATION_SIZE

protected int BULK_PASSIVATION_SIZE
Timeout Manager

toolkit

protected SafeToolkit toolkit

logger

public org.apache.log4j.Category logger
Constructor Detail

StatefulInstanceManager

public StatefulInstanceManager()
CONSTRUCTOR METHODS
Method Detail

init

public void init(java.util.Properties props)
          throws OpenEJBException
Fully instaniates this instance manager and assigns it to the specified ContainerManager. The properities passed in a re retrieved from the section of the OpenEJB XML config that defines this instance manager.
Parameters:
props - the properties the instance manager needs to fully initialize and run
Throws:
OpenEJBException - if there is a problem initializing this instance manager

getAncillaryState

public java.lang.Object getAncillaryState(java.lang.Object primaryKey)
                                   throws OpenEJBException
Gets the ancillary state object of the instance with the specified primaryKey. The Ancillary state object is used to hold additional information specific to the bean instance that is not captured by the instance itself. Example: The org.openejb.core.StatefulContainer uses a ancillary object to store the client identity (unique identity of the JVM and computer) that created the stateful bean instance.
Parameters:
primaryKey - the primary key of the bean instance
Returns:
the ancillary state object
Throws:
OpenEJBException - if there is a problem retrieving the ancillary state object
See Also:
SessionKey

setAncillaryState

public void setAncillaryState(java.lang.Object primaryKey,
                              java.lang.Object ancillaryState)
                       throws OpenEJBException
Sets the ancillary state of the bean instance with the specified primaryKey Setting the ancillary state after modifing it is not necessary, because getAncillary state returns an object reference.
Parameters:
primaryKey - the unique key that can identify the instance being managed
ancillaryState - the new ancillary state of the bean instance in this instance manager
Throws:
OpenEJBException - if there is a problem setting the ancillary state object
See Also:
SessionKey

newInstance

public javax.ejb.EnterpriseBean newInstance(java.lang.Object primaryKey,
                                            java.lang.Class beanClass)
                                     throws OpenEJBException
Instantiates and returns an new instance of the specified bean class.
Parameters:
primaryKey - the unique key that can identify the instance being managed
beanClass - the type of the bean's class
Returns:
an new instance of the bean class
Throws:
OpenEJBException - if there is a problem initializing the bean class
See Also:
SessionKey

newInstance

public javax.ejb.EnterpriseBean newInstance(java.lang.Object primaryKey,
                                            java.lang.Object ancillaryState,
                                            java.lang.Class beanClass)
                                     throws OpenEJBException
Instantiates and returns an new instance of the specified bean class.
Parameters:
primaryKey - the unique key that can identify the instance being managed
ancillaryState - the ancillary state of the bean instance in this instance manager
beanClass - the type of the bean's class
Returns:
an new instance of the bean class
Throws:
OpenEJBException - if there is a problem initializing the bean class
See Also:
SessionKey

obtainInstance

public javax.ejb.EnterpriseBean obtainInstance(java.lang.Object primaryKey)
                                        throws OpenEJBException
Gets a previously instantiated instance of the bean class with the specified primaryKey
Parameters:
primaryKey - the unique key that can identify the instance to return
Returns:
an instance of the bean class
Throws:
OpenEJBException - if there is a problem retreiving the instance from the pool
InvalidateReferenceException - if the instance has timed out
See Also:
SessionKey

poolInstance

public void poolInstance(java.lang.Object primaryKey,
                         javax.ejb.EnterpriseBean bean)
                  throws OpenEJBException
Hands an instance of the bean class over to this instance manager to be managed until the instace is needed again.
Parameters:
primaryKey - the unique key that can identify the instance being managed
bean - an instance of the bean class
Throws:
OpenEJBException - if there is a problem adding the instance to the pool
See Also:
SessionKey

freeInstance

public javax.ejb.EnterpriseBean freeInstance(java.lang.Object primaryKey)
                                      throws SystemException
Permanently removes the bean instance with the specified primaryKey from this instance manager's pool. The primaryKey will be of type SessionKey
Parameters:
primaryKey - the unique key that can identify the instance to be freed
Returns:
 
Throws:
OpenEJBException - if there is a problem removing the bean instance from the pool
SystemException -  
See Also:
Sessionkey

passivate

protected void passivate()
                  throws SystemException
PASSIVATION
Throws:
SystemException -  

activate

protected BeanEntry activate(java.lang.Object primaryKey)
                      throws SystemException

destroy

protected InvalidateReferenceException destroy(BeanEntry entry,
                                               java.lang.Exception t)
                                        throws SystemException
Parameters:
entry -  
t -  
Returns:
 
Throws:
SystemException -  

getBeanEntry

protected BeanEntry getBeanEntry(java.lang.Object primaryKey)
                          throws OpenEJBException
Used by get/setAncillaryState( ) methods
Parameters:
primaryKey -  
Returns:
 
Throws:
OpenEJBException -  

handleCallbackException

protected void handleCallbackException(java.lang.Throwable e,
                                       javax.ejb.EnterpriseBean instance,
                                       ThreadContext callContext,
                                       java.lang.String callBack)
                                throws ApplicationException,
                                       SystemException

markTxRollbackOnly

protected void markTxRollbackOnly(javax.transaction.Transaction tx)
                           throws SystemException

getTxMngr

protected javax.transaction.TransactionManager getTxMngr()