Package javax.transaction

Examples of javax.transaction.RollbackException


            if (status == Status.STATUS_MARKED_ROLLBACK) {
                rollbackResources(resourceManagers);
                              if(timedout)
                              {
                                  throw new RollbackException("Transaction timout");
                              }
                              else
                              {
                                  throw new RollbackException("Unable to commit");
                              }
            }
            synchronized (this) {
                if (status == Status.STATUS_ACTIVE) {
                    if (this.resourceManagers.size() == 0) {
                        // nothing to commit
                        status = Status.STATUS_COMMITTED;
                    } else if (this.resourceManagers.size() == 1) {
                        // one-phase commit decision
                        status = Status.STATUS_COMMITTING;
                    } else {
                        // start prepare part of two-phase
                        status = Status.STATUS_PREPARING;
                    }
                }
                // resourceManagers is now immutable
            }


            // no-phase
            if (resourceManagers.size() == 0) {
                synchronized (this) {
                    status = Status.STATUS_COMMITTED;
                }
                return;
            }

            // one-phase
            if (resourceManagers.size() == 1) {
                TransactionBranch manager = (TransactionBranch) resourceManagers.getFirst();
                try {
                    manager.getCommitter().commit(manager.getBranchId(), true);
                    synchronized (this) {
                        status = Status.STATUS_COMMITTED;
                    }
                    return;
                } catch (XAException e) {
                    synchronized (this) {
                        status = Status.STATUS_ROLLEDBACK;
                    }
                    throw (RollbackException) new RollbackException("Error during one-phase commit").initCause(e);
                }
            }

            // two-phase
            boolean willCommit = internalPrepare();

            // notify the RMs
            if (willCommit) {
                commitResources(resourceManagers);
            } else {
                rollbackResources(resourceManagers);
                throw new RollbackException("Unable to commit");
            }
        } finally {
            afterCompletion();
            synchronized (this) {
                status = Status.STATUS_NO_TRANSACTION;
View Full Code Here


                if (!rms.isEmpty()) {
                    result = XAResource.XA_OK;
                }
            } else {
                rollbackResources(rms);
                throw new RollbackException("Unable to commit");
            }
        } finally {
            if (result == XAResource.XA_RDONLY) {
                afterCompletion();
                synchronized (this) {
View Full Code Here

        switch (status) {
            case Status.STATUS_ACTIVE:
            case Status.STATUS_PREPARING:
                break;
            case Status.STATUS_MARKED_ROLLBACK:
                throw new RollbackException("Transaction is marked for rollback");
            default:
                throw new IllegalStateException("Status is " + getStateString(status));
        }
        syncList.add(synch);
    }
View Full Code Here

        }
        switch (status) {
            case Status.STATUS_ACTIVE:
                break;
            case Status.STATUS_MARKED_ROLLBACK:
                throw new RollbackException("Transaction is marked for rollback");
            default:
                throw new IllegalStateException("Status is " + getStateString(status));
        }

        if (activeXaResources.containsKey(xaRes)) {
View Full Code Here

            }

            if (status == Status.STATUS_MARKED_ROLLBACK) {
                rollbackResources(resourceManagers);
                if (timedout) {
                    throw new RollbackException("Transaction timout");
                } else {
                    throw new RollbackException("Unable to commit: transaction marked for rollback");
                }
            }
            synchronized (this) {
                if (status == Status.STATUS_ACTIVE) {
                    if (this.resourceManagers.size() == 0) {
                        // nothing to commit
                        status = Status.STATUS_COMMITTED;
                    } else if (this.resourceManagers.size() == 1) {
                        // one-phase commit decision
                        status = Status.STATUS_COMMITTING;
                    } else {
                        // start prepare part of two-phase
                        status = Status.STATUS_PREPARING;
                    }
                }
                // resourceManagers is now immutable
            }

            // no-phase
            if (resourceManagers.size() == 0) {
                synchronized (this) {
                    status = Status.STATUS_COMMITTED;
                }
                return;
            }

            // one-phase
            if (resourceManagers.size() == 1) {
                TransactionBranch manager = (TransactionBranch) resourceManagers.getFirst();
                try {
                    manager.getCommitter().commit(manager.getBranchId(), true);
                    synchronized (this) {
                        status = Status.STATUS_COMMITTED;
                    }
                    return;
                } catch (XAException e) {
                    synchronized (this) {
                        status = Status.STATUS_ROLLEDBACK;
                    }
                    throw (RollbackException) new RollbackException("Error during one-phase commit").initCause(e);
                }
            }

            // two-phase
            boolean willCommit = internalPrepare();

            // notify the RMs
            if (willCommit) {
                commitResources(resourceManagers);
            } else {
                rollbackResources(resourceManagers);
                throw new RollbackException("Unable to commit");
            }
        } finally {
            afterCompletion();
            synchronized (this) {
                status = Status.STATUS_NO_TRANSACTION;
View Full Code Here

                if (!rms.isEmpty()) {
                    result = XAResource.XA_OK;
                }
            } else {
                rollbackResources(rms);
                throw new RollbackException("Unable to commit");
            }
        } finally {
            if (result == XAResource.XA_RDONLY) {
                afterCompletion();
                synchronized (this) {
View Full Code Here

      {
        throw new javax.transaction.HeuristicMixedException();
      }
      catch (TRANSACTION_ROLLEDBACK e4)
      {
        throw new RollbackException(e4.toString());
      }
      catch (org.omg.CORBA.NO_PERMISSION e5)
      {
        throw new SecurityException();
      }
View Full Code Here

    int status = getStatus();

    switch (status)
    {
    case javax.transaction.Status.STATUS_MARKED_ROLLBACK:
      throw new RollbackException("TransactionImple.enlistResource - "
                    + jtaLogger.loggerI18N.getString("com.arjuna.ats.internal.jta.transaction.jts.markedrollback"));
    case javax.transaction.Status.STATUS_ACTIVE:
      break;
    default:
      throw new IllegalStateException(
View Full Code Here

      {
        throw new javax.transaction.HeuristicMixedException();
      }
      catch (TRANSACTION_ROLLEDBACK e4)
      {
        throw new RollbackException(e4.toString());
      }
      catch (org.omg.CORBA.NO_PERMISSION e5)
      {
        throw new SecurityException();
      }
View Full Code Here

        throw new javax.transaction.HeuristicMixedException();
      case ActionStatus.H_HAZARD:
        throw new javax.transaction.HeuristicMixedException();
      case ActionStatus.H_ROLLBACK:
      case ActionStatus.ABORTED:
        RollbackException rollbackException = new RollbackException(
            jtaLogger.logMesg
                .getString("com.arjuna.ats.internal.jta.transaction.arjunacore.commitwhenaborted"));
        if (_theTransaction.getDeferredThrowable() != null)
        {
          rollbackException.initCause(_theTransaction
              .getDeferredThrowable());
        }
        throw rollbackException;
      default:
        throw new IllegalStateException(
View Full Code Here

TOP

Related Classes of javax.transaction.RollbackException

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.