public class MariaXaResource
extends java.lang.Object
implements javax.transaction.xa.XAResource
Modifier and Type | Field and Description |
---|---|
private MariaDbConnection |
connection |
Constructor and Description |
---|
MariaXaResource(MariaDbConnection connection) |
Modifier and Type | Method and Description |
---|---|
void |
commit(javax.transaction.xa.Xid xid,
boolean onePhase)
Commits the global transaction specified by xid.
|
void |
end(javax.transaction.xa.Xid xid,
int flags)
Ends the work performed on behalf of a transaction branch.
|
private void |
execute(java.lang.String command)
Execute a query.
|
private static java.lang.String |
flagsToString(int flags) |
void |
forget(javax.transaction.xa.Xid xid)
Tells the resource manager to forget about a heuristically completed transaction branch.
|
int |
getTransactionTimeout()
Obtains the current transaction timeout value set for this XAResource instance.
|
boolean |
isSameRM(javax.transaction.xa.XAResource xaResource)
This method is called to determine if the resource manager instance represented by the target
object is the same as the resource manager instance represented by the parameter xares.
|
private javax.transaction.xa.XAException |
mapXaException(java.sql.SQLException sqle) |
int |
prepare(javax.transaction.xa.Xid xid)
Ask the resource manager to prepare for a transaction commit of the transaction specified in
xid.
|
javax.transaction.xa.Xid[] |
recover(int flags)
Obtains a list of prepared transaction branches from a resource manager.
|
void |
rollback(javax.transaction.xa.Xid xid)
Informs the resource manager to roll back work done on behalf of a transaction branch.
|
boolean |
setTransactionTimeout(int timeout)
Sets the current transaction timeout value for this XAResource instance.
|
void |
start(javax.transaction.xa.Xid xid,
int flags)
Starts work on behalf of a transaction branch specified in xid.
|
private static java.lang.String |
xidToString(javax.transaction.xa.Xid xid) |
private final MariaDbConnection connection
public MariaXaResource(MariaDbConnection connection)
private static java.lang.String xidToString(javax.transaction.xa.Xid xid)
private static java.lang.String flagsToString(int flags)
private javax.transaction.xa.XAException mapXaException(java.sql.SQLException sqle)
private void execute(java.lang.String command) throws javax.transaction.xa.XAException
command
- query to run.javax.transaction.xa.XAException
- exceptionpublic void commit(javax.transaction.xa.Xid xid, boolean onePhase) throws javax.transaction.xa.XAException
commit
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifieronePhase
- If true, the resource manager should use a one-phase commit protocol to commit
the work done on behalf of xid.javax.transaction.xa.XAException
- exceptionpublic void end(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.XAException
If TMSUSPEND is specified in the flags, the transaction branch is temporarily suspended in an incomplete state. The transaction context is in a suspended state and must be resumed via the start method with TMRESUME specified.
If TMFAIL is specified, the portion of work has failed. The resource manager may mark the transaction as rollback-only
If TMSUCCESS is specified, the portion of work has completed successfully.
end
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifier that is the same as the identifier used previously
in the start method.flags
- One of TMSUCCESS, TMFAIL, or TMSUSPEND.javax.transaction.xa.XAException
- An error has occurred. (XAException values are XAER_RMERR, XAER_RMFAILED,
XAER_NOTA, XAER_INVAL, XAER_PROTO, or XA_RB*)public void forget(javax.transaction.xa.Xid xid)
forget
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifier.public int getTransactionTimeout()
getTransactionTimeout
in interface javax.transaction.xa.XAResource
public boolean isSameRM(javax.transaction.xa.XAResource xaResource)
isSameRM
in interface javax.transaction.xa.XAResource
xaResource
- An XAResource object whose resource manager instance is to be compared with
the target object.public int prepare(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
prepare
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifier.javax.transaction.xa.XAException
- An error has occurred. Possible exception values are: XA_RB*, XAER_RMERR,
XAER_RMFAIL, XAER_NOTA, XAER_INVAL, XAER_PROTO.public javax.transaction.xa.Xid[] recover(int flags) throws javax.transaction.xa.XAException
recover
in interface javax.transaction.xa.XAResource
flags
- One of TMSTARTRSCAN, TMENDRSCAN, TMNOFLAGS. TMNOFLAGS must be used when no other
flags are set in the parameter.javax.transaction.xa.XAException
- An error has occurred. Possible values are XAER_RMERR, XAER_RMFAIL,
XAER_INVAL, and XAER_PROTO.public void rollback(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
rollback
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifier.javax.transaction.xa.XAException
- An error has occurred.public boolean setTransactionTimeout(int timeout)
setTransactionTimeout
in interface javax.transaction.xa.XAResource
timeout
- The transaction timeout value in seconds.public void start(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.XAException
start
in interface javax.transaction.xa.XAResource
xid
- A global transaction identifier to be associated with the resource.flags
- One of TMNOFLAGS, TMJOIN, or TMRESUME.javax.transaction.xa.XAException
- An error has occurred.