org.jboss.ejb3.cache.simple
Class StatefulSessionFilePersistenceManager

java.lang.Object
  extended by org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager
All Implemented Interfaces:
StatefulSessionPersistenceManager

public class StatefulSessionFilePersistenceManager
extends Object
implements StatefulSessionPersistenceManager

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.

Version:
$Revision: 80079 $
Author:
Rickard ?berg, Marc Fleury, Sebastien Alborini, Jason Dillon, Bill Burke

Field Summary
 
Fields inherited from interface org.jboss.ejb3.cache.simple.StatefulSessionPersistenceManager
DEFAULT_STORE_DIRECTORY_NAME, log
 
Constructor Summary
StatefulSessionFilePersistenceManager()
           
 
Method Summary
 StatefulBeanContext activateSession(Object id)
          Restores session state from the serialized file & invokes SessionBean.ejbActivate() on the target bean.
 void destroy()
          Purge any data in the store, and then the store directory too.
 List<StatefulBeanContext> getPassivatedBeans()
           
 boolean getPurgeEnabled()
          Get the stale session state purge enabled flag.
 File getStoreDirectory()
          Returns the directory used to store session passivation state files.
 String getStoreDirectoryName()
          Get the sub-directory name under the server data directory where session data is stored.
 void initialize(Container con)
          Setup the session data storage directory.
 void passivateSession(StatefulBeanContext ctx)
          Invokes SessionBean.ejbPassivate() on the target bean and saves the state of the session to a file.
 void purgeAllSessionData()
          Removes any state files left in the storgage directory.
 void removePassivated(Object id)
          Removes the saved state file (if any) for the given session id.
 void setContainer(Container con)
           
 void setPurgeEnabled(boolean flag)
          Set the stale session state purge enabled flag.
 void setStoreDirectoryName(String dirName)
          Set the sub-directory name under the server data directory where session data will be stored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatefulSessionFilePersistenceManager

public StatefulSessionFilePersistenceManager()
Method Detail

setStoreDirectoryName

public void setStoreDirectoryName(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 String getStoreDirectoryName()
Get the sub-directory name under the server data directory where session data is stored.

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.

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

getPurgeEnabled

public boolean getPurgeEnabled()
Get the stale session state purge enabled flag.

Returns:
True if purge is enabled.

getStoreDirectory

public File getStoreDirectory()
Returns the directory used to store session passivation state files.

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

setContainer

public void setContainer(Container con)

initialize

public void initialize(Container con)
                throws Exception
Setup the session data storage directory.

Purges any existing session data found.

Specified by:
initialize in interface StatefulSessionPersistenceManager
Throws:
Exception

purgeAllSessionData

public void purgeAllSessionData()
Removes any state files left in the storgage directory.


destroy

public void destroy()
             throws Exception
Purge any data in the store, and then the store directory too.

Specified by:
destroy in interface StatefulSessionPersistenceManager
Throws:
Exception

activateSession

public StatefulBeanContext activateSession(Object id)
Restores session state from the serialized file & invokes SessionBean.ejbActivate() on the target bean.

Specified by:
activateSession in interface StatefulSessionPersistenceManager

getPassivatedBeans

public List<StatefulBeanContext> getPassivatedBeans()
Specified by:
getPassivatedBeans in interface StatefulSessionPersistenceManager

passivateSession

public void passivateSession(StatefulBeanContext ctx)
Invokes SessionBean.ejbPassivate() on the target bean and saves the state of the session to a file.

Specified by:
passivateSession in interface StatefulSessionPersistenceManager

removePassivated

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

Specified by:
removePassivated in interface StatefulSessionPersistenceManager


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.