Package javax.transaction

Examples of javax.transaction.TransactionRolledbackException


        return delegate.wrapException(obj);
    }

    public RemoteException mapSystemException(SystemException ex) {
        if (ex instanceof TRANSACTION_ROLLEDBACK) {
            TransactionRolledbackException transactionRolledbackException = new TransactionRolledbackException(ex.getMessage());
            transactionRolledbackException.detail = ex;
            return transactionRolledbackException;
        }
        if (ex instanceof TRANSACTION_REQUIRED) {
            TransactionRequiredException transactionRequiredException = new TransactionRequiredException(ex.getMessage());
View Full Code Here


        return delegate.wrapException(obj);
    }

    public RemoteException mapSystemException(SystemException ex) {
        if (ex instanceof TRANSACTION_ROLLEDBACK) {
            TransactionRolledbackException transactionRolledbackException = new TransactionRolledbackException(ex.getMessage());
            transactionRolledbackException.detail = ex;
            return transactionRolledbackException;
        }
        if (ex instanceof TRANSACTION_REQUIRED) {
            TransactionRequiredException transactionRequiredException = new TransactionRequiredException(ex.getMessage());
View Full Code Here

        String[] theFinalStates1 = init1;

        Exception[] theExceptions = { null, null, null, null, null, null, null,
                null };

        TransactionRolledbackException aTransactionRolledbackException;
        int loopCount = init1.length;
        for (int i = 0; i < loopCount; i++) {
            try {
                aTransactionRolledbackException = new TransactionRolledbackException(
                        init1[i]);
                if (theExceptions[i] != null) {
                    fail();
                }
                assertEquals(i + "  Final state mismatch",
                        aTransactionRolledbackException.getMessage(),
                        theFinalStates1[i]);

            } catch (Exception e) {
                if (theExceptions[i] == null) {
                    fail(i + "Unexpected exception");
View Full Code Here

        String[] theFinalStates1 = { null };

        Exception[] theExceptions = { null };

        TransactionRolledbackException aTransactionRolledbackException;
        int loopCount = 1;
        for (int i = 0; i < loopCount; i++) {
            try {
                aTransactionRolledbackException = new TransactionRolledbackException();
                if (theExceptions[i] != null) {
                    fail();
                }
                assertEquals(i + "  Final state mismatch",
                        aTransactionRolledbackException.getMessage(),
                        theFinalStates1[i]);

            } catch (Exception e) {
                if (theExceptions[i] == null) {
                    fail(i + "Unexpected exception");
View Full Code Here

  @Test
  public void testCorrectHandlerUsedForSubclass() throws Throwable {
    MyThrowsHandler th = new MyThrowsHandler();
    ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
    // Extends RemoteException
    TransactionRolledbackException ex = new TransactionRolledbackException();
    MethodInvocation mi = mock(MethodInvocation.class);
    given(mi.proceed()).willThrow(ex);
    try {
      ti.invoke(mi);
      fail();
View Full Code Here

      }
    };

    ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
    // Extends RemoteException
    TransactionRolledbackException ex = new TransactionRolledbackException();
    MethodInvocation mi = mock(MethodInvocation.class);
    given(mi.proceed()).willThrow(ex);
    try {
      ti.invoke(mi);
      fail();
View Full Code Here

      {
         // If we got a remote TransactionRolledbackException for a local
         // invocation convert it into a TransactionRolledbackLocalException
         if (isLocal && e instanceof TransactionRolledbackException)
         {
            TransactionRolledbackException remoteTxRollback =
                  (TransactionRolledbackException)e;

            Exception cause;
            if (remoteTxRollback.detail instanceof Exception)
            {
               cause = (Exception)remoteTxRollback.detail;
            }
            else if (remoteTxRollback.detail instanceof Error)
            {
               String msg = formatException(
                     "Unexpected Error",
                     remoteTxRollback.detail);
               cause = new EJBException(msg);
            }
            else
            {
               String msg = formatException(
                     "Unexpected Throwable",
                     remoteTxRollback.detail);
               cause = new EJBException(msg);
            }

            e = new JBossTransactionRolledbackLocalException(
                  remoteTxRollback.getMessage(),
                  cause);
         }

         // If we got a local TransactionRolledbackLocalException for a remote
         // invocation convert it into a TransactionRolledbackException
View Full Code Here

            {
               throw (TransactionRolledbackException) cause;
            }
            else
            {
               TransactionRolledbackException ex =
                       new TransactionRolledbackException(cause.getMessage());
               ex.detail = cause;
               throw ex;
            }
         }
      }
View Full Code Here

        } else if (ex instanceof TRANSACTION_REQUIRED) {
            RemoteException newEx = new TransactionRequiredException(message);
            newEx.detail = ex;
            return newEx;
        } else if (ex instanceof TRANSACTION_ROLLEDBACK) {
            RemoteException newEx = new TransactionRolledbackException(message);
            newEx.detail = ex;
            return newEx;
        } else if (ex instanceof INVALID_TRANSACTION) {
            RemoteException newEx = new InvalidTransactionException(message);
            newEx.detail = ex;
View Full Code Here

/*  89 */     this.tm = getContainer().getTransactionManager();
/*     */   }
/*     */
/*     */   protected Object invokeNext(Invocation invocation, boolean inheritedTx) throws Exception {
/* 112 */     InvocationType type = invocation.getType();
/*     */     TransactionRolledbackException ex;
/*     */     try {
/* 115 */       if ((type == InvocationType.REMOTE) || (type == InvocationType.LOCAL) || (type == InvocationType.SERVICE_ENDPOINT))
/*     */       {
/* 118 */         if (ejbTimeout.equals(invocation.getMethod())) {
/* 119 */           registerTimer(invocation);
/*     */         }
/* 121 */         return getNext().invoke(invocation);
/*     */       }
/*     */
/* 125 */       return getNext().invokeHome(invocation);
/*     */     }
/*     */     catch (Throwable e)
/*     */     {
/* 131 */       if (((e instanceof Exception)) && (!(e instanceof RuntimeException)) && (!(e instanceof RemoteException)))
/*     */       {
/* 134 */         throw ((Exception)e);
/*     */       }
/*     */
/* 138 */       Transaction tx = invocation.getTransaction();
/* 139 */       if (tx == null)
/*     */       {
/*     */         try
/*     */         {
/* 144 */           tx = this.tm.getTransaction();
/* 145 */           if (!TxUtils.isActive(tx))
/* 146 */             tx = null;
/*     */         }
/*     */         catch (Exception ex)
/*     */         {
/* 150 */           this.log.warn("Unable to determine transaction context", ex);
/*     */         }
/*     */       }
/* 153 */       if (tx != null)
/*     */       {
/*     */         try
/*     */         {
/* 157 */           tx.setRollbackOnly();
/*     */         }
/*     */         catch (SystemException ex)
/*     */         {
/* 161 */           this.log.error("SystemException while setting transaction for rollback only", ex);
/*     */         }
/*     */         catch (IllegalStateException ex)
/*     */         {
/* 166 */           this.log.error("IllegalStateException while setting transaction for rollback only", ex);
/*     */         }
/*     */
/*     */       }
/*     */
/* 172 */       boolean isLocal = (type == InvocationType.LOCAL) || (type == InvocationType.LOCALHOME);
/*     */
/* 179 */       if (!inheritedTx)
/*     */       {
/* 181 */         if ((e instanceof Exception))
/*     */         {
/* 183 */           throw ((Exception)e);
/*     */         }
/* 185 */         if ((e instanceof Error))
/*     */         {
/* 187 */           throw ((Error)e);
/*     */         }
/*     */
/* 191 */         if (isLocal)
/*     */         {
/* 193 */           String msg = formatException("Unexpected Throwable", e);
/* 194 */           throw new EJBException(msg);
/*     */         }
/*     */
/* 198 */         ServerException ex = new ServerException("Unexpected Throwable");
/* 199 */         ex.detail = e;
/* 200 */         throw ex;
/*     */       }
/*     */       Throwable cause;
/* 207 */       if ((e instanceof NoSuchEntityException))
/*     */       {
/* 209 */         NoSuchEntityException nsee = (NoSuchEntityException)e;
/*     */         Throwable cause;
/* 210 */         if (isLocal)
/*     */         {
/* 212 */           cause = new NoSuchObjectLocalException(nsee.getMessage(), nsee.getCausedByException());
/*     */         }
/*     */         else
/*     */         {
/* 217 */           Throwable cause = new NoSuchObjectException(nsee.getMessage());
/*     */
/* 220 */           ((NoSuchObjectException)cause).detail = nsee.getCausedByException();
/*     */         }
/*     */       }
/*     */       else
/*     */       {
/*     */         Throwable cause;
/* 226 */         if (isLocal)
/*     */         {
/*     */           Throwable cause;
/* 230 */           if ((e instanceof Exception))
/*     */           {
/* 232 */             cause = e;
/*     */           }
/*     */           else
/*     */           {
/*     */             Throwable cause;
/* 234 */             if ((e instanceof Error))
/*     */             {
/* 236 */               String msg = formatException("Unexpected Error", e);
/* 237 */               cause = new EJBException(msg);
/*     */             }
/*     */             else
/*     */             {
/* 241 */               String msg = formatException("Unexpected Throwable", e);
/* 242 */               cause = new EJBException(msg);
/*     */             }
/*     */           }
/*     */
/*     */         }
/*     */         else
/*     */         {
/* 249 */           cause = e;
/*     */         }
/*     */
/*     */       }
/*     */
/* 254 */       if (isLocal)
/*     */       {
/* 256 */         if ((cause instanceof TransactionRolledbackLocalException))
/*     */         {
/* 258 */           throw ((TransactionRolledbackLocalException)cause);
/*     */         }
/*     */
/* 262 */         throw new TransactionRolledbackLocalException(cause.getMessage(), (Exception)cause);
/*     */       }
/*     */
/* 268 */       if ((cause instanceof TransactionRolledbackException))
/*     */       {
/* 270 */         throw ((TransactionRolledbackException)cause);
/*     */       }
/*     */
/* 274 */       ex = new TransactionRolledbackException(cause.getMessage());
/*     */
/* 276 */       ex.detail = cause;
/* 277 */     }throw ex;
/*     */   }
View Full Code Here

TOP

Related Classes of javax.transaction.TransactionRolledbackException

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.