com.atomikos.icatch.imp
Class AbstractCompositeTransaction

java.lang.Object
  extended by com.atomikos.icatch.imp.AbstractCompositeTransaction
All Implemented Interfaces:
Stateful, CompositeTransaction, Serializable
Direct Known Subclasses:
CompositeTransactionAdaptor, CompositeTransactionImp

public abstract class AbstractCompositeTransaction
extends Object
implements CompositeTransaction, Serializable

An abstract base implementation of CompositeTransaction, for common behaviour of both proxy and local instances.

See Also:
Serialized Form

Field Summary
protected  Stack lineage_
           
protected  Properties properties_
           
protected  boolean serial_
           
protected  HeuristicMessage tag_
           
protected  String tid_
           
 
Constructor Summary
AbstractCompositeTransaction()
          Required for externalization of subclasses
AbstractCompositeTransaction(String tid, Stack lineage, boolean serial)
          Constructor.
 
Method Summary
 RecoveryCoordinator addParticipant(Participant participant)
           
 void addSubTxAwareParticipant(SubTxAwareParticipant subtxaware)
          Resources that support lock inheritance can use this feature to be notified whenever a lock should be inherited.
 void commit()
          Commits the composite transaction.
 CompositeTransaction createSubTransaction()
           
 boolean equals(Object obj)
           
 CompositeCoordinator getCompositeCoordinator()
           
 Extent getExtent()
           
 Stack getLineage()
           
 int getLocalSubTxCount()
           
 Properties getProperties()
          Gets all properties of this instance.
 String getProperty(String name)
          Gets the specified metadata property.
 Object getState()
          Gets the current state.
 String getTid()
           
 long getTimeout()
           
 TransactionControl getTransactionControl()
           
 int hashCode()
           
 boolean isAncestorOf(CompositeTransaction ct)
           
 boolean isDescendantOf(CompositeTransaction ct)
           
 boolean isLocal()
           
 boolean isRelatedTransaction(CompositeTransaction ct)
           
 boolean isRoot()
           
 boolean isSameTransaction(CompositeTransaction ct)
           
 boolean isSerial()
          Serial mode is an optimized way for lock inheritance: no locks among related transactions are necessary if all related transactions are executed serially with respect to each other.
 void registerSynchronization(Synchronization sync)
           
 void rollback()
          Rollback of the current transaction.
 void setProperty(String name, String value)
          Sets metadata property information on the transaction object.
 void setRollbackOnly()
          Marks the transaction so that the only possible termination is rollback.
 void setSerial()
          Sets the serial mode.
 void setTag(HeuristicMessage tag)
          Sets the tag for this transaction.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lineage_

protected Stack lineage_

tid_

protected String tid_

serial_

protected boolean serial_

tag_

protected HeuristicMessage tag_

properties_

protected Properties properties_
Constructor Detail

AbstractCompositeTransaction

public AbstractCompositeTransaction()
Required for externalization of subclasses


AbstractCompositeTransaction

public AbstractCompositeTransaction(String tid,
                                    Stack lineage,
                                    boolean serial)
Constructor.

Method Detail

getTid

public String getTid()
Specified by:
getTid in interface CompositeTransaction
Returns:
String The tid for the tx.
See Also:
CompositeTransaction.

setTag

public void setTag(HeuristicMessage tag)
Description copied from interface: CompositeTransaction
Sets the tag for this transaction. This is returned as a summary of the local work in case the transaction was imported from a remote client TM.

Specified by:
setTag in interface CompositeTransaction
See Also:
CompositeTransaction.

isSerial

public boolean isSerial()
Description copied from interface: CompositeTransaction
Serial mode is an optimized way for lock inheritance: no locks among related transactions are necessary if all related transactions are executed serially with respect to each other. The serial property is set by the root transaction and is propagated to all its subtransactions.

Specified by:
isSerial in interface CompositeTransaction
Returns:
See Also:
CompositeTransaction.

isLocal

public boolean isLocal()
Specified by:
isLocal in interface CompositeTransaction
Returns:
boolean True if started in the local VM. For imported transactions, this is false.
See Also:
Defaults to false.

getTransactionControl

public TransactionControl getTransactionControl()
                                         throws UnsupportedOperationException
Specified by:
getTransactionControl in interface CompositeTransaction
Throws:
UnsupportedOperationException
See Also:
CompositeTransaction.

addParticipant

public RecoveryCoordinator addParticipant(Participant participant)
                                   throws SysException,
                                          IllegalStateException
Specified by:
addParticipant in interface CompositeTransaction
Returns:
RecoveryCoordinator Whom to ask for indoubt timeout resolution.
Throws:
SysException
IllegalStateException
See Also:
CompositeTransaction

registerSynchronization

public void registerSynchronization(Synchronization sync)
                             throws IllegalStateException,
                                    UnsupportedOperationException,
                                    SysException
Specified by:
registerSynchronization in interface CompositeTransaction
Throws:
IllegalStateException
SysException
UnsupportedOperationException
See Also:
CompositeTransaction

getLineage

public Stack getLineage()
Specified by:
getLineage in interface CompositeTransaction
Returns:
Stack A stack of ancestors, bottom one is the root.
See Also:
CompositeTransaction.

isRoot

public boolean isRoot()
Specified by:
isRoot in interface CompositeTransaction
Returns:
boolean True if this is the root transaction, i.e. the first transaction created in a (possibly distributed) hierarchy.
See Also:
CompositeTransaction.

isAncestorOf

public boolean isAncestorOf(CompositeTransaction ct)
Specified by:
isAncestorOf in interface CompositeTransaction
Returns:
boolean True if this instance is an ancestor of the supplied transaction.
See Also:
CompositeTransaction.

isDescendantOf

public boolean isDescendantOf(CompositeTransaction ct)
Specified by:
isDescendantOf in interface CompositeTransaction
Returns:
boolean True if this instance is a descendant of the other instance.
See Also:
CompositeTransaction.

isRelatedTransaction

public boolean isRelatedTransaction(CompositeTransaction ct)
Specified by:
isRelatedTransaction in interface CompositeTransaction
Returns:
True if related. That is: if both share the same root transaction.
See Also:
CompositeTransaction.

isSameTransaction

public boolean isSameTransaction(CompositeTransaction ct)
Specified by:
isSameTransaction in interface CompositeTransaction
Returns:
True if both are the same.
See Also:
CompositeTransaction.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getCompositeCoordinator

public CompositeCoordinator getCompositeCoordinator()
                                             throws SysException,
                                                    UnsupportedOperationException
Specified by:
getCompositeCoordinator in interface CompositeTransaction
Returns:
CompositeCoordinator
Throws:
SysException
UnsupportedOperationException
See Also:
CompositeTransaction.

addSubTxAwareParticipant

public void addSubTxAwareParticipant(SubTxAwareParticipant subtxaware)
                              throws SysException,
                                     UnsupportedOperationException,
                                     IllegalStateException
Description copied from interface: CompositeTransaction
Resources that support lock inheritance can use this feature to be notified whenever a lock should be inherited.

Specified by:
addSubTxAwareParticipant in interface CompositeTransaction
Throws:
SysException
IllegalStateException
UnsupportedOperationException
See Also:
CompositeTransaction

createSubTransaction

public CompositeTransaction createSubTransaction()
                                          throws SysException,
                                                 IllegalStateException
Specified by:
createSubTransaction in interface CompositeTransaction
Throws:
SysException
IllegalStateException
See Also:
CompositeTransaction.createSubTransaction()

setSerial

public void setSerial()
               throws IllegalStateException,
                      SysException
Description copied from interface: CompositeTransaction
Sets the serial mode. This only works on the root itself, and can not be undone. After this, no parallel calls are allowed in any descendant.

Specified by:
setSerial in interface CompositeTransaction
Throws:
IllegalStateException
SysException
See Also:
CompositeTransaction.setSerial()

getLocalSubTxCount

public int getLocalSubTxCount()
Specified by:
getLocalSubTxCount in interface CompositeTransaction
See Also:
CompositeTransaction.getLocalSubTxCount()

getExtent

public Extent getExtent()
Specified by:
getExtent in interface CompositeTransaction
Returns:
The extent.
See Also:
CompositeTransaction.getExtent()

getTimeout

public long getTimeout()
Specified by:
getTimeout in interface CompositeTransaction
Returns:
long The transaction timeout in millis.
See Also:
CompositeTransaction.getTimeout()

setRollbackOnly

public void setRollbackOnly()
Description copied from interface: CompositeTransaction
Marks the transaction so that the only possible termination is rollback.

Specified by:
setRollbackOnly in interface CompositeTransaction
See Also:
CompositeTransaction.setRollbackOnly()

commit

public void commit()
            throws HeurRollbackException,
                   HeurMixedException,
                   HeurHazardException,
                   SysException,
                   SecurityException,
                   RollbackException
Description copied from interface: CompositeTransaction
Commits the composite transaction.

Specified by:
commit in interface CompositeTransaction
Throws:
HeurRollbackException - On heuristic rollback.
HeurMixedException - On heuristic mixed outcome.
HeurHazardException - In case of heuristic hazard.
SysException - For unexpected failures.
SecurityException - If calling thread does not have right to commit.
RollbackException - If the transaction was rolled back before prepare.
See Also:
CompositeTransaction.commit()

rollback

public void rollback()
              throws IllegalStateException,
                     SysException
Description copied from interface: CompositeTransaction
Rollback of the current transaction.

Specified by:
rollback in interface CompositeTransaction
Throws:
IllegalStateException - If prepared or inactive.
SysException - If unexpected error.
See Also:
CompositeTransaction.rollback()

setProperty

public void setProperty(String name,
                        String value)
Description copied from interface: CompositeTransaction
Sets metadata property information on the transaction object. Once set, metadata properties can't be overwritten. Properties are inherited by all subtransactions created after the set. Properties may or may not be propagated along with exported transactions (depending on the protocol).

Specified by:
setProperty in interface CompositeTransaction

getProperty

public String getProperty(String name)
Description copied from interface: CompositeTransaction
Gets the specified metadata property.

Specified by:
getProperty in interface CompositeTransaction
Parameters:
name - The name of the property.
Returns:
The property, or null if not set.

getProperties

public Properties getProperties()
Description copied from interface: CompositeTransaction
Gets all properties of this instance.

Specified by:
getProperties in interface CompositeTransaction
Returns:
The (cloned) properties of this transaction.

getState

public Object getState()
Description copied from interface: CompositeTransaction
Gets the current state.

Specified by:
getState in interface Stateful
Specified by:
getState in interface CompositeTransaction
Returns:
The object representing the state.
See Also:
com.atomikos.finitestates.Stateful.


Copyright © 2012. All Rights Reserved.