Package org.synchronoss.cpo.core.jta
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
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
FieldsModifier and TypeFieldDescriptionstatic final intThe transaction branch is currently associated with a resource manager.static final intThe transaction branch's association has been temporarily suspended.static final intThe transaction branch has no resource manager currently associated with it. -
Constructor Summary
ConstructorsConstructorDescriptionCpoXaState(Xid xid, T resource, int state, CpoBaseXaResource<T> assignedResourceManager, boolean success) Constructs the state for a new transaction branch. -
Method Summary
Modifier and TypeMethodDescriptionGets the resource manager instance currently associated with this branch.intGets the current association state.Gets the underlying resource associated with this branch.getXid()Gets the global transaction identifier for this branch.booleanGets whether this branch has been prepared as part of two-phase commit.booleanGets whether the work done on this branch so far is considered successful.voidsetAssignedResourceManager(CpoBaseXaResource<T> assignedResourceManager) Sets the resource manager instance currently associated with this branch.voidsetAssociation(int association) Sets the association state.voidsetPrepared(boolean prepared) Sets whether this branch has been prepared (voted to commit) as part of two-phase commit.voidsetSuccess(boolean success) Sets whether the work done on this branch so far is considered successful.
-
Field Details
-
XA_UNASSOCIATED
public static final int XA_UNASSOCIATEDThe transaction branch has no resource manager currently associated with it.- See Also:
-
XA_ASSOCIATED
public static final int XA_ASSOCIATEDThe transaction branch is currently associated with a resource manager.- See Also:
-
XA_SUSPENDED
public static final int XA_SUSPENDEDThe 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 branchresource- the underlying resource associated with this branchstate- the initial association state; one ofXA_UNASSOCIATED,XA_ASSOCIATED, orXA_SUSPENDEDassignedResourceManager- the resource manager instance currently associated with this branch, ornullif nonesuccess- whether the work done on this branch so far is considered successful
-
-
Method Details
-
getXid
Gets the global transaction identifier for this branch.- Returns:
- the global transaction identifier for this branch
-
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 ofXA_UNASSOCIATED,XA_ASSOCIATED, orXA_SUSPENDED
-
getAssociation
public int getAssociation()Gets the current association state.- Returns:
- the current association state; one of
XA_UNASSOCIATED,XA_ASSOCIATED, orXA_SUSPENDED
-
setSuccess
public void setSuccess(boolean success) Sets whether the work done on this branch so far is considered successful.- Parameters:
success-trueif successful,falseif the branch has been marked failed
-
isSuccess
public boolean isSuccess()Gets whether the work done on this branch so far is considered successful.- Returns:
trueif 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-trueif prepared,falseotherwise
-
isPrepared
public boolean isPrepared()Gets whether this branch has been prepared as part of two-phase commit.- Returns:
trueif this branch has been prepared as part of two-phase commit
-
getAssignedResourceManager
Gets the resource manager instance currently associated with this branch.- Returns:
- the resource manager instance currently associated with this branch, or
nullif none
-
setAssignedResourceManager
Sets the resource manager instance currently associated with this branch.- Parameters:
assignedResourceManager- the resource manager to associate, ornullto clear the association
-