Methods Summary |
---|
public void | activateSession(org.jboss.ejb.StatefulSessionEnterpriseContext ctx)
try
{
ObjectInputStream in;
// Load state
PackagedSession state = this.sessionState.getStateWithOwnership (this.appName, ctx.getId ());
if (state == null)
throw new EJBException ("Could not activate; failed to recover session (session has been probably removed by session-timeout)");
in = new SessionObjectInputStream (ctx, new ByteArrayInputStream (state.getState ()));;
ctx.setInstance ( in.readObject () );
in.close ();
//removePassivated (ctx.getId ());
// Instruct the bean to perform activation logic
((SessionBean)ctx.getInstance()).ejbActivate();
}
catch (ClassNotFoundException e)
{
throw new EJBException ("Could not activate", e);
}
catch (IOException e)
{
throw new EJBException ("Could not activate", e);
}
|
public java.lang.Object | createId(org.jboss.ejb.StatefulSessionEnterpriseContext ctx)
//
// jason: could probably use org.jboss.util.collection.CompoundKey here
// for better uniqueness based on hashCode and such...
//
// return new CompoundKey(this.localNodeName, new UID());
//
return this.localNodeName + ":" + new UID();
|
protected void | createService()
// Initialize the dataStore
// Find HASessionState that we will use
//
String sessionStateName = org.jboss.metadata.ClusterConfigMetaData.DEFAULT_SESSION_STATE_NAME;
ClusterConfigMetaData config = con.getBeanMetaData ().getClusterConfigMetaData ();
if (config != null)
sessionStateName = config.getHaSessionStateName ();
Context ctx = new InitialContext ();
try {
this.sessionState = (HASessionState)ctx.lookup (sessionStateName);
}
finally {
ctx.close();
}
this.localNodeName = this.sessionState.getNodeName ();
this.appName = this.con.getBeanMetaData ().getJndiName ();
this.sessionState.subscribe (this.appName, this);
|
public void | createdSession(org.jboss.ejb.StatefulSessionEnterpriseContext ctx)
this.sessionState.createSession(this.appName, ctx.getId());
|
public void | newSessionStateTopology(org.jboss.ha.framework.interfaces.HAPartition haSubPartition)
|
public void | passivateSession(org.jboss.ejb.StatefulSessionEnterpriseContext ctx)
// do nothing
|
public void | removePassivated(java.lang.Object key)
this.sessionState.removeSession (this.appName, key);
|
public void | removeSession(org.jboss.ejb.StatefulSessionEnterpriseContext ctx)
try
{
// Call bean
((SessionBean)ctx.getInstance()).ejbRemove();
}
finally
{
this.sessionState.removeSession (this.appName, ctx.getId ());
}
|
public void | sessionExternallyModified(org.jboss.ha.hasessionstate.interfaces.PackagedSession session)
// this callback warns us that a session (i.e. a bean) has been externally modified
// this means that we need to tell to our InstanceCache that this bean is no more under its control
// and that it should not keep a cached version of it => CACHE MISS
//
log.trace ("Invalidating cache for session: " + session.getKey());
this.con.getInstanceCache ().remove (session.getKey ());
|
public void | setContainer(org.jboss.ejb.Container c)
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
con = (StatefulSessionContainer)c;
|
protected void | stopService()
this.sessionState.unsubscribe (this.appName, this);
|
public void | synchroSession(org.jboss.ejb.StatefulSessionEnterpriseContext ctx)
try
{
// Call bean
((SessionBean)ctx.getInstance()).ejbPassivate();
// Store state
ByteArrayOutputStream baos = new ByteArrayOutputStream ();
ObjectOutputStream out = new SessionObjectOutputStream (baos);
out.writeObject (ctx.getInstance ());
out.close ();
this.sessionState.setState (this.appName, ctx.getId (), baos.toByteArray ());
((SessionBean)ctx.getInstance()).ejbActivate(); //needed?
}
catch (IOException e)
{
throw new EJBException ("Could not passivate", e);
}
|