Class CpoXaState<T>

java.lang.Object
org.synchronoss.cpo.core.jta.CpoXaState<T>
Type Parameters:
T - the type of the underlying resource associated with this transaction branch

public class CpoXaState<T> extends Object
Mutable state tracked for a single XA transaction branch (Xid): its association state with a resource manager, its underlying resource, and its success/prepared flags.

Instances are held in the per-subclass state map maintained by CpoBaseXaResource and mutated as the branch progresses through start/end/prepare/commit/rollback.

Author:
dberry
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The transaction branch is currently associated with a resource manager.
    static final int
    The transaction branch's association has been temporarily suspended.
    static final int
    The transaction branch has no resource manager currently associated with it.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CpoXaState(Xid xid, T resource, int state, CpoBaseXaResource<T> assignedResourceManager, boolean success)
    Constructs the state for a new transaction branch.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the resource manager instance currently associated with this branch.
    int
    Gets the current association state.
    Gets the underlying resource associated with this branch.
    Gets the global transaction identifier for this branch.
    boolean
    Gets whether this branch has been prepared as part of two-phase commit.
    boolean
    Gets whether the work done on this branch so far is considered successful.
    void
    Sets the resource manager instance currently associated with this branch.
    void
    setAssociation(int association)
    Sets the association state.
    void
    setPrepared(boolean prepared)
    Sets whether this branch has been prepared (voted to commit) as part of two-phase commit.
    void
    setSuccess(boolean success)
    Sets whether the work done on this branch so far is considered successful.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • XA_UNASSOCIATED

      public static final int XA_UNASSOCIATED
      The transaction branch has no resource manager currently associated with it.
      See Also:
    • XA_ASSOCIATED

      public static final int XA_ASSOCIATED
      The transaction branch is currently associated with a resource manager.
      See Also:
    • XA_SUSPENDED

      public static final int XA_SUSPENDED
      The transaction branch's association has been temporarily suspended.
      See Also:
  • Constructor Details

    • CpoXaState

      public CpoXaState(Xid xid, T resource, int state, CpoBaseXaResource<T> assignedResourceManager, boolean success)
      Constructs the state for a new transaction branch.
      Parameters:
      xid - the global transaction identifier for this branch
      resource - the underlying resource associated with this branch
      state - the initial association state; one of XA_UNASSOCIATED, XA_ASSOCIATED, or XA_SUSPENDED
      assignedResourceManager - the resource manager instance currently associated with this branch, or null if none
      success - whether the work done on this branch so far is considered successful
  • Method Details

    • getXid

      public Xid getXid()
      Gets the global transaction identifier for this branch.
      Returns:
      the global transaction identifier for this branch
    • getResource

      public T getResource()
      Gets the underlying resource associated with this branch.
      Returns:
      the underlying resource associated with this branch
    • setAssociation

      public void setAssociation(int association)
      Sets the association state.
      Parameters:
      association - one of XA_UNASSOCIATED, XA_ASSOCIATED, or XA_SUSPENDED
    • getAssociation

      public int getAssociation()
      Gets the current association state.
      Returns:
      the current association state; one of XA_UNASSOCIATED, XA_ASSOCIATED, or XA_SUSPENDED
    • setSuccess

      public void setSuccess(boolean success)
      Sets whether the work done on this branch so far is considered successful.
      Parameters:
      success - true if successful, false if the branch has been marked failed
    • isSuccess

      public boolean isSuccess()
      Gets whether the work done on this branch so far is considered successful.
      Returns:
      true if the work done on this branch so far is considered successful
    • setPrepared

      public void setPrepared(boolean prepared)
      Sets whether this branch has been prepared (voted to commit) as part of two-phase commit.
      Parameters:
      prepared - true if prepared, false otherwise
    • isPrepared

      public boolean isPrepared()
      Gets whether this branch has been prepared as part of two-phase commit.
      Returns:
      true if this branch has been prepared as part of two-phase commit
    • getAssignedResourceManager

      public CpoBaseXaResource<T> getAssignedResourceManager()
      Gets the resource manager instance currently associated with this branch.
      Returns:
      the resource manager instance currently associated with this branch, or null if none
    • setAssignedResourceManager

      public void setAssignedResourceManager(CpoBaseXaResource<T> assignedResourceManager)
      Sets the resource manager instance currently associated with this branch.
      Parameters:
      assignedResourceManager - the resource manager to associate, or null to clear the association