Package org.jboss.ejb

Examples of org.jboss.ejb.EntityEnterpriseContext


/* 167 */         if (canPassivate(instance))
/*     */         {
/*     */           try
/*     */           {
/* 171 */             remove(id);
/* 172 */             EntityEnterpriseContext entity = (EntityEnterpriseContext)instance;
/* 173 */             this.container.getPersistenceManager().passivateEntity(entity);
/* 174 */             this.container.getInstancePool().free(instance);
/*     */           }
/*     */           catch (Exception ignored)
/*     */           {
View Full Code Here


/*     */     }
/*     */   }
/*     */
/*     */   public Object invokeHome(Invocation mi) throws Exception
/*     */   {
/* 200 */     EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext();
/* 201 */     Transaction tx = mi.getTransaction();
/*     */
/* 203 */     Object rtn = getNext().invokeHome(mi);
/*     */
/* 206 */     if (ctx.getId() != null)
/*     */     {
/* 210 */       ctx.setValid(true);
/*     */
/* 212 */       if (tx != null)
/*     */       {
/* 214 */         BeanLock lock = this.container.getLockManager().getLock(ctx.getCacheKey());
/*     */         try
/*     */         {
/* 217 */           lock.schedule(mi);
/* 218 */           register(ctx, tx);
/* 219 */           lock.endInvocation(mi);
View Full Code Here

/* 152 */     return this.m_container.getLockManager().canPassivate(key);
/*     */   }
/*     */
/*     */   protected void unableToPassivateDueToCtxLock(EnterpriseContext ctx, boolean passivateAfterCommit)
/*     */   {
/* 161 */     EntityEnterpriseContext ectx = (EntityEnterpriseContext)ctx;
/* 162 */     ectx.setPassivateAfterCommit(passivateAfterCommit);
/* 163 */     ConfigurationMetaData config = this.m_container.getBeanMetaData().getContainerConfiguration();
/* 164 */     if ((!config.isStoreNotFlushed()) && (ectx.hasTxSynchronization()))
/*     */     {
/* 166 */       ectx.setTxAssociation(GlobalTxEntityMap.PREVENT_SYNC);
/*     */     }
/*     */   }
View Full Code Here

/*     */
/*     */   public Object invokeHome(Invocation mi)
/*     */     throws Exception
/*     */   {
/* 113 */     EntityContainer container = (EntityContainer)getContainer();
/* 114 */     EntityEnterpriseContext ctx = (EntityEnterpriseContext)container.getInstancePool().get();
/* 115 */     ctx.setTxAssociation(GlobalTxEntityMap.NOT_READY);
/* 116 */     InstancePool pool = container.getInstancePool();
/*     */
/* 119 */     mi.setEnterpriseContext(ctx);
/*     */
/* 122 */     ctx.setTransaction(mi.getTransaction());
/*     */
/* 124 */     ctx.setSecurityContext(mi.getSecurityContext());
/*     */
/* 126 */     ctx.setPrincipal(mi.getPrincipal());
/*     */
/* 128 */     AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_HOME);
/*     */
/* 132 */     Object obj = null;
/* 133 */     Exception exception = null;
/*     */     try
/*     */     {
/* 137 */       obj = getNext().invokeHome(mi);
/*     */
/* 140 */       if (ctx.getId() != null)
/*     */       {
/* 142 */         BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey());
/* 143 */         lock.sync();
/*     */         try
/*     */         {
/* 149 */           cache = container.getInstanceCache();
/* 150 */           cache.remove(ctx.getCacheKey());
/*     */
/* 154 */           cache.insert(ctx);
/*     */         }
/*     */         finally
/*     */         {
/* 158 */           lock.releaseSync();
/* 159 */           container.getLockManager().removeLockRef(ctx.getCacheKey());
/*     */         }
/*     */
/* 163 */         InstanceCache cache = obj;
/*     */         return cache;
/*     */       }
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 168 */       exception = e;
/*     */     }
/*     */     finally
/*     */     {
/* 172 */       AllowedOperationsAssociation.popInMethodFlag();
/*     */     }
/*     */
/* 175 */     ctx.setTransaction(null);
/*     */
/* 177 */     mi.setEnterpriseContext(null);
/*     */
/* 181 */     if (exception == null)
/*     */     {
View Full Code Here

/*     */     throws Exception
/*     */   {
/* 208 */     boolean trace = this.log.isTraceEnabled();
/*     */
/* 211 */     Object key = mi.getId();
/*     */     EntityEnterpriseContext ctx;
/*     */     try
/*     */     {
/* 217 */       ctx = (EntityEnterpriseContext)this.container.getInstanceCache().get(key);
/*     */     }
/*     */     catch (NoSuchObjectException e)
/*     */     {
/* 221 */       if (mi.isLocal()) {
/* 222 */         throw new NoSuchObjectLocalException(e.getMessage());
/*     */       }
/* 224 */       throw e;
/*     */     }
/*     */     catch (EJBException e)
/*     */     {
/* 228 */       throw e;
/*     */     }
/*     */     catch (RemoteException e)
/*     */     {
/* 232 */       throw e;
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 236 */       InvocationType type = mi.getType();
/* 237 */       boolean isLocal = (type == InvocationType.LOCAL) || (type == InvocationType.LOCALHOME);
/* 238 */       if (isLocal) {
/* 239 */         throw new EJBException("Unable to get an instance from the pool/cache", e);
/*     */       }
/* 241 */       throw new RemoteException("Unable to get an intance from the pool/cache", e);
/*     */     }
/*     */
/* 244 */     if (trace) this.log.trace("Begin invoke, key=" + key);
/*     */
/* 251 */     Transaction tx = mi.getTransaction();
/* 252 */     if (!this.container.isReadOnly())
/*     */     {
/* 254 */       Method method = mi.getMethod();
/* 255 */       if ((method == null) || (!this.container.getBeanMetaData().isMethodReadOnly(method.getName())))
/*     */       {
/* 258 */         ctx.setTransaction(tx);
/*     */       }
/*     */     }
/*     */
/* 262 */     ctx.setSecurityContext(mi.getSecurityContext());
/*     */
/* 264 */     ctx.setPrincipal(mi.getPrincipal());
/*     */
/* 266 */     EnterpriseBeanPolicyContextHandler.setEnterpriseBean(ctx.getInstance());
/*     */
/* 269 */     mi.setEnterpriseContext(ctx);
/*     */
/* 271 */     if (ejbTimeout.equals(mi.getMethod()))
/* 272 */       AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_TIMEOUT);
/*     */     else {
/* 274 */       AllowedOperationsAssociation.pushInMethodFlag(IN_BUSINESS_METHOD);
/*     */     }
/* 276 */     Throwable exceptionThrown = null;
/* 277 */     boolean discardContext = false;
/*     */     try
/*     */     {
/* 280 */       Object obj = getNext().invoke(mi);
/* 281 */       localObject1 = obj;
/*     */     }
/*     */     catch (RemoteException e)
/*     */     {
/*     */       Object localObject1;
/* 285 */       exceptionThrown = e;
/* 286 */       discardContext = true;
/* 287 */       throw e;
/*     */     }
/*     */     catch (RuntimeException e)
/*     */     {
/* 291 */       exceptionThrown = e;
/* 292 */       discardContext = true;
/* 293 */       throw e;
/*     */     }
/*     */     catch (Error e)
/*     */     {
/* 297 */       exceptionThrown = e;
/* 298 */       discardContext = true;
/* 299 */       throw e;
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 303 */       exceptionThrown = e;
/* 304 */       throw e;
/*     */     }
/*     */     catch (Throwable e)
/*     */     {
/* 308 */       exceptionThrown = e;
/* 309 */       discardContext = true;
/* 310 */       throw new NestedRuntimeException(e);
/*     */     }
/*     */     finally
/*     */     {
/* 314 */       AllowedOperationsAssociation.popInMethodFlag();
/*     */
/* 319 */       if ((exceptionThrown != null) && (tx != null))
/*     */       {
/* 321 */         Transaction ctxTx = ctx.getTransaction();
/* 322 */         if ((tx.equals(ctxTx)) && (!ctx.hasTxSynchronization())) {
/* 323 */           ctx.setTransaction(null);
/*     */         }
/*     */       }
/*     */
/* 327 */       if ((exceptionThrown != null) && (!ctx.hasTxSynchronization()) && (discardContext))
/*     */       {
/* 336 */         this.container.getInstanceCache().remove(key);
/*     */
/* 338 */         if (trace) this.log.trace("Ending invoke, exceptionThrown, ctx=" + ctx, exceptionThrown);
/*     */       }
/* 340 */       else if (ctx.getId() == null)
/*     */       {
/* 343 */         this.container.getInstanceCache().remove(key);
/*     */
/* 345 */         if (trace) this.log.trace("Ending invoke, cache removal, ctx=" + ctx);
/*     */
View Full Code Here

/*     */   }
/*     */
/*     */   public Object invoke(Invocation mi)
/*     */     throws Exception
/*     */   {
/*  83 */     EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext();
/*  84 */     boolean nonReentrant = (!this.reentrant) && (!isReentrantMethod(mi));
/*     */
/*  87 */     NonReentrantLock methodLock = ctx.getMethodLock();
/*  88 */     Transaction miTx = ctx.getTransaction();
/*  89 */     boolean locked = false;
/*     */     try
/*     */     {
/*  92 */       while (!locked)
/*     */       {
/*  94 */         if (methodLock.attempt(5000L, miTx, nonReentrant))
/*     */         {
/*  96 */           locked = true; continue;
/*     */         }
/*     */
/* 100 */         if (!isTxExpired(miTx))
/*     */           continue;
/* 102 */         this.log.error("Saw rolled back tx=" + miTx);
/* 103 */         throw new RuntimeException("Transaction marked for rollback, possibly a timeout");
/*     */       }
/*     */
/*     */     }
/*     */     catch (NonReentrantLock.ReentranceException re)
/*     */     {
/* 110 */       if (mi.getType() == InvocationType.REMOTE)
/*     */       {
/* 112 */         throw new RemoteException("Reentrant method call detected: " + this.container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString());
/*     */       }
/*     */
/* 118 */       throw new EJBException("Reentrant method call detected: " + this.container.getBeanMetaData().getEjbName() + " " + ctx.getId().toString());
/*     */     }
/*     */
/*     */     try
/*     */     {
/* 125 */       ctx.lock();
/* 126 */       re = getNext().invoke(mi);
/*     */     }
/*     */     finally
/*     */     {
/* 130 */       ctx.unlock();
/* 131 */       methodLock.release(nonReentrant);
/*     */     }
/*     */   }
View Full Code Here

/*    */   }
/*    */
/*    */   protected EnterpriseContext create(Object instance)
/*    */     throws Exception
/*    */   {
/* 67 */     return new EntityEnterpriseContext(instance, getContainer());
/*    */   }
View Full Code Here

/*    */   public Object invokeHome(Invocation mi)
/*    */     throws Exception
/*    */   {
/* 45 */     Object retVal = getNext().invokeHome(mi);
/*    */
/* 49 */     EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext();
/*    */
/* 51 */     if ((ctx != null) && (ctx.getId() != null))
/*    */     {
/* 55 */       mi.setId(ctx.getId());
/*    */
/* 60 */       getNext().invoke(mi);
/*    */
/* 63 */       if (TxUtils.isActive(mi.getTransaction()))
/*    */       {
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.