XAResourceManager (Bitronix Transaction Manager :: Core 2.1.4 API)
Date: 2013-09-15

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## bitronix.tm.internal
Class XAResourceManager

    java.lang.Object
      bitronix.tm.internal.XAResourceManager

    public class XAResourceManager

extends Object

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
`XAResourceManager(Uid gtrid)` Create a resource manager for the specified GTRID.

Method Summary
`void` | `clearXAResourceHolderStates()` Remove this transaction's `XAResourceHolderState` from all enlisted `XAResourceHolder`s.
`Set<String>` | `collectUniqueNames()` Get a `Set` of unique names of all the enlisted `XAResourceHolderState`s.
`boolean` | `delist(XAResourceHolderState xaResourceHolderState, int flag)` Delist the specified `XAResourceHolderState`.
`void` | `enlist(XAResourceHolderState xaResourceHolderState)` Enlist the specified `XAResourceHolderState`.
`XAResourceHolderState` | `findXAResourceHolderState(XAResource xaResource)` Look if an `XAResource` has already been enlisted.
`List<XAResourceHolderState>` | `getAllResources()`
`Uid` | `getGtrid()` Get the GTRID of the transaction the `XAResourceManager` instance is attached to.
`SortedSet<Integer>` | `getNaturalOrderPositions()`
`List<XAResourceHolderState>` | `getNaturalOrderResourcesForPosition(Integer position)`
`SortedSet<Integer>` | `getReverseOrderPositions()`
`List<XAResourceHolderState>` | `getReverseOrderResourcesForPosition(Integer position)`
`void` | `resume()` Resume all enlisted resources in the current transaction context.
`int` | `size()` Get the enlisted resources count.
`void` | `suspend()` Suspend all enlisted resources from the current transaction context.
`String` | `toString()` Return a human-readable representation of this object.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### XAResourceManager

    public XAResourceManager(Uid gtrid)

  Create a resource manager for the specified GTRID.

  Parameters:
    `gtrid` - the transaction's GTRID this XAResourceManager will be assigned to.

Method Detail

### enlist

    public void enlist(XAResourceHolderState xaResourceHolderState)
                throws XAException,
                       BitronixSystemException

  Enlist the specified `XAResourceHolderState`. 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 a `XAResourceHolderState` is 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 `XAResourceHolderState` and 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` - the `XAResourceHolderState` to 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 specified `XAResourceHolderState`. A reference to the resource is kept anyway.

  Parameters:
    `xaResourceHolderState` - the `XAResourceHolderState` to 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

    public void suspend()
                 throws XAException

  Suspend all enlisted resources from the current transaction context.

  Throws:
    `XAException` - if the resource threw an exception during suspend.

### resume

    public void resume()
                throws XAException

  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 an `XAResource` has already been enlisted.

  Parameters:
    `xaResource` - the `XAResource` to look for.
  Returns:
    the `XAResourceHolderState` of the enlisted resource or null if the `XAResource` has not been enlisted in this `XAResourceManager`.
  Throws:
    `BitronixSystemException` - if an internal error happens.

### clearXAResourceHolderStates

    public void clearXAResourceHolderStates()

  Remove this transaction's `XAResourceHolderState` from all enlisted `XAResourceHolder`s.

### collectUniqueNames

    public Set<String> collectUniqueNames()

  Get a `Set` of unique names of all the enlisted `XAResourceHolderState`s.

  Returns:
    a `Set` of unique names of all the enlisted `XAResourceHolderState`s.

### getNaturalOrderPositions

    public SortedSet<Integer> getNaturalOrderPositions()

### getReverseOrderPositions

    public SortedSet<Integer> getReverseOrderPositions()

### getNaturalOrderResourcesForPosition

    public List<XAResourceHolderState> getNaturalOrderResourcesForPosition(Integer position)

### getReverseOrderResourcesForPosition

    public List<XAResourceHolderState> getReverseOrderResourcesForPosition(Integer position)

### getAllResources

    public List<XAResourceHolderState> getAllResources()

### size

    public int size()

  Get the enlisted resources count.

  Returns:
    the enlisted resources count.

### getGtrid

    public Uid getGtrid()

  Get the GTRID of the transaction the `XAResourceManager` instance is attached to.

  Returns:
    the GTRID of the transaction the `XAResourceManager` instance is attached to.

### toString

    public String toString()

  Return a human-readable representation of this object.

  Overrides:
    `toString` in class `Object`
  Returns:
    a human-readable representation of this object.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2013 Bitronix Software. All Rights Reserved.