org.jboss.txbridge.ba
Class SingleTransactionManager

java.lang.Object
  extended by org.jboss.txbridge.ba.SingleTransactionManager
All Implemented Interfaces:
java.io.Serializable

public class SingleTransactionManager
extends java.lang.Object
implements java.io.Serializable

The Single Transaction Manager component is responsible for maintaining information about a single Business Activity. It knows about the exact order of tasks that have been executed within the Business Activity, the participants that have been instantiated for this specific Business Activity and about participant managers responsible for those participants.

Version:
0.1
Author:
Maciej P. Machulak (mmachulak@redhat.com)
See Also:
Serialized Form

Field Summary
private static com.arjuna.mw.wst.BusinessActivityManager businessActivityManager
           
private static org.apache.log4j.Logger log
           
private  java.util.concurrent.ConcurrentMap<Participant,com.arjuna.wst.BAParticipantManager> participantManagerMapping
           
private static ServiceInformationManager serviceInformationManager
           
private  java.util.concurrent.ConcurrentMap<java.lang.String,Participant> serviceParticipantMapping
           
private  java.util.List<java.lang.String> singleServiceList
           
private  java.util.concurrent.ConcurrentMap<java.lang.String,com.arjuna.wst.BAParticipantManager> taskBAManagerMapping
           
private  java.util.List<java.lang.String> taskList
           
private  java.util.List<java.lang.String> taskListFirst
           
private  java.util.List<java.lang.String> taskListLast
           
private  java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.String> taskServiceMapping
           
private  boolean transactionCompleted
           
private  java.lang.String txId
           
 
Constructor Summary
SingleTransactionManager(java.lang.String txId)
           
 
Method Summary
 void cleanInvocation(TaskDescription taskDesc)
          This method cleans invocation - if there was an error with invoking the required service then transaction-related information is removed.
 void compensate()
          This method executes datamgmt for all tasks that are associated with this transaction.
private  void compensateList(java.util.Stack<java.lang.String> taskList)
          This method executes a datamgmt for a given list of tasks.
 void complete()
          This method is executed by the participant.
 void completeInvocation(TaskDescription taskDesc, java.lang.Object[] arguments, java.lang.Object returnObject)
          This method handles transaction management for a certain invocation of a method when this invocation has already completed.
private  void completeList(java.util.List<CoordinatorCompletionParticipant> participantList, java.util.Map<Participant,com.arjuna.wst.BAParticipantManager> managerList)
          This method loops through a list of participants that should complete its work.
 void completeTask(java.lang.String taskId, MethodType serviceType)
          This method completes the work done by the given participant within a certain transaction.
 Participant processInvocation(java.lang.String taskId, java.lang.String serviceId)
          This method processes a single invocation within a scope of a transaction this single transaction manager is responsible for.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.log4j.Logger log

businessActivityManager

private static com.arjuna.mw.wst.BusinessActivityManager businessActivityManager

serviceInformationManager

private static ServiceInformationManager serviceInformationManager

txId

private java.lang.String txId

transactionCompleted

private boolean transactionCompleted

taskList

private java.util.List<java.lang.String> taskList

taskListFirst

private java.util.List<java.lang.String> taskListFirst

taskListLast

private java.util.List<java.lang.String> taskListLast

singleServiceList

private java.util.List<java.lang.String> singleServiceList

taskServiceMapping

private java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.String> taskServiceMapping

serviceParticipantMapping

private java.util.concurrent.ConcurrentMap<java.lang.String,Participant> serviceParticipantMapping

taskBAManagerMapping

private java.util.concurrent.ConcurrentMap<java.lang.String,com.arjuna.wst.BAParticipantManager> taskBAManagerMapping

participantManagerMapping

private java.util.concurrent.ConcurrentMap<Participant,com.arjuna.wst.BAParticipantManager> participantManagerMapping
Constructor Detail

SingleTransactionManager

public SingleTransactionManager(java.lang.String txId)
Method Detail

processInvocation

public Participant processInvocation(java.lang.String taskId,
                                     java.lang.String serviceId)
                              throws TransactionProcessingException
This method processes a single invocation within a scope of a transaction this single transaction manager is responsible for. It either creates a new participant for the service that is being invoked or associates this invocation with an existing participant.

Parameters:
taskId - is the task identifier.
serviceId - is the service identifier.
Returns:
the participant associated with the invocation.
Throws:
TransactionProcessingException - if an error occurs

completeInvocation

public void completeInvocation(TaskDescription taskDesc,
                               java.lang.Object[] arguments,
                               java.lang.Object returnObject)
                        throws com.arjuna.wst.SystemException,
                               com.arjuna.wst.UnknownTransactionException,
                               com.arjuna.wst.WrongStateException,
                               TransactionProcessingException
This method handles transaction management for a certain invocation of a method when this invocation has already completed.

Parameters:
taskDesc - is the task description.
arguments - is the list of original arguments.
returnObject - is the return object.
Throws:
com.arjuna.wst.SystemException - if there was an error.
com.arjuna.wst.UnknownTransactionException - if there was an error.
com.arjuna.wst.WrongStateException - if there was an error.
TransactionProcessingException - if there was an error.

completeTask

public void completeTask(java.lang.String taskId,
                         MethodType serviceType)
                  throws TransactionProcessingException,
                         com.arjuna.wst.SystemException,
                         com.arjuna.wst.UnknownTransactionException,
                         com.arjuna.wst.WrongStateException
This method completes the work done by the given participant within a certain transaction.

Parameters:
taskId - is the participant which wants to completeTask its work.
serviceType - is the type of the service.
Throws:
TransactionProcessingException - if processing was not successful.
com.arjuna.wst.SystemException - if processing was not successful.
com.arjuna.wst.UnknownTransactionException - if processing was not successful.
com.arjuna.wst.WrongStateException - if processing was not successful.

cleanInvocation

public void cleanInvocation(TaskDescription taskDesc)
                     throws TransactionProcessingException
This method cleans invocation - if there was an error with invoking the required service then transaction-related information is removed.

Parameters:
taskDesc - is the description of a certain task.
Throws:
TransactionProcessingException - an internal error.

complete

public void complete()
This method is executed by the participant. It asks the Single Transaction Manager to complete all the work that needs to be completed within the transaction.


completeList

private void completeList(java.util.List<CoordinatorCompletionParticipant> participantList,
                          java.util.Map<Participant,com.arjuna.wst.BAParticipantManager> managerList)
This method loops through a list of participants that should complete its work. After each participant completes its work, its associated BAParticipantManager informs the coordinator that the work has completed. Otherwise a fault is sent to the Coordinator.

Parameters:
participantList - is the list of participants that should complete their work.
managerList - is the list of BAParticipantManagers associated with participants

compensate

public void compensate()
This method executes datamgmt for all tasks that are associated with this transaction. It executes a compensationList() method on all lists that have been defined.


compensateList

private void compensateList(java.util.Stack<java.lang.String> taskList)
This method executes a datamgmt for a given list of tasks. It gets reference to participants responsible for different tasks and asks them to compensate those tasks. If there is an error with compensating a task it is communicated to the coordinator so that the client knows if heuristics occur.

Parameters:
taskList - is the list of tasks which should be compensated.