Package bitronix.tm.internal
Class XAResourceManager
java.lang.Object
bitronix.tm.internal.XAResourceManager
Every
BitronixTransaction contains an instance of this class that is used to register
and keep track of resources enlisted in a transaction.- Author:
- lorban
-
Constructor Summary
ConstructorsConstructorDescriptionXAResourceManager(Uid gtrid) Create a resource manager for the specified GTRID. -
Method Summary
Modifier and TypeMethodDescriptionvoidRemove this transaction'sXAResourceHolderStatefrom all enlistedXAResourceHolders.Get aSetof unique names of all the enlistedXAResourceHolderStates.booleandelist(XAResourceHolderState xaResourceHolderState, int flag) Delist the specifiedXAResourceHolderState.voidenlist(XAResourceHolderState xaResourceHolderState) Enlist the specifiedXAResourceHolderState.findXAResourceHolderState(XAResource xaResource) Look if anXAResourcehas already been enlisted.getGtrid()Get the GTRID of the transaction theXAResourceManagerinstance is attached to.getNaturalOrderResourcesForPosition(Integer position) getReverseOrderResourcesForPosition(Integer position) voidresume()Resume all enlisted resources in the current transaction context.intsize()Get the enlisted resources count.voidsuspend()Suspend all enlisted resources from the current transaction context.toString()Return a human-readable representation of this object.
-
Constructor Details
-
XAResourceManager
Create a resource manager for the specified GTRID.- Parameters:
gtrid- the transaction's GTRID this XAResourceManager will be assigned to.
-
-
Method Details
-
enlist
public void enlist(XAResourceHolderState xaResourceHolderState) throws XAException, BitronixSystemException Enlist the specifiedXAResourceHolderState. A XID is generated and the resource is started with XAResource.TMNOFLAGS or XAResource.TMJOIN if it could be joined with another previously enlisted one.
There are 3 different cases that can happen when aXAResourceHolderStateis enlisted:- already enlisted and not ended: do nothing
- already enlisted and ended: try to join. if you can join, keep a reference on the passed-in
XAResourceHolderStateand drop the previous one. if you cannot join, it's the same as case 3 - not enlisted: create a new branch and keep a reference on the passed-in
XAResourceHolderState
- Parameters:
xaResourceHolderState- theXAResourceHolderStateto be enlisted.- Throws:
XAException- if a resource error occured.BitronixSystemException- if an internal error occured.
-
delist
public boolean delist(XAResourceHolderState xaResourceHolderState, int flag) throws XAException, BitronixSystemException Delist the specifiedXAResourceHolderState. A reference to the resource is kept anyway.- Parameters:
xaResourceHolderState- theXAResourceHolderStateto be delisted.flag- the delistment flag.- Returns:
- true if the resource could be delisted, false otherwise.
- Throws:
XAException- if the resource threw an exception during delistment.BitronixSystemException- if an internal error occured.
-
suspend
Suspend all enlisted resources from the current transaction context.- Throws:
XAException- if the resource threw an exception during suspend.
-
resume
Resume all enlisted resources in the current transaction context.- Throws:
XAException- if the resource threw an exception during resume.
-
findXAResourceHolderState
public XAResourceHolderState findXAResourceHolderState(XAResource xaResource) throws BitronixSystemException Look if anXAResourcehas already been enlisted.- Parameters:
xaResource- theXAResourceto look for.- Returns:
- the
XAResourceHolderStateof the enlisted resource or null if theXAResourcehas not been enlisted in thisXAResourceManager. - Throws:
BitronixSystemException- if an internal error happens.
-
clearXAResourceHolderStates
public void clearXAResourceHolderStates()Remove this transaction'sXAResourceHolderStatefrom all enlistedXAResourceHolders. -
collectUniqueNames
Get aSetof unique names of all the enlistedXAResourceHolderStates.- Returns:
- a
Setof unique names of all the enlistedXAResourceHolderStates.
-
getNaturalOrderPositions
-
getReverseOrderPositions
-
getNaturalOrderResourcesForPosition
-
getReverseOrderResourcesForPosition
-
getAllResources
-
size
public int size()Get the enlisted resources count.- Returns:
- the enlisted resources count.
-
getGtrid
Get the GTRID of the transaction theXAResourceManagerinstance is attached to.- Returns:
- the GTRID of the transaction the
XAResourceManagerinstance is attached to.
-
toString
Return a human-readable representation of this object.
-