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

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

public abstract class TransactionContextFactory<T extends TransactionContext>
extends Object

Utility class for participating in a transaction, parameterized by a type of TransactionContext to be used with a participant.


Nested Class Summary
protected  class TransactionContextFactory.NonDurableParticipant
          Provides a non-durable transaction participant.
protected  class TransactionContextFactory.Participant
          Provides a durable transaction participant.
 
Constructor Summary
protected TransactionContextFactory(TransactionContextMap<T> contextMap, String participantName)
          Constructs an instance of this class with the given TransactionContextMap.
protected TransactionContextFactory(TransactionProxy txnProxy, String participantName)
          Constructs an instance of this class, using the specified TransactionProxy to create the TransactionContextMap.
 
Method Summary
protected abstract  T createContext(Transaction txn)
          Returns a new TransactionContext to hold state for the specified transaction, txn.
protected  TransactionParticipant createParticipant()
          Returns a new transaction participant that operates on the currently active transaction context.
 TransactionParticipant getParticipant()
          Returns the transaction participant for use with this factory.
 T joinTransaction()
          Makes sure the participant 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

TransactionContextFactory

protected TransactionContextFactory(TransactionContextMap<T> contextMap,
                                    String participantName)
Constructs an instance of this class with the given TransactionContextMap.

Parameters:
contextMap - the transaction context map
participantName - the type name of the transaction participants

TransactionContextFactory

protected TransactionContextFactory(TransactionProxy txnProxy,
                                    String participantName)
Constructs an instance of this class, using the specified TransactionProxy to create the TransactionContextMap. Use this constructor if access to the TransactionContextMap is not needed.

Parameters:
txnProxy - the transaction proxy
participantName - the type name of the transaction participants
Method Detail

joinTransaction

public T joinTransaction()
Makes sure the participant is joined to the current transaction and returns the associated context.

The default implementation calls joinTransaction on the TransactionContextMap supplied to, or created by, the constructor, passing this instance as the argument.

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.

getParticipant

public TransactionParticipant getParticipant()
Returns the transaction participant for use with this factory.

The default implementation creates a new transaction participant by calling createParticipant the first time the participant is requested.

Returns:
the transaction participant

createContext

protected abstract T createContext(Transaction txn)
Returns a new TransactionContext to hold state for the specified transaction, txn.

Parameters:
txn - a transaction
Returns:
a new transaction context

createParticipant

protected TransactionParticipant createParticipant()
Returns a new transaction participant that operates on the currently active transaction context.

The default implementation of this method returns a transaction participant that implements NonDurableTransactionParticipant.

Returns:
a transaction participant

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