org.jboss.txbridge.ba.compensation
Class CompensationManagerProvider

java.lang.Object
  extended by org.jboss.txbridge.ba.compensation.CompensationManagerProvider

public class CompensationManagerProvider
extends java.lang.Object

This component is responsible for ensuring that a proper Compensation Manager is provided during execution of a service or a compensation action. It associates compensation managers with proper threads of execution.

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

Field Summary
private static java.util.concurrent.ConcurrentMap<java.lang.Long,CompensationManager> cmList
           
private static CompensationManagerProvider cmp
           
private static org.apache.log4j.Logger log
           
 
Constructor Summary
private CompensationManagerProvider()
           
 
Method Summary
 void associateCompensationManager(java.lang.Long thread, CompensationManager cmp)
          This method associates a compensation manager with a given thread of execution.
 CompensationManager getCompensationManager(java.lang.Long thread)
          This method returns the compensation manager object associated to a certain thread of execution.
static CompensationManagerProvider getSingletonInstance()
          Returns the instance fo a compensation manager provider.
 void removeCompensationManager(java.lang.Long thread)
          This method removes the association of a thread and a compensation manager.
 
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

cmp

private static volatile CompensationManagerProvider cmp

cmList

private static java.util.concurrent.ConcurrentMap<java.lang.Long,CompensationManager> cmList
Constructor Detail

CompensationManagerProvider

private CompensationManagerProvider()
Method Detail

getSingletonInstance

public static CompensationManagerProvider getSingletonInstance()
Returns the instance fo a compensation manager provider.

Returns:
the compensation manager.

associateCompensationManager

public void associateCompensationManager(java.lang.Long thread,
                                         CompensationManager cmp)
This method associates a compensation manager with a given thread of execution.

Parameters:
thread - is the thread for which the compensation manager should be associated.
cmp - is the compensation manager, which should be associated.

getCompensationManager

public CompensationManager getCompensationManager(java.lang.Long thread)
This method returns the compensation manager object associated to a certain thread of execution. If there is no compensation manager associated to a certain thread of execution then it means the service is being executed outside the scope of the Business Activity and a dummy compensation manager is simply returned.

Parameters:
thread - thread ID for which the compensation manager should be returned.
Returns:
the CompensationManager object.

removeCompensationManager

public void removeCompensationManager(java.lang.Long thread)
This method removes the association of a thread and a compensation manager.

Parameters:
thread - is the thread for which the associaction should be removed.