com.atomikos.icatch.imp
Class BaseTransactionManager

java.lang.Object
  extended by com.atomikos.icatch.imp.BaseTransactionManager
All Implemented Interfaces:
CompositeTransactionManager, SubTxAwareParticipant, Serializable

public class BaseTransactionManager
extends Object
implements CompositeTransactionManager, SubTxAwareParticipant

Abstract TM class, to be extended for different communication layers. For instance, transactional RMI could be one extension, JTS another one.

See Also:
Serialized Form

Constructor Summary
protected BaseTransactionManager()
          Constructor.
 
Method Summary
 void committed(CompositeTransaction tx)
          Called if a tx is ended successfully.
 CompositeTransaction createCompositeTransaction(long timeout)
          Starts a new (sub)transaction (not an activity) for the current thread.
 CompositeTransaction getCompositeTransaction()
          Gets the composite transaction for the current thread.
 CompositeTransaction getCompositeTransaction(String tid)
          Gets the composite transaction with the given id.
 Participant getParticipant(String root)
          Get the participant for the given root.
 void init(TransactionServiceImp service, Properties properties)
          Initialize the TM.
protected  void printMsg(String msg, int level)
          Print a message to the console, with the given level of detail.
protected  CompositeTransaction recreateCompositeTransaction(Propagation context, boolean orphancheck, boolean heur_commit)
          Recreate a composite transaction based on an imported context.
 void resume(CompositeTransaction ct)
          Re-maps the thread to the given tx.
 void rolledback(CompositeTransaction tx)
          Called if a tx is ended with failure.
 void shutdown(boolean force)
          Shut down the server in a clean way.
protected  void startlistening(CompositeTransaction transaction)
           
 CompositeTransaction suspend()
          Suspends the tx for the current thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseTransactionManager

protected BaseTransactionManager()
Constructor.

Method Detail

printMsg

protected void printMsg(String msg,
                        int level)
Print a message to the console, with the given level of detail.

Parameters:
msg -
level -

init

public void init(TransactionServiceImp service,
                 Properties properties)
          throws SysException
Initialize the TM.

Parameters:
service - The tx service to use. As part of this method, the service will also be initialized.
properties - The init properties.
Throws:
SysException

getParticipant

public Participant getParticipant(String root)
Get the participant for the given root. Needed for recovery of JCA inbound transactions.

Parameters:
root -
Returns:
The participant.

committed

public void committed(CompositeTransaction tx)
Called if a tx is ended successfully. In order to remove the tx from the mapping.

Specified by:
committed in interface SubTxAwareParticipant
Parameters:
tx - The composite transaction that has terminated locally at its node.
See Also:
SubTxAwareParticipant

rolledback

public void rolledback(CompositeTransaction tx)
Called if a tx is ended with failure. In order to remove tx from mapping.

Specified by:
rolledback in interface SubTxAwareParticipant
See Also:
SubTxAwareParticipant

getCompositeTransaction

public CompositeTransaction getCompositeTransaction()
                                             throws SysException
Description copied from interface: CompositeTransactionManager
Gets the composite transaction for the current thread.

Specified by:
getCompositeTransaction in interface CompositeTransactionManager
Returns:
CompositeTransaction The instance for the current thread, null if none.
Throws:
SysException - Unexpected failure.
See Also:
CompositeTransactionManager

getCompositeTransaction

public CompositeTransaction getCompositeTransaction(String tid)
                                             throws SysException
Description copied from interface: CompositeTransactionManager
Gets the composite transaction with the given id. This method is useful e.g. for retrieving a suspended transaction by its id.

Specified by:
getCompositeTransaction in interface CompositeTransactionManager
Parameters:
tid - The id of the transaction.
Returns:
CompositeTransaction The transaction with the given id, or null if not found.
Throws:
SysException - Unexpected failure.
See Also:
CompositeTransactionManager

recreateCompositeTransaction

protected CompositeTransaction recreateCompositeTransaction(Propagation context,
                                                            boolean orphancheck,
                                                            boolean heur_commit)
                                                     throws SysException
Recreate a composite transaction based on an imported context. Needed by the application's communication layer.

Parameters:
context - The propagationcontext.
orphancheck - If true, real composite txs are done. If false, OTS like behavior applies.
heur_commit - True for heuristic commit, false for heuristic rollback.
Returns:
CompositeTransaction The recreated local instance.
Throws:
SysException - Failure.

suspend

public CompositeTransaction suspend()
                             throws SysException
Description copied from interface: CompositeTransactionManager
Suspends the tx for the current thread.

Specified by:
suspend in interface CompositeTransactionManager
Returns:
CompositeTransaction The transaction for the current thread.
Throws:
SysException - On failure.
See Also:
CompositeTransactionManager

resume

public void resume(CompositeTransaction ct)
            throws IllegalStateException,
                   SysException
Description copied from interface: CompositeTransactionManager
Re-maps the thread to the given tx.

Specified by:
resume in interface CompositeTransactionManager
Parameters:
ct - The CompositeTransaction to resume.
Throws:
IllegalStateException - If thread has tx already.
SysException - Unexpected failure.
See Also:
CompositeTransactionManager

shutdown

public void shutdown(boolean force)
              throws SysException,
                     IllegalStateException
Shut down the server in a clean way.

Parameters:
force - If true, shutdown will not wait for possibly indoubt txs to finish. Calling shutdown with force being true implies that shutdown will not fail, but there may be remaining timer threads that stay asleep until there timeouts expire. Such remaining active transactions will NOT be able to finish, because the recovery manager will be shutdown by that time. New transactions will not be allowed.
Throws:
SysException - For unexpected errors.
IllegalStateException - If active txs exist, and not force.

startlistening

protected void startlistening(CompositeTransaction transaction)
                       throws SysException
Throws:
SysException

createCompositeTransaction

public CompositeTransaction createCompositeTransaction(long timeout)
                                                throws SysException
Description copied from interface: CompositeTransactionManager
Starts a new (sub)transaction (not an activity) for the current thread. Associates the current thread with that instance.
NOTE: subtransactions should not be mixed: either each subtransaction is an activity, or not (default). Use suspend/resume if mixed models are necessary: for instance, if you want to create a normal transaction within an activity, then suspend the activity first before starting the transaction. Afterwards, resume the activity.

Specified by:
createCompositeTransaction in interface CompositeTransactionManager
Returns:
CompositeTransaction The new instance.
Throws:
SysException - Unexpected error.
See Also:
CompositeTransactionManager


Copyright © 2011. All Rights Reserved.