org.jboss.txbridge.ba.participant
Class Participant

java.lang.Object
  extended by org.jboss.txbridge.ba.participant.Participant
Direct Known Subclasses:
ParticipantCompletionParticipant

public abstract class Participant
extends java.lang.Object

This is an abstract class for Participant. It provides the implemention of methods that are related to datamgmt and completing the work and are common for following participants: - Coordinator Completion Participant - Participant Completion Participant

Version:
0.1
Author:
Maciej P. Machulak (mmachulak@redhat.com)

Field Summary
private static BATransactionManager baTransactionManager
           
private  ManagedDataFactory cdf
           
private  java.util.concurrent.ConcurrentMap<java.lang.String,ManagedData> compensationData
           
protected  boolean completed
           
private static org.apache.log4j.Logger log
           
protected  java.lang.String serviceId
           
protected  ServiceInformationManager sim
           
protected  SingleTransactionManager stm
           
protected  java.util.List<java.lang.String> taskList
           
protected  java.lang.String txId
           
 
Constructor Summary
Participant(java.lang.String txId, java.lang.String serviceId, SingleTransactionManager stm, ManagedDataFactory cdf)
          Constructor.
 
Method Summary
 void associateTask(java.lang.String taskId)
          This method associates a new task with the existing participant.
(package private)  void closeTransaction()
          This method is invoked by the participant object if a transaction is finished.
 void compensateTask(java.lang.String taskId)
          This method provides the implementation for executing the datamgmt action.
(package private)  void compensateTransaction()
          This method is invoked by the participant object if a transaction should compensate.
 java.lang.Object get(java.lang.String taskId, java.lang.Object objectId)
          This method retrieves an object with a given identifier from the datamgmt data that is stored for a given task id.
 java.lang.Object[] getArguments(java.lang.String taskId)
          This method retrieves a list of arguments that was passed for method's invocation.
 java.lang.Object[] getReturn(java.lang.String taskId)
          This method gets the return value that will be used as an argument when executing datamgmt action (when DataMatch is set to RETURN_VALUE)
 void put(java.lang.String taskId, java.lang.Object objectId, java.lang.Object object)
          This method stores an object withing the datamgmt data for a given task.
 void putArguments(java.lang.String taskId, java.lang.Object[] arguments)
          This method stores a list of arguments that was passed for method's invocation.
 void putReturn(java.lang.String taskId, java.lang.Object returnObject)
          This method stores the return value that will be used as an argument when executing datamgmt action (when DataMatch is set to RETURN_VALUE)
 void removeTask(java.lang.String taskId)
           
 
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

sim

protected ServiceInformationManager sim

baTransactionManager

private static BATransactionManager baTransactionManager

cdf

private ManagedDataFactory cdf

stm

protected SingleTransactionManager stm

txId

protected java.lang.String txId

serviceId

protected java.lang.String serviceId

taskList

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

completed

protected boolean completed

compensationData

private java.util.concurrent.ConcurrentMap<java.lang.String,ManagedData> compensationData
Constructor Detail

Participant

public Participant(java.lang.String txId,
                   java.lang.String serviceId,
                   SingleTransactionManager stm,
                   ManagedDataFactory cdf)
Constructor.

Parameters:
txId - is the transaction identifier.
serviceId - is the service identifier.
cdf - is the datamgmt data factory that should be used.
stm - is the single transaction manager.
Method Detail

put

public void put(java.lang.String taskId,
                java.lang.Object objectId,
                java.lang.Object object)
This method stores an object withing the datamgmt data for a given task. The object is assigned an ID.

Parameters:
taskId - is the ID of the task.
objectId - is the ID of the object.
object - is the object to be stored.

get

public java.lang.Object get(java.lang.String taskId,
                            java.lang.Object objectId)
This method retrieves an object with a given identifier from the datamgmt data that is stored for a given task id.

Parameters:
taskId - is the ID of the task.
objectId - is the ID of the object.
Returns:
the object with a given ID.

associateTask

public void associateTask(java.lang.String taskId)
                   throws TaskAssociationFailedException
This method associates a new task with the existing participant.

Parameters:
taskId - is the task identifier.
Throws:
TaskAssociationFailedException - if task association fails.

removeTask

public void removeTask(java.lang.String taskId)
Parameters:
taskId - is the ID of a task that should be removed from the list.

compensateTransaction

void compensateTransaction()
This method is invoked by the participant object if a transaction should compensate. It asks the BA Transaction Manager to compensate the transaction.


closeTransaction

void closeTransaction()
This method is invoked by the participant object if a transaction is finished. It asks the BA Transaction Manager to forget about the transaction.


compensateTask

public void compensateTask(java.lang.String taskId)
                    throws ActionExecutionException
This method provides the implementation for executing the datamgmt action. It uses the Executor class for executing a single method/service.

Parameters:
taskId - is the ID of the task that is supposed to be compensated.
Throws:
ActionExecutionException - if datamgmt was not successful.

putArguments

public void putArguments(java.lang.String taskId,
                         java.lang.Object[] arguments)
This method stores a list of arguments that was passed for method's invocation. It is used if the service has its DataMatch set to PARAM_MATCH.

Parameters:
taskId - is the ID of the task.
arguments - is the list of arguments.

getArguments

public java.lang.Object[] getArguments(java.lang.String taskId)
This method retrieves a list of arguments that was passed for method's invocation. It is used when executing the datamgmt action if the DataMatch is set to PARAM_MATCH.

Parameters:
taskId - is the task ID.
Returns:
the list of arguments.

putReturn

public void putReturn(java.lang.String taskId,
                      java.lang.Object returnObject)
This method stores the return value that will be used as an argument when executing datamgmt action (when DataMatch is set to RETURN_VALUE)

Parameters:
taskId - is the task identifier.
returnObject - is the return object.

getReturn

public java.lang.Object[] getReturn(java.lang.String taskId)
This method gets the return value that will be used as an argument when executing datamgmt action (when DataMatch is set to RETURN_VALUE)

Parameters:
taskId - is the task ID.
Returns:
the return object.