Package org.jboss.ejb

Examples of org.jboss.ejb.EntityContainer


         log.warn("container is null, can't steal persistence manager");
         return;
      }
      if (container instanceof EntityContainer)
      {
         EntityContainer ec = (EntityContainer) container;

         if (ec.getPersistenceManager() == null)
         {
            log.info("no persistence manager in container!");
            return;
         }
         if (ec.getPersistenceManager() == this)
         {
            log.info(" persistence manager in container already set!");
            return;
         }
         pm = ec.getPersistenceManager();
         ec.setPersistenceManager(this);
      }

      // get the JNDI names for all resources that are referenced "Unshareable"
      org.jboss.metadata.BeanMetaData bmd = container.getBeanMetaData();
      org.jboss.metadata.ApplicationMetaData appMetaData = bmd.getApplicationMetaData();
View Full Code Here


   public Object invokeHome(Invocation mi)
      throws Exception
   {
      // Get context
      EntityContainer container = (EntityContainer) getContainer();
      EntityEnterpriseContext ctx = (EntityEnterpriseContext) container.getInstancePool().get();
      ctx.setTxAssociation(GlobalTxEntityMap.NOT_READY);
      InstancePool pool = container.getInstancePool();

      // Pass it to the method invocation
      mi.setEnterpriseContext(ctx);
  
      // Give it the transaction
      ctx.setTransaction(mi.getTransaction());
  
      // Set the current security information
      ctx.setPrincipal(mi.getPrincipal());

      AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME);
     
      // Invoke through interceptors
     
      Object obj = null;
      Exception exception = null;

      try
      {
         obj = getNext().invokeHome(mi);
         
         // Is the context now with an identity? in which case we need to insert
         if (ctx.getId() != null)
         {
            BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey());
            lock.sync(); // lock all access to BeanLock
            try
            {
               // Check there isn't a context already in the cache
               // e.g. commit-option B where the entity was
               // created then removed externally
               InstanceCache cache = container.getInstanceCache();
               cache.remove(ctx.getCacheKey());
      
               // marcf: possible race on creation and usage
               // insert instance in cache,
               cache.insert(ctx);
            }
            finally
            {
               lock.releaseSync();
               container.getLockManager().removeLockRef(ctx.getCacheKey());
            }
            
            // we are all done            
            return obj;
         }
      }
      catch (Exception e)
      {
         exception = e;
      }
      finally
      {
         AllowedOperationsAssociation.popInMethodFlag();
      }

      ctx.setTransaction(null);
      // EntityCreateInterceptor will access ctx if it is not null and call postCreate
      mi.setEnterpriseContext(null);
     
      // if we get to here with a null exception then our invocation is
      // just a home invocation. Return our instance to the instance pool  
      if (exception == null)
      {
         container.getInstancePool().free(ctx);
         return obj;
      }
     
      if (exception instanceof RuntimeException)
      {
View Full Code Here

   public JDBCSelectorBridge(JDBCStoreManager manager, JDBCQueryMetaData queryMetaData)
   {
      this.queryMetaData = queryMetaData;
      this.manager = manager;

      EntityContainer container = manager.getContainer();
      tm = container.getTransactionManager();
      syncBeforeSelect = !container.getBeanMetaData().getContainerConfiguration().getSyncOnCommitOnly();
   }
View Full Code Here

      Collection retVal;
      Method method = getMethod();
      try
      {
         JDBCQueryCommand query = manager.getQueryManager().getQueryCommand(method);
         EntityContainer selectedContainer = query.getSelectManager().getContainer();
         GenericEntityObjectFactory factory;
         if(queryMetaData.isResultTypeMappingLocal() && selectedContainer.getLocalHomeClass() != null)
         {
            factory = selectedContainer.getLocalProxyFactory();
         }
         else
         {
            factory = selectedContainer.getProxyFactory();
         }

         retVal = query.execute(method, args, null, factory);
      }
      catch(FinderException e)
View Full Code Here

         // construct a new relationshet
         try
         {
            // get the curent transaction
            EntityContainer container = getJDBCStoreManager().getContainer();
            TransactionManager tm = container.getTransactionManager();
            Transaction tx = tm.getTransaction();

            // if whe have a valid transaction...
            if(tx != null && (tx.getStatus() == Status.STATUS_ACTIVE || tx.getStatus() == Status.STATUS_PREPARING))
            {
View Full Code Here

      // Related Manager
      relatedManager = (JDBCStoreManager) relatedEntity.getManager();

      // Related Container
      EntityContainer relatedContainer = relatedManager.getContainer();
      this.relatedContainerRef = new WeakReference(relatedContainer);

      // related findByPrimaryKey
      Class homeClass = (relatedContainer.getLocalHomeClass() != null ?
         relatedContainer.getLocalHomeClass() : relatedContainer.getHomeClass());
      try
      {
         relatedFindByPrimaryKey =
            homeClass.getMethod("findByPrimaryKey", new Class[]{relatedEntity.getPrimaryKeyClass()});
      }
View Full Code Here

    * @return related local object instance.
    */
   public EJBLocalObject getRelatedEntityByFK(Object fk)
   {
      EJBLocalObject relatedLocalObject = null;
      final EntityContainer relatedContainer = getRelatedContainer();

      if(hasFKFieldsMappedToCMPFields
         && relatedManager.getReadAheadCache().getPreloadDataMap(fk, false) == null // not in preload cache
      )
      {
         EJBLocalHome relatedHome = relatedContainer.getLocalProxyFactory().getEJBLocalHome();
         try
         {
            relatedLocalObject = (EJBLocalObject) relatedFindByPrimaryKey.invoke(relatedHome, new Object[]{fk});
         }
         catch(Exception ignore)
         {
            // no such entity. it is ok to ignore
         }
      }
      else
      {
         relatedLocalObject = relatedContainer.getLocalProxyFactory().getEntityEJBLocalObject(fk);
      }

      return relatedLocalObject;
   }
View Full Code Here

   private Transaction getTransaction()
   {
      try
      {
         EntityContainer container = getJDBCStoreManager().getContainer();
         TransactionManager tm = container.getTransactionManager();
         return tm.getTransaction();
      }
      catch(SystemException e)
      {
         throw new EJBException("Error getting transaction from the transaction manager", e);
View Full Code Here

      }

      // get the parameter order
      setParameterList(compiler.getInputParameters());

      EntityContainer con = ((JDBCStoreManager)compiler.getStoreManager()).getContainer();
      factory = metadata.isResultTypeMappingLocal() && con.getLocalHomeClass() != null ?
         con.getLocalProxyFactory() : con.getProxyFactory();
     
      return execute(
         compiler.getSQL(),
         parameters,
         offset,
View Full Code Here

         log.debug("Remove: Rows affected = " + rowsAffected);
   }

   public void invokeRemoveRelated(Object relatedId) throws RemoveException, RemoteException
   {
      EntityContainer container = relatedManager.getContainer();

      /*
      try
      {
         EntityCache instanceCache = (EntityCache) container.getInstanceCache();
         SecurityActions actions = SecurityActions.UTIL.getSecurityActions();

         org.jboss.invocation.Invocation invocation = new org.jboss.invocation.Invocation();
         invocation.setId(instanceCache.createCacheKey(relatedId));
         invocation.setArguments(new Object[]{});
         invocation.setTransaction(container.getTransactionManager().getTransaction());
         invocation.setPrincipal(actions.getPrincipal());
         invocation.setCredential(actions.getCredential());
         invocation.setType(invocationType);
         invocation.setMethod(removeMethod);

         container.invoke(invocation);
      }
      catch(EJBException e)
      {
         throw e;
      }
      catch(Exception e)
      {
         throw new EJBException("Error in remove instance", e);
      }
      */

      /**
       * Have to remove through EJB[Local}Object interface since the proxy contains the 'removed' flag
       * to be set on removal.
       */
      if(container.getLocalProxyFactory() != null)
      {
         final EJBLocalObject ejbObject = container.getLocalProxyFactory().getEntityEJBLocalObject(relatedId);
         ejbObject.remove();
      }
      else
      {
         final EJBObject ejbObject = (EJBObject)container.getProxyFactory().getEntityEJBObject(relatedId);
         ejbObject.remove();
      }
   }
View Full Code Here

TOP

Related Classes of org.jboss.ejb.EntityContainer

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.