FileDocCategorySizeDatePackage
ProxiedStatefulBeanContext.javaAPI DocJBoss 4.2.110463Fri Jul 13 20:53:50 BST 2007org.jboss.ejb3.stateful

ProxiedStatefulBeanContext

public class ProxiedStatefulBeanContext extends StatefulBeanContext implements Externalizable
Proxy to a NestedStatefulBeanContext that can be independently passivated, activated and replicated without disturbing the object it is proxying.
author
Bill Burke
author
Brian Stansberry
version
$Revision: 60652 $

Fields Summary
private static final long
serialVersionUID
The serialVersionUID
private transient StatefulBeanContext
delegate
private Object
oid
private String
containerId
private StatefulBeanContextReference
parentRef
Constructors Summary
public ProxiedStatefulBeanContext(StatefulBeanContext delegate)


     
   
      this.delegate = delegate;
      oid = delegate.getId();
      containerId = delegate.getContainer().getObjectName().getCanonicalName();
      parentRef = new StatefulBeanContextReference(delegate.getContainedIn());
   
public ProxiedStatefulBeanContext()

   
Methods Summary
public voidactivateAfterReplication()
Ignores the call, as activation of this proxy context does not affect the underlying bean (which is activated along with its parent context).

      // ignore
   
public voidaddContains(StatefulBeanContext ctx)

      getDelegate().addContains(ctx);
   
public voidaddExtendedPersistenceContext(java.lang.String id, javax.persistence.EntityManager pc)

      getDelegate().addExtendedPersistenceContext(id, pc);
   
public voidextractBeanAndInterceptors()

      getDelegate().extractBeanAndInterceptors();
   
public booleangetCanPassivate()

      if (delegate == null)
      {
         // If we haven't deserialized our delegate, we're not in use
         // on this node
         return true;
      }
      // Just check if *we* are in use; whether any children are
      // in use doesn't matter, since passivating this proxy
      // doesn't affect children
      return (isInUse() == false);
   
public booleangetCanRemoveFromCache()

      return getDelegate().getCanRemoveFromCache();
   
public StatefulBeanContextgetContainedIn()

      return getDelegate().getContainedIn();
   
public org.jboss.ejb3.ContainergetContainer()

      return getDelegate().getContainer();
   
public java.util.ListgetContains()

      return getDelegate().getContains();
   
protected StatefulBeanContextgetDelegate()

      if (delegate == null)
      {
         for (StatefulBeanContext ctx : parentRef.getBeanContext()
               .getContains())
         {
            Object matchingOid = ctx.getId();
            if (oid.equals(matchingOid)
                  && ctx.getContainer().getObjectName().getCanonicalName()
                        .equals(containerId))
            {
               delegate = ctx;
               break;
            }
         }
         if (delegate == null)
            throw new RuntimeException("Failed to read delegate");
         
         // If we just read our delegate, it's possible there's been a 
         // failover and a remote node still has a ref to a stale delegate.
         // So, we should be replicated to invalidate the remote node.
         this.markedForReplication = true;
      }
      return delegate;
   
public javax.ejb.EJBContextgetEJBContext()

      return getDelegate().getEJBContext();
   
public javax.persistence.EntityManagergetExtendedPersistenceContext(java.lang.String id)

      return getDelegate().getExtendedPersistenceContext(id);
   
public java.util.MapgetExtendedPersistenceContexts()

      return getDelegate().getExtendedPersistenceContexts();
   
public java.lang.ObjectgetId()

      return getDelegate().getId();
   
public java.lang.ObjectgetInstance()

      return getDelegate().getInstance();
   
public java.lang.Object[]getInterceptorInstances(org.jboss.ejb3.interceptor.InterceptorInfo[] interceptorInfos)

      return getDelegate().getInterceptorInstances(interceptorInfos);
   
public java.util.concurrent.locks.ReentrantLockgetLock()

      return getDelegate().getLock();
   
public org.jboss.aop.metadata.SimpleMetaDatagetMetaData()

      return getDelegate().getMetaData();
   
public booleangetReplicationIsPassivation()

      return getDelegate().getReplicationIsPassivation();
   
public StatefulBeanContextgetUltimateContainedIn()

      return getDelegate().getUltimateContainedIn();
   
public voidinitialiseInterceptorInstances()

      getDelegate().initialiseInterceptorInstances();
   
public booleanisDiscarded()

      return getDelegate().isDiscarded();
   
public booleanisInInvocation()

      return getDelegate().isInInvocation();
   
public booleanisInUse()

      // Don't call delegate
      return super.isInUse();
   
public booleanisRemoved()

      return getDelegate().isRemoved();
   
public booleanisTxSynchronized()

      return getDelegate().isTxSynchronized();
   
public voidpassivateAfterReplication()
Ignores the call, as passivation of this proxy context does not affect the underlying bean (which is passivated along with its parent context).

      // ignore
   
public voidpopContainedIn()

      getDelegate().popContainedIn();
   
public voidpostActivate()
Ignores the call, as activation of this proxy context does not affect the underlying bean (which is activated along with its parent context).

   
public voidpostReplicate()
Ignores the call, as replication of this proxy context does not affect the underlying bean (which is replicated along with its parent context).

      // ignore
   
public voidprePassivate()
Ignores the call, as passivation of this proxy context does not affect the underlying bean (which is passivated along with its parent context).

   
public voidpreReplicate()
Ignores the call, as replication of this proxy context does not affect the underlying bean (which is replicated along with its parent context).

      // ignore
   
public StatefulBeanContextpushContainedIn()

      return getDelegate().pushContainedIn();
   
public voidreadExternal(java.io.ObjectInput in)

      oid = in.readObject();
      containerId = in.readUTF();
      parentRef = (StatefulBeanContextReference) in.readObject();
   
public voidremove()

      getDelegate().remove();
   
public voidremoveContains(StatefulBeanContext ctx)

      getDelegate().removeContains(ctx);
   
public voidremoveExtendedPersistenceContext(java.lang.String id)

      getDelegate().removeExtendedPersistenceContext(id);
   
public booleanscanForExtendedPersistenceContext(java.lang.String id, StatefulBeanContext ignore)

      return getDelegate().scanForExtendedPersistenceContext(id, ignore);
   
public voidsetContainer(org.jboss.ejb3.Container container)

      getDelegate().setContainer(container);
   
public voidsetDiscarded(boolean discarded)

      getDelegate().setDiscarded(discarded);
   
public voidsetId(java.lang.Object id)

      this.oid = id;
      getDelegate().setId(id);
   
public voidsetInInvocation(boolean inInvocation)

      getDelegate().setInInvocation(inInvocation);
   
public voidsetInUse(boolean inUse)

      super.setInUse(inUse);
      // delegate needs to know this for getCanPassivate()
      getDelegate().setInUse(inUse);
      
      if (!inUse)
      {
         // drop ref to delegate, as the delegate can be passivated/activated
         // without our knowledge, and if that happens we have a ref to a
         // stale delegate.
         delegate = null;
      }
   
public voidsetInstance(java.lang.Object instance)

      getDelegate().setInstance(instance);
   
public voidsetReplicationIsPassivation(boolean replicationIsPassivation)

      getDelegate().setReplicationIsPassivation(replicationIsPassivation);
   
public voidsetTxSynchronized(boolean txSynchronized)

      getDelegate().setTxSynchronized(txSynchronized);
   
public voidwriteExternal(java.io.ObjectOutput out)

      out.writeObject(oid);
      out.writeUTF(containerId);
      out.writeObject(parentRef);