org.jboss.ejb.plugins
Class StatefulSessionFilePersistenceManager

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.ejb.plugins.StatefulSessionFilePersistenceManager
All Implemented Interfaces:
AllowedOperationsFlags (src) , ContainerPlugin (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src) , StatefulSessionPersistenceManager (src)

public class StatefulSessionFilePersistenceManager
extends ServiceMBeanSupport (src)
implements StatefulSessionPersistenceManager (src)

A file-based stateful session bean persistence manager.

Reads and writes session bean objects to files by using the standard Java serialization mechanism.

Passivated state files are stored under: jboss-server-data-dir/storeDirectoryName/ejb-name-unique-id.

Since ejb-name is not unique across deployments we generate a unique-id to make sure that beans with the same EJB name do not collide.


Field Summary
static java.lang.String DEFAULT_STORE_DIRECTORY_NAME
          The default store directory name ("sessions").
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
log, server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.ejb.AllowedOperationsFlags (src)
IN_AFTER_BEGIN, IN_AFTER_COMPLETION, IN_BEFORE_COMPLETION, IN_BUSINESS_METHOD, IN_EJB_ACTIVATE, IN_EJB_CREATE, IN_EJB_FIND, IN_EJB_HOME, IN_EJB_LOAD, IN_EJB_PASSIVATE, IN_EJB_POST_CREATE, IN_EJB_REMOVE, IN_EJB_STORE, IN_EJB_TIMEOUT, IN_INTERCEPTOR_METHOD, IN_SERVICE_ENDPOINT_METHOD, IN_SET_ENTITY_CONTEXT, IN_SET_MESSAGE_DRIVEN_CONTEXT, IN_SET_SESSION_CONTEXT, IN_UNSET_ENTITY_CONTEXT, NOT_ALLOWED
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
StatefulSessionFilePersistenceManager()
           
 
Method Summary
 void activateSession(StatefulSessionEnterpriseContext (src)  ctx)
          Restores session state from the serialized file & invokes SessionBean.ejbActivate() on the target bean.
 void createdSession(StatefulSessionEnterpriseContext (src)  ctx)
          Non-operation.
 java.lang.Object createId(StatefulSessionEnterpriseContext (src)  ctx)
          Create a unique identifier for the given SFSB context.
protected  void createService()
          Setup the session data storage directory.
protected  void destroyService()
          Purge any data in the store, and then the store directory too.
 boolean getPurgeEnabled()
          Get the stale session state purge enabled flag.
 java.io.File getStoreDirectory()
          Returns the directory used to store session passivation state files.
 java.lang.String getStoreDirectoryName()
          Get the sub-directory name under the server data directory where session data is stored.
 void passivateSession(StatefulSessionEnterpriseContext (src)  ctx)
          Invokes SessionBean.ejbPassivate() on the target bean and saves the state of the session to a file.
 void removePassivated(java.lang.Object id)
          Removes the saved state file (if any) for the given session id.
 void removeSession(StatefulSessionEnterpriseContext (src)  ctx)
          Invokes SessionBean.ejbRemove() on the target bean.
 void setContainer(Container (src)  con)
          Saves a reference to the StatefulSessionContainer (src) for its bean type.
 void setPurgeEnabled(boolean flag)
          Set the stale session state purge enabled flag.
 void setStoreDirectoryName(java.lang.String dirName)
          Set the sub-directory name under the server data directory where session data will be stored.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, destroy, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, startService, stop, stopService
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.system.Service (src)
create, destroy, start, stop
 

Field Detail

DEFAULT_STORE_DIRECTORY_NAME

public static final java.lang.String DEFAULT_STORE_DIRECTORY_NAME
The default store directory name ("sessions").

See Also:
Constant Field Values (src)
Constructor Detail

StatefulSessionFilePersistenceManager

public StatefulSessionFilePersistenceManager()
Method Detail

setContainer

public void setContainer(Container (src)  con)
Saves a reference to the StatefulSessionContainer (src) for its bean type.

Specified by:
setContainer in interface ContainerPlugin (src)
Parameters:
con - The container using this plugin. This may be null if the plugin is being disassociated from a container.
Throws:
java.lang.ClassCastException - Container is not a StatefulSessionContainer.

setStoreDirectoryName

public void setStoreDirectoryName(java.lang.String dirName)
Set the sub-directory name under the server data directory where session data will be stored.

This value will be appened to the value of jboss-server-data-dir.

This value is only used during creation and will not dynamically change the store directory when set after the create step has finished.

Parameters:
dirName - A sub-directory name.

getStoreDirectoryName

public java.lang.String getStoreDirectoryName()
Get the sub-directory name under the server data directory where session data is stored. jmx:managed-attribute

Returns:
A sub-directory name.
See Also:
setStoreDirectoryName(java.lang.String)

setPurgeEnabled

public void setPurgeEnabled(boolean flag)
Set the stale session state purge enabled flag. jmx:managed-attribute

Parameters:
flag - The toggle flag to enable or disable purging.

getPurgeEnabled

public boolean getPurgeEnabled()
Get the stale session state purge enabled flag. jmx:managed-attribute

Returns:
True if purge is enabled.

getStoreDirectory

public java.io.File getStoreDirectory()
Returns the directory used to store session passivation state files. jmx:managed-attribute

Returns:
The directory used to store session passivation state files.

createService

protected void createService()
                      throws java.lang.Exception
Setup the session data storage directory.

Purges any existing session data found.

Overrides:
createService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

destroyService

protected void destroyService()
                       throws java.lang.Exception
Purge any data in the store, and then the store directory too.

Overrides:
destroyService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

createId

public java.lang.Object createId(StatefulSessionEnterpriseContext (src)  ctx)
                          throws java.lang.Exception
Description copied from interface: StatefulSessionPersistenceManager (src)
Create a unique identifier for the given SFSB context.

Specified by:
createId in interface StatefulSessionPersistenceManager (src)
Parameters:
ctx - The context of the SFSB to create an unique identifier for.
Returns:
A UID (src) .
Throws:
java.lang.Exception - Failed to create unique identifier.

createdSession

public void createdSession(StatefulSessionEnterpriseContext (src)  ctx)
                    throws java.lang.Exception
Non-operation.

Specified by:
createdSession in interface StatefulSessionPersistenceManager (src)
Parameters:
ctx - The context of the SFSB which was created.
Throws:
java.lang.Exception

activateSession

public void activateSession(StatefulSessionEnterpriseContext (src)  ctx)
                     throws java.rmi.RemoteException
Restores session state from the serialized file & invokes SessionBean.ejbActivate() on the target bean.

Specified by:
activateSession in interface StatefulSessionPersistenceManager (src)
Parameters:
ctx - The context of the SFSB to activate.
Throws:
java.rmi.RemoteException

passivateSession

public void passivateSession(StatefulSessionEnterpriseContext (src)  ctx)
                      throws java.rmi.RemoteException
Invokes SessionBean.ejbPassivate() on the target bean and saves the state of the session to a file.

Specified by:
passivateSession in interface StatefulSessionPersistenceManager (src)
Parameters:
ctx - The context of the SFSB to passivate.
Throws:
java.rmi.RemoteException

removeSession

public void removeSession(StatefulSessionEnterpriseContext (src)  ctx)
                   throws java.rmi.RemoteException,
                          RemoveException (src) 
Invokes SessionBean.ejbRemove() on the target bean.

Specified by:
removeSession in interface StatefulSessionPersistenceManager (src)
Parameters:
ctx - The context of the SFSB to remove.
Throws:
java.rmi.RemoteException
RemoveException (src)

removePassivated

public void removePassivated(java.lang.Object id)
Removes the saved state file (if any) for the given session id.

Specified by:
removePassivated in interface StatefulSessionPersistenceManager (src)
Parameters:
id - The identifier of the SFSB to remove passivate state for.