| java.lang.Object org.ofbiz.minerva.pool.jdbc.xa.wrapper.XAResourceImpl
XAResourceImpl | public class XAResourceImpl implements XAResource(Code) | | JTA resource implementation for JDBC 1.0 connections. This is somewhat
limited in two respects. First, it does not support two-phase commits since
JDBC 1.0 does not. It will operate in the presence of two-phase commits, but
will throw heuristic exceptions if there is a failure during a commit or
rollback. Second, it can only be associated with one transaction
at a time, and will throw exceptions if a second transaction tries to
attach before the first has called commit, rollback, or forget.
Warning: This implementation assumes
that forget will be called after a failed commit or rollback. Otherwise,
the database connection will never be closed.
author: Aaron Mulder (ammulder@alumni.princeton.edu) |
Constructor Summary | |
public | XAResourceImpl(Connection con) Creates a new instance as the transactional resource for the specified
underlying connection. |
Method Summary | |
public void | close() Closes this instance permanently. | public void | commit(Xid id, boolean twoPhase) Commits a transaction.
throws: XAException - Occurs when the state was not correct (end never called), thetransaction ID is wrong, the connection was set to Auto-Commit,or the commit on the underlying connection fails. | public void | end(Xid id, int flags) Dissociates a resource from a global transaction. | public void | forget(Xid id) Indicates that no further action will be taken on behalf of this
transaction (after a heuristic failure). | public int | getTransactionTimeout() Gets the transaction timeout. | public XAConnectionImpl | getXAConnection() | public boolean | isSameRM(XAResource res) Since the concept of resource managers does not really apply here (all
JDBC connections must be managed individually), indicates whether the
specified resource is the same as this one. | public boolean | isTransaction() Gets whether there is outstanding work on behalf of a Transaction. | public int | prepare(Xid id) Prepares a transaction to commit. | public Xid[] | recover(int flag) Returns all transaction IDs where work was done with no corresponding
commit, rollback, or forget. | public void | rollback(Xid id) Rolls back the work, assuming it was done on behalf of the specified
transaction.
throws: XAException - Occurs when the state was not correct (end never called), thetransaction ID is wrong, the connection was set to Auto-Commit,or the rollback on the underlying connection fails. | public boolean | setTransactionTimeout(int timeout) Sets the transaction timeout. | void | setXAConnection(XAConnectionImpl xaCon) Sets the XAConnection associated with this XAResource. | public void | start(Xid id, int flags) Associates a JDBC connection with a global transaction. | protected void | throwXAException(int code) | protected void | throwXAException(String msg) |
XAResourceImpl | public XAResourceImpl(Connection con)(Code) | | Creates a new instance as the transactional resource for the specified
underlying connection.
|
close | public void close()(Code) | | Closes this instance permanently.
|
commit | public void commit(Xid id, boolean twoPhase) throws XAException(Code) | | Commits a transaction.
throws: XAException - Occurs when the state was not correct (end never called), thetransaction ID is wrong, the connection was set to Auto-Commit,or the commit on the underlying connection fails. The error codediffers depending on the exact situation. |
end | public void end(Xid id, int flags) throws XAException(Code) | | Dissociates a resource from a global transaction.
throws: XAException - Occurs when the state was not correct (end called twice), or thetransaction ID is wrong. |
forget | public void forget(Xid id) throws XAException(Code) | | Indicates that no further action will be taken on behalf of this
transaction (after a heuristic failure). It is assumed this will be
called after a failed commit or rollback.
throws: XAException - Occurs when the state was not correct (end never called), or thetransaction ID is wrong. |
getTransactionTimeout | public int getTransactionTimeout() throws XAException(Code) | | Gets the transaction timeout.
|
isSameRM | public boolean isSameRM(XAResource res) throws XAException(Code) | | Since the concept of resource managers does not really apply here (all
JDBC connections must be managed individually), indicates whether the
specified resource is the same as this one.
|
isTransaction | public boolean isTransaction()(Code) | | Gets whether there is outstanding work on behalf of a Transaction. If
there is not, then a connection that is closed will cause the
XAConnection to be closed or returned to a pool. If there is, then the
XAConnection must be kept open until commit or rollback is called.
|
prepare | public int prepare(Xid id) throws XAException(Code) | | Prepares a transaction to commit. Since JDBC 1.0 does not support
2-phase commits, this claims the commit is OK (so long as some work was
done on behalf of the specified transaction).
throws: XAException - Occurs when the state was not correct (end never called), thetransaction ID is wrong, or the connection was set to Auto-Commit. |
recover | public Xid[] recover(int flag) throws javax.transaction.xa.XAException(Code) | | Returns all transaction IDs where work was done with no corresponding
commit, rollback, or forget. Not really sure why this is useful in the
context of JDBC drivers.
|
rollback | public void rollback(Xid id) throws XAException(Code) | | Rolls back the work, assuming it was done on behalf of the specified
transaction.
throws: XAException - Occurs when the state was not correct (end never called), thetransaction ID is wrong, the connection was set to Auto-Commit,or the rollback on the underlying connection fails. The error codediffers depending on the exact situation. |
setTransactionTimeout | public boolean setTransactionTimeout(int timeout) throws XAException(Code) | | Sets the transaction timeout. This is saved, but the value is not used
by the current implementation.
|
setXAConnection | void setXAConnection(XAConnectionImpl xaCon)(Code) | | Sets the XAConnection associated with this XAResource. This is required,
but both classes cannot include an instance of the other in their
constructor!
throws: java.lang.IllegalStateException - Occurs when this is called more than once. |
start | public void start(Xid id, int flags) throws XAException(Code) | | Associates a JDBC connection with a global transaction. We assume that
end will be called followed by prepare, commit, or rollback.
If start is called after end but before commit or rollback, there is no
way to distinguish work done by different transactions on the same
connection). If start is called more than once before
end, either it's a duplicate transaction ID or illegal transaction ID
(since you can't have two transactions associated with one DB
connection).
throws: XAException - Occurs when the state was not correct (start called twice), thetransaction ID is wrong, or the instance has already been closed. |
|
|