SessionHandleState (Transactions JTA 4.0.6 API)
Date: 2018-01-11

com.atomikos.datasource.xa.session

## Class SessionHandleState

- java.lang.Object
- - com.atomikos.datasource.xa.session.SessionHandleState

-     public class SessionHandleState
      extends java.lang.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

    Constructors
    Constructor and Description
    `SessionHandleState(XATransactionalResource resource, javax.transaction.xa.XAResource xaResource)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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)` 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)`
    `java.lang.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,
                            javax.transaction.xa.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)
                               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.
      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 java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.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 © 2018. All Rights Reserved.