FileDocCategorySizeDatePackage
StatefulHASessionInstanceCache.javaAPI DocJBoss 4.2.14593Fri Jul 13 20:52:34 BST 2007org.jboss.ejb.plugins

StatefulHASessionInstanceCache

public class StatefulHASessionInstanceCache extends StatefulSessionInstanceCache
SFSB cache for clustered environment. Mainly avoid "excessive" locking that can generate cluster-distributed deadlocks.
see
org.jboss.ejb.plugins.StatefulSessionInstanceCache
author
Sacha Labourey.
version
$Revision: 57188 $

Revisions:

19 decembre 2002 Sacha Labourey:

  • First implementation

Fields Summary
Constructors Summary
Methods Summary
public org.jboss.ejb.EnterpriseContextget(java.lang.Object id)

      if (id == null) throw new IllegalArgumentException("Can't get an object with a null key");

      EnterpriseContext ctx = null;

      synchronized (getCacheLock())
      {
         ctx = (EnterpriseContext)getCache().get(id);
         if (ctx != null)
         {
            return ctx;
         }
      }

      // If the ctx is still null at this point, it means that we must activate it
      // => we don't lock the cache during this operation
      // StatefulSessionInstanceInterceptor prevents multiple accesses for the same id
      //
      try
      {
         ctx = acquireContext();
         setKey(id, ctx);
         activate(ctx);
         logActivation(id);
         insert(ctx);
      }
      catch (Exception x)
      {
         if (ctx != null)
            freeContext(ctx);
         log.debug("Activation failure, id="+id, x);
         throw new NoSuchObjectException(x.getMessage());
      }
      
      // FIXME marcf: How can this ever be reached? the ctx is always assigned
      if (ctx == null) throw new NoSuchObjectException("Can't find bean with id = " + id);

      return ctx;
   
public voidinvalidateLocally(java.lang.Object id)
Remove an object from the local cache *without* any locking (synchronized, etc.) to avoid huge cluster-wide deadlock situations We have to unschedule passivation as well as the bean may be used on another node.

      if (id == null) return;
      
      try
      {
         getCache().remove(id);
      }
      catch (Exception e)
      {
         log.debug (e);
      }