public class TransactionXaAdapter extends AbstractEnlistmentAdapter implements XAResource
CacheTransaction
and implementor of an XAResource
that will be called by tx manager on various tx stages.config
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
Constructor and Description |
---|
TransactionXaAdapter(LocalXaTransaction localTransaction,
TransactionTable txTable,
RecoveryManager rm,
TransactionCoordinator txCoordinator,
CommandsFactory commandsFactory,
RpcManager rpcManager,
ClusteringDependentLogic clusteringDependentLogic,
Configuration config) |
TransactionXaAdapter(TransactionTable txTable,
RecoveryManager rm,
TransactionCoordinator txCoordinator,
CommandsFactory commandsFactory,
RpcManager rpcManager,
ClusteringDependentLogic clusteringDependentLogic,
Configuration config) |
Modifier and Type | Method and Description |
---|---|
void |
commit(Xid externalXid,
boolean isOnePhase)
Same comment as for
prepare(javax.transaction.xa.Xid) applies for commit. |
void |
end(Xid externalXid,
int i)
Called to disassociate the resource from a transaction.
|
boolean |
equals(Object o) |
void |
forget(Xid externalXid)
Tells the resource manager to forget about a heuristic decision.
|
LocalXaTransaction |
getLocalTransaction() |
int |
getTransactionTimeout()
Get the current transaction timeout value for this resource.
|
boolean |
isSameRM(XAResource xaResource)
the only situation in which it returns true is when the other xa resource pertains to the same cache, on
the same node.
|
int |
prepare(Xid externalXid)
This can be call for any transaction object.
|
Xid[] |
recover(int flag)
Return a list of transactions that are in a prepared or heuristically
state.
|
void |
rollback(Xid externalXid)
Same comment as for
prepare(javax.transaction.xa.Xid) applies for commit. |
boolean |
setTransactionTimeout(int i)
Set the transaction timeout value for this resource.
|
void |
start(Xid externalXid,
int i)
Called to associate the resource with a transaction.
|
String |
toString() |
hashCode, releaseLocksForCompletedTransaction
public TransactionXaAdapter(LocalXaTransaction localTransaction, TransactionTable txTable, RecoveryManager rm, TransactionCoordinator txCoordinator, CommandsFactory commandsFactory, RpcManager rpcManager, ClusteringDependentLogic clusteringDependentLogic, Configuration config)
public TransactionXaAdapter(TransactionTable txTable, RecoveryManager rm, TransactionCoordinator txCoordinator, CommandsFactory commandsFactory, RpcManager rpcManager, ClusteringDependentLogic clusteringDependentLogic, Configuration config)
public int prepare(Xid externalXid) throws XAException
prepare
in interface XAResource
externalXid
- The id of the transaction to prepare to commit work for.XAResource.XA_OK
or XAResource.XA_RDONLY
.XAException
- If an error occurred.public void commit(Xid externalXid, boolean isOnePhase) throws XAException
prepare(javax.transaction.xa.Xid)
applies for commit.commit
in interface XAResource
externalXid
- The id of the transaction to commit work for.isOnePhase
- If true, the transaction manager is using one-phase
optimization.XAException
- If an error occurred.public void rollback(Xid externalXid) throws XAException
prepare(javax.transaction.xa.Xid)
applies for commit.rollback
in interface XAResource
externalXid
- The id of the transaction to commit work for.XAException
- If an error occurred.public void start(Xid externalXid, int i) throws XAException
XAResource
XAResource.TMNOFLAGS
, the transaction must not
previously have been seen by this resource manager, or an
XAException
with error code XAER_DUPID will be thrown.
If the flags argument is XAResource.TMJOIN
, the resource will join a
transaction previously seen by tis resource manager.
If the flags argument is XAResource.TMRESUME
the resource will
resume the transaction association that was suspended with
end(TMSUSPEND).start
in interface XAResource
externalXid
- The id of the transaction to associate with.i
- Must be either XAResource.TMNOFLAGS
, XAResource.TMJOIN
or XAResource.TMRESUME
.XAException
- If an error occurred.public void end(Xid externalXid, int i) throws XAException
XAResource
XAResource.TMSUCCESS
, the portion of work
was done sucessfully.
If the flags argument is XAResource.TMFAIL
, the portion of work
failed. The resource manager may mark the transaction for
rollback only to avoid the transaction being committed.
If the flags argument is XAResource.TMSUSPEND
the resource will
temporarily suspend the transaction association. The transaction
must later be re-associated by giving the XAResource.TMRESUME
flag
to the start
method.end
in interface XAResource
externalXid
- The id of the transaction to disassociate from.i
- Must be either XAResource.TMSUCCESS
, XAResource.TMFAIL
or XAResource.TMSUSPEND
.XAException
- If an error occurred.public void forget(Xid externalXid) throws XAException
XAResource
forget
in interface XAResource
externalXid
- The id of the transaction that was ended with a heuristic
decision.XAException
- If an error occurred.public int getTransactionTimeout() throws XAException
XAResource
getTransactionTimeout
in interface XAResource
XAException
- If an error occurred.public boolean isSameRM(XAResource xaResource) throws XAException
isSameRM
in interface XAResource
XAException
- If an error occurred.public Xid[] recover(int flag) throws XAException
XAResource
A recovery scan is done with one or more calls to this method.
At the first call, XAResource.TMSTARTRSCAN
must be in the
flag
argument to indicate that the scan should be started.
During the recovery scan, the resource manager maintains an internal
cursor that keeps track of the progress of the recovery scan.
To end the recovery scan, the XAResource.TMENDRSCAN
must be passed
in the flag
argument.
recover
in interface XAResource
flag
- Must be either XAResource.TMNOFLAGS
, XAResource.TMSTARTRSCAN
,
XAResource.TMENDRSCAN
or TMSTARTRSCAN|TMENDRSCAN
.XAException
- If an error occurred.public boolean setTransactionTimeout(int i) throws XAException
XAResource
seconds
argument is 0
, the
timeout value is set to the default timeout value of the resource
manager.
Not all resource managers support setting the timeout value.
If the resource manager does not support setting the timeout
value, it should return false.setTransactionTimeout
in interface XAResource
i
- The timeout value, in seconds.XAException
- If an error occurred.public LocalXaTransaction getLocalTransaction()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.