Package org.jboss.ejb

Examples of org.jboss.ejb.EntityEnterpriseContext


   public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException
   {
      if(id == null) throw new IllegalArgumentException("Can't get an object with a null key");

      Map cache = getLocalCache();
      EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id);
      if(instance == null)
      {
         try
         {
            // acquire
            instance = (EntityEnterpriseContext) container.getInstancePool().get();
            // set key
            instance.setId(id);
            instance.setCacheKey(id);
            // activate
            container.getPersistenceManager().activateEntity(instance);
            // insert
            cache.put(id, instance);
         }
View Full Code Here


   public void insert(EnterpriseContext instance)
   {
      if(instance == null) throw new IllegalArgumentException("Can't insert a null object in the cache");

      EntityEnterpriseContext entity = (EntityEnterpriseContext) instance;
      getLocalCache().put(entity.getCacheKey(), instance);
   }
View Full Code Here

            if(canPassivate(instance))
            {
               try
               {
                  remove(id);
                  EntityEnterpriseContext entity = (EntityEnterpriseContext) instance;
                  container.getPersistenceManager().passivateEntity(entity);
                  container.getInstancePool().free(instance);
               }
               catch(Exception ignored)
               {
View Full Code Here

   // Protected -----------------------------------------------------

   protected void unableToPassivateDueToCtxLock(EnterpriseContext ctx, boolean passivateAfterCommit)
   {
      EntityEnterpriseContext ectx = (EntityEnterpriseContext)ctx;
      ectx.setPassivateAfterCommit(passivateAfterCommit);
      ConfigurationMetaData config = m_container.getBeanMetaData().getContainerConfiguration();
      if(!config.isStoreNotFlushed() && ectx.hasTxSynchronization())
      {
         ectx.setTxAssociation(GlobalTxEntityMap.PREVENT_SYNC);
      }
   }
View Full Code Here

   public Object invoke(Invocation mi)
           throws Exception
   {
      // We are going to work with the context a lot
      EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext();
      boolean nonReentrant = !(reentrant || isReentrantMethod(mi));

      // Not a reentrant method like getPrimaryKey
      NonReentrantLock methodLock = ctx.getMethodLock();
      Transaction miTx = ctx.getTransaction();
      boolean locked = false;
      try
      {
         while (!locked)
         {
            if (methodLock.attempt(5000, miTx, nonReentrant))
            {
               locked = true;
            }
            else
            {
               if (isTxExpired(miTx))
               {
                  log.error("Saw rolled back tx=" + miTx);
                  throw new RuntimeException("Transaction marked for rollback, possibly a timeout");
               }
            }
         }
      }
      catch (NonReentrantLock.ReentranceException re)
      {
         if (mi.getType() == InvocationType.REMOTE)
         {
            throw new RemoteException("Reentrant method call detected: "
                    + container.getBeanMetaData().getEjbName() + " "
                    + ctx.getId().toString());
         }
         else
         {
            throw new EJBException("Reentrant method call detected: "
                    + container.getBeanMetaData().getEjbName() + " "
                    + ctx.getId().toString());
         }
      }
      try
      {
         ctx.lock();
         return getNext().invoke(mi);
      }
      finally
      {
         ctx.unlock();
         methodLock.release(nonReentrant);
      }
   }
View Full Code Here

      // Do we own the lock?
      Transaction tx = mi.getTransaction();
      if (tx != null && tx.equals(getTransaction()))
      {
         // If there is no context or synchronization, release the lock
         EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext();
         if (ctx == null || ctx.hasTxSynchronization() == false)
            endTransaction(tx);
      }
   }
View Full Code Here

      // Invoke through interceptors
      Object retVal = getNext().invokeHome(mi);

      // Is the context now with an identity?
      // This means that a create method was called, so invoke ejbPostCreate.
      EntityEnterpriseContext ctx =
            (EntityEnterpriseContext) mi.getEnterpriseContext();
      if(ctx != null && ctx.getId() != null)
      {
         // copy from the context into the mi
         // interceptors down the chain look in the mi for the id not the ctx.
         mi.setId(ctx.getId());
        
         // invoke down the invoke chain
         // the final interceptor in EntityContainer will redirect this
         // call to postCreateEntity, which calls ejbPostCreate
         getNext().invoke(mi);
View Full Code Here

   public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException
   {
      if(id == null) throw new IllegalArgumentException("Can't get an object with a null key");

      Map cache = getLocalCache();
      EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id);
      if(instance == null)
      {
         try
         {
            // acquire
            instance = (EntityEnterpriseContext) container.getInstancePool().get();
            // set key
            instance.setId(id);
            instance.setCacheKey(id);
            // activate
            container.getPersistenceManager().activateEntity(instance);
            // insert
            cache.put(id, instance);
         }
View Full Code Here

   public void insert(EnterpriseContext instance)
   {
      if(instance == null) throw new IllegalArgumentException("Can't insert a null object in the cache");

      EntityEnterpriseContext entity = (EntityEnterpriseContext) instance;
      getLocalCache().put(entity.getCacheKey(), instance);
   }
View Full Code Here

            if(canPassivate(instance))
            {
               try
               {
                  remove(id);
                  EntityEnterpriseContext entity = (EntityEnterpriseContext) instance;
                  container.getPersistenceManager().passivateEntity(entity);
                  container.getInstancePool().free(instance);
               }
               catch(Exception ignored)
               {
View Full Code Here

TOP

Related Classes of org.jboss.ejb.EntityEnterpriseContext

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.