Examples of Xid


Examples of javax.transaction.xa.Xid

   {
      XATerminator xt = adapter.ctx.getXATerminator();
      WorkManager wm = adapter.ctx.getWorkManager();
      TestWork work = new TestWork();
      ExecutionContext ec = new ExecutionContext();
      Xid xid = new MyXid(1);
      ec.setXid(xid);

      wm.doWork(work, 0l, ec, null);
      if (work.complete == false)
         throw new Exception("Work was not done");
View Full Code Here

Examples of javax.transaction.xa.Xid

   public boolean equals(Object object)
   {
      if (object == null || (object instanceof Xid) == false)
         return false;

      Xid other = (Xid) object;
      return
      (
         formatId == other.getFormatId() &&
         Arrays.equals(globalTransactionId, other.getGlobalTransactionId()) &&
         Arrays.equals(branchQualifier, other.getBranchQualifier())
      );
   }
View Full Code Here

Examples of javax.transaction.xa.Xid

      ExecutionContext ctx = getExecutionContext();
     
      if (ctx != null)
      {
         Xid xid = ctx.getXid();
         if (xid != null)
         {
            //JBAS-4002 base value is in seconds as per the API, here we convert to millis
            long timeout = (ctx.getTransactionTimeout() * 1000);
            workManager.getXATerminator().registerWork(work, xid, timeout);
         }
      }
     
      if (ctx != null)
      {
         Xid xid = ctx.getXid();
         if (xid != null)
         {
            workManager.getXATerminator().startWork(work, xid);
         }
      }
View Full Code Here

Examples of javax.transaction.xa.Xid

      ExecutionContext ctx = getExecutionContext();

      if (ctx != null)
      {
         Xid xid = ctx.getXid();
         if (xid != null)
         {
            workManager.getXATerminator().endWork(work, xid);
         }
      }
View Full Code Here

Examples of javax.transaction.xa.Xid

      ExecutionContext ctx = getExecutionContext();

      if (ctx != null)
      {
         Xid xid = ctx.getXid();
         if (xid != null)
         {
            workManager.getXATerminator().cancelWork(work, xid);
         }
      }
View Full Code Here

Examples of javax.transaction.xa.Xid

            throw new IllegalStateException();
        }

        // Preventing two branches from being active at the same time on the
        // same resource manager
        Xid activeXid = (Xid) activeBranches.get(xaRes);
        if (activeXid != null)
        {
            return false;
        }

        boolean alreadyEnlisted = false;
        int flag = XAResource.TMNOFLAGS;

        Xid branchXid = (Xid) suspendedResources.get(xaRes);

        if (branchXid == null)
        {
            Iterator enlistedIterator = enlistedResources.iterator();
            while ((!alreadyEnlisted) && (enlistedIterator.hasNext()))
View Full Code Here

Examples of javax.transaction.xa.Xid

            Iterator branchKeys = branches.keySet().iterator();
   
            status = Status.STATUS_ROLLING_BACK;
            while (branchKeys.hasNext())
            {
                Xid xid = (Xid) branchKeys.next();
                XAResource resourceManager = (XAResource) branches.get(xid);
                try
                {
                    resourceManager.rollback(xid);
                }
View Full Code Here

Examples of javax.transaction.xa.Xid

     * @see javax.transaction.xa.XAResource#recover(int)
     */
    Xid[] getPreparedXids() {

        Iterator it = resources.keySet().iterator();
        Xid      curXid;
        HashSet  preparedSet = new HashSet();

        while (it.hasNext()) {
            curXid = (Xid) it.next();

View Full Code Here

Examples of javax.transaction.xa.Xid

            {
                // If we have only one resource, we don't ask to prepare, and we go with one-phase commit
                status = Status.STATUS_COMMITTING;
                while (branchKeys.hasNext())
                {
                    Xid key = branchKeys.next();
                    XAResource resourceManager = branches.get(key);
                    try
                    {
                        if (!failed)
                        {
                            resourceManager.commit(key, true);
                        }
                        else
                        {
                            resourceManager.rollback(key);
                        }
                    }
                    catch (Throwable e)
                    {
                        if (failures == null)
                        {
                            //lazy instantiate this, because we only need on failures
                            failures = new ArrayList();
                        }
                        failures.add(e);
                        failed = true;
                        status = Status.STATUS_MARKED_ROLLBACK;
                        NucleusLogger.TRANSACTION.error(LOCALISER.msg("015038", "commit", resourceManager,
                            getXAErrorCode(e), toString()));                   
                    }
                }
                if (!failed)
                {
                    status = Status.STATUS_COMMITTED;
                }
                else
                {
                    status = Status.STATUS_ROLLEDBACK;
                }
            }
            else if (enlistedResources.size() > 0)
            {
                // Prepare each enlisted resource
                status = Status.STATUS_PREPARING;
                while ((!failed) && (branchKeys.hasNext()))
                {
                    Xid key = branchKeys.next();
                    XAResource resourceManager = branches.get(key);
                    try
                    {
                        // Preparing the resource manager using its branch xid
                        resourceManager.prepare(key);
                    }
                    catch (Throwable e)
                    {
                        if (failures == null)
                        {
                            //lazy instantiate this, because we only need on failures
                            failures = new ArrayList();
                        }
                        failures.add(e);
                        failed = true;
                        status = Status.STATUS_MARKED_ROLLBACK;
                        NucleusLogger.TRANSACTION.error(LOCALISER.msg("015038", "prepare", resourceManager,
                            getXAErrorCode(e), toString()));
                    }
                }

                if (!failed)
                {
                    status = Status.STATUS_PREPARED;
                }
   
                // Starts 2nd commit phase
                // If fail, rollback
                if (failed)
                {
                    status = Status.STATUS_ROLLING_BACK;
                    failed = false;
                    // Rolling back all the prepared (and unprepared) branches
                    branchKeys = branches.keySet().iterator();
                    while (branchKeys.hasNext())
                    {
                        Xid key = branchKeys.next();
                        XAResource resourceManager = branches.get(key);
                        try
                        {
                            resourceManager.rollback(key);
                        }
                        catch (Throwable e)
                        {
                            NucleusLogger.TRANSACTION.error(LOCALISER.msg("015038", "rollback", resourceManager,
                                getXAErrorCode(e), toString()));                       
                            if (failures == null)
                            {
                                //lazy instantiate this, because we only need on failures
                                failures = new ArrayList();
                            }
                            failures.add(e);
                            failed = true;
                        }
                    }
                    status = Status.STATUS_ROLLEDBACK;
                }
                else
                {
                    status = Status.STATUS_COMMITTING;
                    // Commit each enlisted resource
                    branchKeys = branches.keySet().iterator();
                    while (branchKeys.hasNext())
                    {
                        Xid key = branchKeys.next();
                        XAResource resourceManager = branches.get(key);
                        try
                        {
                            resourceManager.commit(key, false);
                        }
View Full Code Here

Examples of javax.transaction.xa.Xid

        if (status != Status.STATUS_ACTIVE)
        {
            throw new IllegalStateException();
        }

        Xid xid = activeBranches.get(xaRes);
        if (xid == null)
        {
            throw new IllegalStateException();
        }
        activeBranches.remove(xaRes);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.