org.jboss.ejb3.stateful
Class StatefulBeanContext

java.lang.Object
  extended by org.jboss.ejb3.BaseContext<T>
      extended by org.jboss.ejb3.session.SessionBeanContext<T>
          extended by org.jboss.ejb3.session.SessionSpecBeanContext<StatefulContainer>
              extended by org.jboss.ejb3.stateful.StatefulBeanContext
All Implemented Interfaces:
Externalizable, Serializable, org.jboss.ejb3.cache.Identifiable, org.jboss.ejb3.interceptors.container.BeanContext<Object>, org.jboss.ejb3.tx.container.StatefulBeanContext<Object>
Direct Known Subclasses:
NestedStatefulBeanContext, ProxiedStatefulBeanContext

public class StatefulBeanContext
extends SessionSpecBeanContext<StatefulContainer>
implements org.jboss.ejb3.cache.Identifiable, Externalizable, org.jboss.ejb3.tx.container.StatefulBeanContext<Object>

BeanContext for a stateful session bean. Either bean or beanMO are always filled.

Version:
$Revision: 73457 $
Author:
Bill Burke, Brian Stansberry
See Also:
Serialized Form

Field Summary
protected  org.jboss.serial.io.MarshalledObject beanMO
           
protected  StatefulBeanContext containedIn
           
protected  String containerClusterUid
           
protected  String containerGuid
           
protected  List<StatefulBeanContext> contains
           
static ThreadLocalStack<StatefulBeanContext> currentBean
           
protected  boolean discarded
           
protected  Object id
           
protected  boolean inInvocation
           
protected  boolean isClustered
           
 long lastUsed
           
protected  ReentrantLock lock
           
 boolean markedForPassivation
           
 boolean markedForReplication
           
protected  boolean passivated
           
protected  HashMap<String,javax.persistence.EntityManager> persistenceContexts
           
static ThreadLocalStack<StatefulBeanContext> propagatedContainedIn
           
protected  boolean removed
           
protected  boolean replicationIsPassivation
           
protected  boolean txSynchronized
           
 
Fields inherited from class org.jboss.ejb3.session.SessionBeanContext
ejbContext
 
Fields inherited from class org.jboss.ejb3.BaseContext
bean, container, interceptorInstances, log, metadata, rm
 
Constructor Summary
  StatefulBeanContext()
          Deprecated.  
protected StatefulBeanContext(StatefulContainer container, org.jboss.serial.io.MarshalledObject beanMO)
          An incoming context from serialization.
protected StatefulBeanContext(StatefulContainer container, Object bean)
          A brand new stateful session bean.
 
Method Summary
 void activateAfterReplication()
           
 void addContains(StatefulBeanContext ctx)
           
 void addExtendedPersistenceContext(String id, javax.persistence.EntityManager pc)
           
 boolean equals(Object obj)
           
protected  void extractBeanAndInterceptors()
           
 boolean getCanPassivate()
          Checks whether this context or any of its children are in use.
 boolean getCanRemoveFromCache()
           
 StatefulBeanContext getContainedIn()
           
 StatefulContainer getContainer()
           
 List<StatefulBeanContext> getContains()
           
 javax.ejb.EJBContext getEJBContext()
           
 javax.persistence.EntityManager getExtendedPersistenceContext(String id)
           
 Map<String,javax.persistence.EntityManager> getExtendedPersistenceContexts()
           
 Object getId()
           
 Object getInstance()
          Returns the enterprise bean, never returns null.
 Object[] getInterceptorInstances(InterceptorInfo[] interceptorInfos)
           
 Object getInvokedMethodKey()
           
 ReentrantLock getLock()
           
 org.jboss.aop.metadata.SimpleMetaData getMetaData()
           
 boolean getReplicationIsPassivation()
           
 StatefulBeanContext getUltimateContainedIn()
           
 int hashCode()
           
 boolean isDiscarded()
           
 boolean isInInvocation()
           
 boolean isInUse()
           
 boolean isModified()
           
 boolean isRemoved()
           
 boolean isTxSynchronized()
           
 void passivateAfterReplication()
          Notification from a ClusteredStatefulCache to inform that a bean that is stored in the distributed cache is now being passivated as well.
 void popContainedIn()
           
 void postActivate()
          Notification from a non-clustered StatefulCache to inform that we have been activated.
 void postReplicate()
          Notification from a ClusteredStatefulCache after the bean is fetched from the distributed cache.
 void prePassivate()
          Notification from a non-clustered StatefulCache to inform that we are about to be passivated.
 void preReplicate()
          Notification from a ClusteredStatefulCache before a bean is replicated.
 StatefulBeanContext pushContainedIn()
           
 void readExternal(ObjectInput in)
           
 void remove()
           
 void removeContains(StatefulBeanContext ctx)
           
 void removeExtendedPersistenceContext(String id)
           
 boolean scanForExtendedPersistenceContext(String id, StatefulBeanContext ignore)
           
 void setDiscarded(boolean discarded)
           
 void setInInvocation(boolean inInvocation)
           
 void setInUse(boolean inUse)
           
 void setReplicationIsPassivation(boolean replicationIsPassivation)
           
 void setTxSynchronized(boolean txSynchronized)
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.jboss.ejb3.BaseContext
getInterceptor, initialiseInterceptorInstances
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.ejb3.interceptors.container.BeanContext
getInterceptor
 

Field Detail

id

protected Object id

txSynchronized

protected boolean txSynchronized

inInvocation

protected boolean inInvocation

beanMO

protected org.jboss.serial.io.MarshalledObject beanMO

lock

protected ReentrantLock lock

discarded

protected boolean discarded

propagatedContainedIn

public static ThreadLocalStack<StatefulBeanContext> propagatedContainedIn

currentBean

public static ThreadLocalStack<StatefulBeanContext> currentBean

containedIn

protected StatefulBeanContext containedIn

contains

protected List<StatefulBeanContext> contains

persistenceContexts

protected HashMap<String,javax.persistence.EntityManager> persistenceContexts

removed

protected boolean removed

containerClusterUid

protected String containerClusterUid

containerGuid

protected String containerGuid

isClustered

protected boolean isClustered

replicationIsPassivation

protected boolean replicationIsPassivation

passivated

protected transient boolean passivated

markedForPassivation

public volatile boolean markedForPassivation

markedForReplication

public volatile boolean markedForReplication

lastUsed

public long lastUsed
Constructor Detail

StatefulBeanContext

protected StatefulBeanContext(StatefulContainer container,
                              org.jboss.serial.io.MarshalledObject beanMO)
An incoming context from serialization.

Parameters:
container -
beanMO -

StatefulBeanContext

protected StatefulBeanContext(StatefulContainer container,
                              Object bean)
A brand new stateful session bean.

Parameters:
container -
bean -

StatefulBeanContext

public StatefulBeanContext()
Deprecated. 

Only for use by externalization; do not use elsewhere.

Method Detail

getContains

public List<StatefulBeanContext> getContains()

getEJBContext

public javax.ejb.EJBContext getEJBContext()
Specified by:
getEJBContext in class SessionBeanContext<StatefulContainer>

getExtendedPersistenceContext

public javax.persistence.EntityManager getExtendedPersistenceContext(String id)

addExtendedPersistenceContext

public void addExtendedPersistenceContext(String id,
                                          javax.persistence.EntityManager pc)

scanForExtendedPersistenceContext

public boolean scanForExtendedPersistenceContext(String id,
                                                 StatefulBeanContext ignore)

removeExtendedPersistenceContext

public void removeExtendedPersistenceContext(String id)

getExtendedPersistenceContexts

public Map<String,javax.persistence.EntityManager> getExtendedPersistenceContexts()

getContainedIn

public StatefulBeanContext getContainedIn()

getUltimateContainedIn

public StatefulBeanContext getUltimateContainedIn()

addContains

public void addContains(StatefulBeanContext ctx)

removeContains

public void removeContains(StatefulBeanContext ctx)

pushContainedIn

public StatefulBeanContext pushContainedIn()

getCanPassivate

public boolean getCanPassivate()
Checks whether this context or any of its children are in use.


prePassivate

public void prePassivate()
Notification from a non-clustered StatefulCache to inform that we are about to be passivated.


postActivate

public void postActivate()
Notification from a non-clustered StatefulCache to inform that we have been activated.


passivateAfterReplication

public void passivateAfterReplication()
Notification from a ClusteredStatefulCache to inform that a bean that is stored in the distributed cache is now being passivated as well. Something of a misnomer as it is possible the bean wasn't replicated (if it implements Optimized it may have been activated and then a reference left in the cache without the bean ever being replicated).


activateAfterReplication

public void activateAfterReplication()

getReplicationIsPassivation

public boolean getReplicationIsPassivation()

setReplicationIsPassivation

public void setReplicationIsPassivation(boolean replicationIsPassivation)

preReplicate

public void preReplicate()
Notification from a ClusteredStatefulCache before a bean is replicated.


postReplicate

public void postReplicate()
Notification from a ClusteredStatefulCache after the bean is fetched from the distributed cache. Something of a misnomer as it is possible the bean wasn't replicated (if it implements Optimized it can be fetched from the cache twice without ever being replicated).


popContainedIn

public void popContainedIn()

isInUse

public boolean isInUse()

setInUse

public void setInUse(boolean inUse)

isDiscarded

public boolean isDiscarded()

setDiscarded

public void setDiscarded(boolean discarded)

getLock

public ReentrantLock getLock()

isInInvocation

public boolean isInInvocation()

setInInvocation

public void setInInvocation(boolean inInvocation)

getId

public Object getId()
Specified by:
getId in interface org.jboss.ejb3.cache.Identifiable
Overrides:
getId in class BaseContext<StatefulContainer>

isTxSynchronized

public boolean isTxSynchronized()

setTxSynchronized

public void setTxSynchronized(boolean txSynchronized)

isRemoved

public boolean isRemoved()

remove

public void remove()

getCanRemoveFromCache

public boolean getCanRemoveFromCache()

getContainer

public StatefulContainer getContainer()
Overrides:
getContainer in class BaseContext<StatefulContainer>

getInstance

public Object getInstance()
Description copied from class: BaseContext
Returns the enterprise bean, never returns null.

Specified by:
getInstance in interface org.jboss.ejb3.interceptors.container.BeanContext<Object>
Overrides:
getInstance in class BaseContext<StatefulContainer>

isModified

public boolean isModified()

getMetaData

public org.jboss.aop.metadata.SimpleMetaData getMetaData()
Specified by:
getMetaData in interface org.jboss.ejb3.tx.container.StatefulBeanContext<Object>
Overrides:
getMetaData in class BaseContext<StatefulContainer>

getInterceptorInstances

public Object[] getInterceptorInstances(InterceptorInfo[] interceptorInfos)
Overrides:
getInterceptorInstances in class BaseContext<StatefulContainer>

extractBeanAndInterceptors

protected void extractBeanAndInterceptors()

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

getInvokedMethodKey

public Object getInvokedMethodKey()
Overrides:
getInvokedMethodKey in class BaseContext<StatefulContainer>

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


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