Package org.jboss.ejb.plugins.lock

Examples of org.jboss.ejb.plugins.lock.NonReentrantLock


      // 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


      // 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

/*     */     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

TOP

Related Classes of org.jboss.ejb.plugins.lock.NonReentrantLock

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.