Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2006, Red Hat Middleware LLC, and individual contributors
   * as indicated by the @author tags.
   * See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   * This copyrighted material is made available to anyone wishing to use,
   * modify, copy, or redistribute it subject to the terms and conditions
   * of the GNU Lesser General Public License, v. 2.1.
  * This program is distributed in the hope that it will be useful, but WITHOUT A
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
  * You should have received a copy of the GNU Lesser General Public License,
  * v.2.1 along with this distribution; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  * MA  02110-1301, USA.
  *
  * (C) 2005-2006,
  * @author JBoss Inc.
  */
 /*
  * Copyright (C) 2002,
  *
  * Hewlett-Packard Arjuna Labs,
  * Newcastle upon Tyne,
  * Tyne and Wear,
  * UK.
  *
  * $Id: TransactionImple.java 2342 2006-03-30 13:06:17Z  $
  */
 
 package com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate;
 
 
 import  javax.transaction.HeuristicCommitException;
 import  javax.transaction.HeuristicMixedException;
 import  javax.transaction.HeuristicRollbackException;
 import  javax.transaction.RollbackException;
 import  javax.transaction.SystemException;
 
 
 // https://jira.jboss.org/jira/browse/JBTM-384
 
 public class TransactionImple extends
 {
Create a new transaction with the specified timeout.
 
 
 	public TransactionImple (int timeout)
 	{
 		this(new SubordinateAtomicAction(timeout));
 	}
 
 	// TODO use the timeout!
 
 	public TransactionImple (AtomicAction act)
 	{
 		super(act);
 
 		TransactionImple.putTransaction(this);
 	}

Overloads Object.equals()
 
 
 	public boolean equals (Object obj)
 	{
 		if (..isTraceEnabled()) {
             ..trace("TransactionImple.equals");
         }
 
 		if (obj == null)
 			return false;
 
 		if (obj == this)
 			return true;
 
 		if (obj instanceof TransactionImple)
 		{
 			return super.equals(obj);
 		}
 
 		return false;
	}

This is a subordinate transaction, so any attempt to commit it or roll it back directly, should fail.
	public void commit () throws javax.transaction.RollbackException,
			javax.transaction.HeuristicMixedException,
			javax.transaction.HeuristicRollbackException,
			java.lang.SecurityException, javax.transaction.SystemException,
	{
	}

This is a subordinate transaction, so any attempt to commit it or roll it back directly, should fail.
	public void rollback () throws java.lang.IllegalStateException,
			java.lang.SecurityException, javax.transaction.SystemException
	{
	}
	// Should probably return XA status codes, c.f., XAResource.prepare
	public int doPrepare ()
	{
		try
		{
			int res = subAct.doPrepare();
			switch (res)
			{
				TransactionImple.removeTransaction(this);
				break;
			}
			return res;
		}
		catch (ClassCastException ex)
		{
		}
	}
	public void doCommit () throws IllegalStateException,
			HeuristicMixedException, HeuristicRollbackException,
			javax.transaction.SystemException
	{
		try
		{
			int res = subAct.doCommit();
			switch (res)
			{
				TransactionImple.removeTransaction(this);
				break;
				throw new HeuristicRollbackException();
				throw new HeuristicRollbackException();
				throw new HeuristicMixedException();
				TransactionImple.removeTransaction(this);
				throw new IllegalStateException();
			default:
				throw new HeuristicMixedException(); // not sure what
			// happened,
			// so err on the safe side!
			}
		}
		catch (ClassCastException ex)
		{
            UnexpectedConditionException unexpectedConditionException = new UnexpectedConditionException(ex.toString());
            unexpectedConditionException.initCause(ex);
			throw unexpectedConditionException;
		}
	}
	public void doRollback () throws IllegalStateException,
			HeuristicMixedException, HeuristicCommitException, HeuristicRollbackException, SystemException
	{
		try
		{
			{
			}
			// JBTM-927 the transaction reaper may have aborted this transaction already
			int res = subAct.status() == . ? . : subAct.doRollback();
			switch (res)
			{
	                         TransactionImple.removeTransaction(this);
	                                break;
				throw new HeuristicRollbackException();
				throw new HeuristicCommitException();
				throw new HeuristicMixedException();
			default:
				throw new HeuristicMixedException();
			}
		}
		catch (ClassCastException ex)
		{
            UnexpectedConditionException unexpectedConditionException = new UnexpectedConditionException(ex.toString());
            unexpectedConditionException.initCause(ex);
			throw unexpectedConditionException;
		}
	}

Deprecated:
Only called from a test
Throws:
IllegalStateException
	public void doForget () throws IllegalStateException
	{
		try
		{
			subAct.doForget();
		}
		catch (ClassCastException ex)
		{
			throw new IllegalStateException(ex);
		}
		finally
		{
			TransactionImple.removeTransaction(this);
		}
	}
	public void doOnePhaseCommit () throws IllegalStateException,
			javax.transaction.HeuristicMixedException, javax.transaction.SystemException, RollbackException
	{
		try
		{
			int status = subAct.doOnePhaseCommit();
			switch (status)
			{
				TransactionImple.removeTransaction(this);
				break;
	                 case .:
	                 case .:
                TransactionImple.removeTransaction(this);
                // JBTM-428. Note also this may be because the tx was set rollback only,
                // in which case IllegalState may be a better option?
                throw new RollbackException();
	                case .:
	                                throw new InvalidTerminationStateException();
			default:
				throw new javax.transaction.HeuristicMixedException();
			}
		}
		catch (ClassCastException ex)
		{
            UnexpectedConditionException unexpectedConditionException = new UnexpectedConditionException(ex.toString());
            unexpectedConditionException.initCause(ex);
			throw unexpectedConditionException;
		}
	}
	public boolean doBeforeCompletion () throws javax.transaction.SystemException
	{
	    try
	    {
	        
	        return subAct.doBeforeCompletion();
	    }
	    catch (final Exception ex)
	    {
	        ex.printStackTrace();
	        UnexpectedConditionException unexpectedConditionException = new UnexpectedConditionException(ex.toString());
	        unexpectedConditionException.initCause(ex);
	        
	        throw unexpectedConditionException;
	    }
	}
	public String toString ()
	{
		if (super. == null)
			return "TransactionImple < ac-subordinate, NoTransaction >";
		else
		{
			return "TransactionImple < ac-subordinate, "
super. + " >";
		}
	}
	protected void commitAndDisassociate ()
			throws javax.transaction.RollbackException,
			javax.transaction.HeuristicMixedException,
			javax.transaction.HeuristicRollbackException,
			java.lang.SecurityException, javax.transaction.SystemException,
	{
	}
	protected void rollbackAndDisassociate ()
			java.lang.SecurityException, javax.transaction.SystemException
	{
	}

Because of recovery, it is possible that a transaction may not be able to activate itself from the log initially, forcing us to retry later.

Returns:
true if the transaction was activated, false otherwise.
    public boolean activated ()
    {
    	return true;
    }
	protected Xid createXid(boolean branchXAModifier theModifierXAResource xaResourcethrows IOExceptionObjectStoreException
	{
		Xid xid = baseXid();
		// We can have subordinate XIDs that can be editted
			return xid;
		Integer eisName = null;
        if(branch) {
            if( != null) {
                eisName = .getEISName(xaResource);
            }
        }
		xid = new XidImple(xidbrancheisName);
		if (theModifier != null)
		{
			try
			{
				xid = theModifier.createXid((XidImplexid);
			}
			catch (Exception e)
			{
			}
		}
		return xid;
	}
New to GrepCode? Check out our FAQ X