| java.lang.Object org.enhydra.jdbc.standard.StandardPooledConnection org.enhydra.jdbc.standard.StandardXAConnection
All known Subclasses: org.enhydra.jdbc.instantdb.IdbXAConnection, org.enhydra.jdbc.oracle.OracleXAConnection, org.enhydra.jdbc.sybase.SybaseXAConnection, org.enhydra.jdbc.informix.InformixXAConnection,
StandardXAConnection | public class StandardXAConnection extends StandardPooledConnection implements XAConnection,XAResource,Referenceable,Runnable(Code) | | Provides a generic wrapper for JDBC 1 drivers. JDBC 1 drivers always
associate a single transaction at every point in time with a physical
connection. J2EE drivers, on the other hand, allow an XAResource (and
therefore an XAConnection with which it has a one to one mapping) to
switch between global transactions.
To accomodate this, the StandardXADataSource class maintains a list of
Connection objects. When the Transaction Manager associates an XID
with a StandardXAConnection, it looks for a physical connection which
is associated with that transaction.
The "current" connection (super.con and curCon) is the connection
currently being used by the application (i.e. getConnection has
been called, but not Connection.close()). The current connection
is removed and handed to the data source if it becomes associated
with a global transaction.
|
Method Summary | |
public StandardXAStatefulConnection | checkPreparedState(Xid xid) Does most of the work of a generic prepare. | public synchronized void | close() Close this XA connection. | public synchronized void | commit(Xid xid, boolean onePhase) Performs a commit on this resource manager's branch of
the global transaction. | public synchronized void | doStart(Xid xid, int flags) Does most of the work of the start() call (below). | public synchronized void | end(Xid xid, int flags) Ends a connection's association with a global transaction.
It need not act on the current transaction. | public void | forget(Xid xid) This is called by a TM when the RM has reported a heuristic
completion. | public boolean | getCommitOnPrepare() | public synchronized Connection | getConnection() Creates a new StandardXAConnectionHandle for use by an application.
If there is already an StandardXAConnectionHandle in use then it is
closed (i.e. | public Reference | getReference() | public int | getTransactionTimeout() | public XAResource | getXAResource() We are required to maintain a 1-1 mapping between an XAConnection
and its corresponding XAResource. | public boolean | isSameRM(XAResource xares) | protected void | newConnectionHandle() | public int | prepare(Xid xid) Prepares to perform a commit. | public Xid[] | recover(int flag) Called by the transaction manager during recovery. | public synchronized void | rollback(Xid xid) PERFORMS a rollback on this resource manager's branch of
the global transaction. | public void | run() Periodically checks for timed out connections. | public void | setCommitOnPrepare(boolean commitOnPrepare) | public void | setTransactionManager(TransactionManager tm) | public boolean | setTransactionTimeout(int seconds) Accessor methods for timeout. | public synchronized void | start(Xid xid, int flags) Associates this XAConnection with a global transaction. | public String | toString() |
isClosed | boolean isClosed(Code) | | |
thisAutoCommit | public boolean thisAutoCommit(Code) | | |
transactionManager | public TransactionManager transactionManager(Code) | | |
checkPreparedState | public StandardXAStatefulConnection checkPreparedState(Xid xid) throws XAException(Code) | | Does most of the work of a generic prepare. Kept as a
separate method so that sub-classes can call it and get
the StandardXAStatefulConnection back.
|
commit | public synchronized void commit(Xid xid, boolean onePhase) throws XAException(Code) | | Performs a commit on this resource manager's branch of
the global transaction.
|
doStart | public synchronized void doStart(Xid xid, int flags) throws XAException(Code) | | Does most of the work of the start() call (below). Kept as
a separate method so that subclasses can call it and retain
the curCon property.
|
end | public synchronized void end(Xid xid, int flags) throws XAException(Code) | | Ends a connection's association with a global transaction.
It need not act on the current transaction. There is an
interval between being returned to the pool manager and
being invoked by the transaction manager during which the
current connection can change.
Note that the only effect is to change the connection state.
|
forget | public void forget(Xid xid) throws XAException(Code) | | This is called by a TM when the RM has reported a heuristic
completion. It must retain the transaction context until told
to forget about it.
|
getCommitOnPrepare | public boolean getCommitOnPrepare()(Code) | | |
getConnection | public synchronized Connection getConnection() throws SQLException(Code) | | Creates a new StandardXAConnectionHandle for use by an application.
If there is already an StandardXAConnectionHandle in use then it is
closed (i.e. the application has the connection withdrawn).
This method always returns a Connection in the free state (i.e.
(not associated with an Xid). This is necessary since, unless
Start (Xid, flags) gets called, the Connection must do local
transaction processing.
|
getTransactionTimeout | public int getTransactionTimeout()(Code) | | |
getXAResource | public XAResource getXAResource()(Code) | | We are required to maintain a 1-1 mapping between an XAConnection
and its corresponding XAResource. We achieve this by implementing
both interfaces in the same class.
|
newConnectionHandle | protected void newConnectionHandle()(Code) | | |
prepare | public int prepare(Xid xid) throws XAException(Code) | | Prepares to perform a commit. May actually perform a commit
in the flag commitOnPrepare is set to true.
|
recover | public Xid[] recover(int flag) throws XAException(Code) | | Called by the transaction manager during recovery. If it was the
transaction manager or another compoenent which failed then we
can supply our known Xids. However if we failed then this method
does nothing - we need to know about database internals to do that.
|
rollback | public synchronized void rollback(Xid xid) throws XAException(Code) | | PERFORMS a rollback on this resource manager's branch of
the global transaction.
|
run | public void run()(Code) | | Periodically checks for timed out connections.
|
setCommitOnPrepare | public void setCommitOnPrepare(boolean commitOnPrepare)(Code) | | |
setTransactionManager | public void setTransactionManager(TransactionManager tm)(Code) | | |
setTransactionTimeout | public boolean setTransactionTimeout(int seconds)(Code) | | Accessor methods for timeout.
|
start | public synchronized void start(Xid xid, int flags) throws XAException(Code) | | Associates this XAConnection with a global transaction. This
is the only method which can associate the current connection
with a global transaction. It acts only on the current
connection which must have been previously established using
getConnection.
|
|
|