Package org.jboss.ejb3.stateful

Examples of org.jboss.ejb3.stateful.StatefulBeanContext$CustomSessionSynchronization


   {
      // Find the ultimate parent context for the tree of SFSBs the target
      // bean is part of.  This "tree" could just be the bean itself, or
      // a multi-layer tree of nested SFSBs.
      StatefulContainerInvocation ejbInv = (StatefulContainerInvocation) invocation;
      StatefulBeanContext ctx = (StatefulBeanContext) ejbInv.getBeanContext();
      StatefulBeanContext root = ctx.getUltimateContainedIn();
     
      // Find out if the ultimate parent is clustered
      boolean clustered = false;
      StatefulContainer container = (StatefulContainer) root.getContainer();
      ClusteredStatefulCache clusteredCache = null;
      if (container.getCache() instanceof ClusteredStatefulCache)
      {
         clustered = true;
         clusteredCache = (ClusteredStatefulCache) container.getCache();
View Full Code Here


      return create(null, null);
   }
  
   public StatefulBeanContext create(Class<?>[] initTypes, Object[] initValues)
   {
      StatefulBeanContext ctx = null;
      try
      {
         ctx = container.create(initTypes, initValues);
         ++createCount;
         synchronized (cacheMap)
         {
            cacheMap.put(ctx.getId(), ctx);
         }
      }
      catch (EJBException e)
      {
         throw e;
View Full Code Here

      return get(key, true);
   }
  
   public StatefulBeanContext get(Object key, boolean markInUse) throws EJBException
   {
      StatefulBeanContext entry = null;
      synchronized (cacheMap)
      {
         entry = (StatefulBeanContext) cacheMap.get(key);
      }
     
      if (entry == null)
      {
         throw new NoSuchEJBException("Could not find Stateful bean: " + key);
      }     
     
      if (markInUse)
      {  
         if (entry.isRemoved())
         {
            throw new NoSuchEJBException("Could not find stateful bean: " + key +
                                         " (bean was marked as removed");
         }     
     
         entry.setInUse(true);
         entry.lastUsed = System.currentTimeMillis();
      }
     
      return entry;
   }
View Full Code Here

      }
   }

   public void remove(Object key)
   {
      StatefulBeanContext ctx = null;
      synchronized (cacheMap)
      {
         ctx = (StatefulBeanContext) cacheMap.remove(key);
      }
      if(ctx == null)
View Full Code Here

      inject(ctx, ctx.getInstance());
   }

   public void inject(BeanContext beanContext, Object instance)
   {
      StatefulBeanContext ctx = (StatefulBeanContext)beanContext;
      EntityManager pc = ctx.getExtendedPersistenceContext(factory.getKernelName());
      if (pc == null)
      {
         pc = factory.createEntityManager();
         ctx.addExtendedPersistenceContext(factory.getKernelName(), pc);
      }
   }
View Full Code Here

      if (debug)
      {
         log.debug("Reading session state from: " + file);
      }

      StatefulBeanContext bean = null;
      try
      {
         FileInputStream fis = FISAction.open(file);
         // todo need to rewrite SessionObjectInputStream to support EJB3 classes
         ObjectInputStream in;

         in = new JBossObjectInputStream(new BufferedInputStream(fis));
         try
         {
            bean = (StatefulBeanContext) in.readObject();
         }
         finally
         {
            fis.close();
            in.close();
         }
      }
      catch (EJBException e)
      {
         throw e;
      }
      catch (Exception e)
      {
         throw new EJBException("Could not activate; failed to " +
                                "restore state", e);
      }

      removePassivated(id);

      bean.postActivate();
      return bean;
   }
View Full Code Here

            FileInputStream fis = FISAction.open(file);
  
            in = new JBossObjectInputStream(new BufferedInputStream(fis));
            try
            {
               StatefulBeanContext bean = (StatefulBeanContext) in.readObject();
               beans.add(bean);
            }
            finally
            {
               fis.close();
View Full Code Here

      return create(null, null);
   }

   public StatefulBeanContext create(Class<?>[] initTypes, Object[] initValues)
   {
      StatefulBeanContext ctx = null;
      try
      {
         ctx = container.create(initTypes, initValues);
         if (log.isTraceEnabled())
         {
            log.trace("Caching context " + ctx.getId() + " of type " + ctx.getClass());
         }
         synchronized (cacheMap)
         {
            cacheMap.put(ctx.getId(), ctx);
            ctx.setInUse(true);
            ctx.lastUsed = System.currentTimeMillis();
         }
         ++createCount;
      }
      catch (EJBException e)
View Full Code Here

      return get(key, true);
   }
  
   public StatefulBeanContext get(Object key, boolean markInUse) throws EJBException
   {
      StatefulBeanContext entry = null;
      synchronized (cacheMap)
      {
         entry = cacheMap.get(key);
      }
      if(entry == null)
      {
         // TODO: optimize
         synchronized (cacheMap)
         {
            entry = cacheMap.get(key);
            if(entry == null)
            {
               Iterator<StatefulBeanContext> i = passivationQueue.iterator();
               while(i.hasNext())
               {
                  StatefulBeanContext ctx = i.next();
                  if(ctx.getId().equals(key))
                  {
                     boolean passivationCanceled = passivationQueue.remove(ctx);
                     if(passivationCanceled)
                     {
                        entry = ctx;
View Full Code Here

      }
      // don't directly use the cacheMap to get the
      // object from the key. Instead, use the get() method
      // which will even activate any sessions which have been
      // passivated (see https://jira.jboss.org/jira/browse/EJBTHREE-2030)
      StatefulBeanContext ctx = this.get(key);
      if(ctx == null)
         throw new NoSuchEJBException("Could not find Stateful bean: " + key);
      if (!ctx.isRemoved())
         container.destroy(ctx);
     
      ++removeCount;
     
      if (ctx.getCanRemoveFromCache())
      {
         synchronized (cacheMap)
         {
            cacheMap.remove(key);
         }
View Full Code Here

TOP

Related Classes of org.jboss.ejb3.stateful.StatefulBeanContext$CustomSessionSynchronization

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.