com.atomikos.datasource.xa.session
Class SessionHandleState

java.lang.Object
  extended by com.atomikos.datasource.xa.session.SessionHandleState

public class SessionHandleState
extends Object

A reusable state tracker for XA session/connection handles. An instance of this class can be used for automatically tracking the enlistment and termination states of all branches that a connection handle is involved in. It does this by switching states behind the scenes, so the same instance can be used for several branches.


Constructor Summary
SessionHandleState(XATransactionalResource resource, XAResource xaResource)
           
 
Method Summary
 boolean isActiveInTransaction(CompositeTransaction tx)
          Tests if the session is active (enlisted) in the given transaction.
 boolean isErroneous()
          Checks if the session has had any errors.
 boolean isInactiveInTransaction(CompositeTransaction tx)
          Tests if the session is inactive (delisted) for the given transaction.
 boolean isTerminated()
          Checks if the session handle is terminated (i.e., can be discarded) and the underlying vendor xa connection/session can be reused or destroyed.
 void notifyBeforeUse(CompositeTransaction ct, HeuristicMessage hmsg)
          Notification that the session handle is about to be used in the current transaction context (i.e.
 void notifySessionBorrowed()
          Notification that the session was gotten from the pool.
 void notifySessionClosed()
          Notification that the session handle has been closed by the application.
 void notifySessionErrorOccurred()
          Marks this session as erroneous.
 void notifyTransactionTerminated(CompositeTransaction ct)
          Notifies the session that the transaction was terminated.
 void registerSessionHandleStateChangeListener(SessionHandleStateChangeListener listener)
           
 String toString()
           
 void unregisterSessionHandleStateChangeListener(SessionHandleStateChangeListener listener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SessionHandleState

public SessionHandleState(XATransactionalResource resource,
                          XAResource xaResource)
Method Detail

isTerminated

public boolean isTerminated()
Checks if the session handle is terminated (i.e., can be discarded) and the underlying vendor xa connection/session can be reused or destroyed.

Returns:
True if the underlying vendor connection can be reused or destroyed. The session handle itself (i.e., the Atomikos proxy) should be discarded.

notifySessionBorrowed

public void notifySessionBorrowed()
Notification that the session was gotten from the pool.


notifySessionClosed

public void notifySessionClosed()
Notification that the session handle has been closed by the application.


notifyBeforeUse

public void notifyBeforeUse(CompositeTransaction ct,
                            HeuristicMessage hmsg)
                     throws InvalidSessionHandleStateException
Notification that the session handle is about to be used in the current transaction context (i.e. whatever transaction exists for the calling thread). This method MUST be called BEFORE any work is delegated to the underlying vendor connection.

Parameters:
ct - The current transaction, or null if none.
HeuristicMessage - hmsg The heuristic message, null if none.
Throws:
InvalidSessionHandleStateException

isErroneous

public boolean isErroneous()
Checks if the session has had any errors. This method can be used to decide whether or not to reuse the underlying vendor connection in the pool.

Returns:
True if sessionErrorOccurred has been called, false if not.

notifySessionErrorOccurred

public void notifySessionErrorOccurred()
Marks this session as erroneous. This has no other effect than that isErroneous returns true.


notifyTransactionTerminated

public void notifyTransactionTerminated(CompositeTransaction ct)
Notifies the session that the transaction was terminated.

Parameters:
ct -

registerSessionHandleStateChangeListener

public void registerSessionHandleStateChangeListener(SessionHandleStateChangeListener listener)

unregisterSessionHandleStateChangeListener

public void unregisterSessionHandleStateChangeListener(SessionHandleStateChangeListener listener)

toString

public String toString()
Overrides:
toString in class Object

isActiveInTransaction

public boolean isActiveInTransaction(CompositeTransaction tx)
Tests if the session is active (enlisted) in the given transaction.

Parameters:
tx -
Returns:

isInactiveInTransaction

public boolean isInactiveInTransaction(CompositeTransaction tx)
Tests if the session is inactive (delisted) for the given transaction.

Parameters:
tx -
Returns:


Copyright © 2011. All Rights Reserved.