com.sun.sgs.impl.util
Class TransactionContextMap<T extends TransactionContext>

java.lang.Object
  extended by com.sun.sgs.impl.util.TransactionContextMap<T>
Type Parameters:
T - the type of transaction context

public class TransactionContextMap<T extends TransactionContext>
extends Object

Utility class for maintaining the association between transactions and instances of TransactionContext.

See Also:
TransactionContextFactory

Constructor Summary
TransactionContextMap(TransactionProxy txnProxy)
          Constructs an instance of this class with the given TransactionProxy.
 
Method Summary
 void checkContext(T context)
          Checks that the specified context is currently active, throwing TransactionNotActiveException if it isn't.
 T checkTransaction(Transaction txn)
          Checks the specified transaction, throwing IllegalStateException if the current context is null or if the specified transaction is not equal to the transaction in the current context.
 void clearContext()
          Removes the currently active transaction context.
 T getContext()
          Returns the context for the current transaction.
 T joinTransaction(TransactionContextFactory<T> contextFactory)
          Makes sure the participant obtained from contextFactory is joined to the current transaction and returns the associated context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionContextMap

public TransactionContextMap(TransactionProxy txnProxy)
Constructs an instance of this class with the given TransactionProxy.

Parameters:
txnProxy - the transaction proxy
Method Detail

joinTransaction

public T joinTransaction(TransactionContextFactory<T> contextFactory)
Makes sure the participant obtained from contextFactory is joined to the current transaction and returns the associated context. If the participant has not yet joined the current transaction, creates a new context by invoking createContext on contextFactory, passing the current transaction, sets that context as the current context for the current thread, and joins the transaction. Returns the context for the current transaction.

Parameters:
contextFactory - the context factory
Returns:
the context for the current transaction
Throws:
TransactionNotActiveException - if no transaction is active
IllegalStateException - if there is a problem with the state of the transaction.

clearContext

public void clearContext()
Removes the currently active transaction context.


getContext

public T getContext()
Returns the context for the current transaction.

Returns:
the context for the current transaction
Throws:
TransactionNotActiveException - if no transaction is active
IllegalStateException - if there is a problem with the state of the transaction.

checkContext

public void checkContext(T context)
Checks that the specified context is currently active, throwing TransactionNotActiveException if it isn't.

Parameters:
context - a context
Throws:
TransactionNotActiveException - if the specified context is not currently active

checkTransaction

public T checkTransaction(Transaction txn)
Checks the specified transaction, throwing IllegalStateException if the current context is null or if the specified transaction is not equal to the transaction in the current context.

Parameters:
txn - a transaction
Returns:
the current transaction context

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved