public class StandardXAConnection extends StandardPooledConnection implements XAConnection, XAResource, Referenceable, Runnable
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.
| Modifier and Type | Field and Description |
|---|---|
StandardXAConnectionHandle |
connectionHandle |
protected StandardXAStatefulConnection |
curCon |
boolean |
thisAutoCommit |
Thread |
timerThread |
TransactionManager |
transactionManager |
protected StandardXADataSource |
xaDataSource |
con, dataSource, logTMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY| Constructor and Description |
|---|
StandardXAConnection(StandardXADataSource dataSource,
String user,
String password)
Creates the first free connection.
|
| Modifier and Type | Method and Description |
|---|---|
StandardXAStatefulConnection |
checkPreparedState(Xid xid)
Does most of the work of a generic prepare.
|
void |
close()
Close this XA connection.
|
void |
commit(Xid xid,
boolean onePhase)
Performs a commit on this resource manager's branch of
the global transaction.
|
void |
doStart(Xid xid,
int flags)
Does most of the work of the start() call (below).
|
void |
end(Xid xid,
int flags)
Ends a connection's association with a global transaction.
|
void |
forget(Xid xid)
This is called by a TM when the RM has reported a heuristic
completion.
|
boolean |
getCommitOnPrepare() |
Connection |
getConnection()
Creates a new StandardXAConnectionHandle for use by an application.
|
Reference |
getReference() |
int |
getTransactionTimeout() |
XAResource |
getXAResource()
We are required to maintain a 1-1 mapping between an XAConnection
and its corresponding XAResource.
|
boolean |
isSameRM(XAResource xares) |
protected void |
newConnectionHandle() |
int |
prepare(Xid xid)
Prepares to perform a commit.
|
Xid[] |
recover(int flag)
Called by the transaction manager during recovery.
|
void |
rollback(Xid xid)
PERFORMS a rollback on this resource manager's branch of
the global transaction.
|
void |
run()
Periodically checks for timed out connections.
|
void |
setCommitOnPrepare(boolean commitOnPrepare) |
void |
setTransactionManager(TransactionManager tm) |
boolean |
setTransactionTimeout(int seconds)
Accessor methods for timeout.
|
void |
start(Xid xid,
int flags)
Associates this XAConnection with a global transaction.
|
String |
toString() |
addConnectionEventListener, addStatementEventListener, connectionErrorOccurred, getPhysicalConnection, removeConnectionEventListener, removeStatementEventListener, setLoggerclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddConnectionEventListener, addStatementEventListener, removeConnectionEventListener, removeStatementEventListenerprotected StandardXAStatefulConnection curCon
public Thread timerThread
public TransactionManager transactionManager
public StandardXAConnectionHandle connectionHandle
protected StandardXADataSource xaDataSource
public boolean thisAutoCommit
public StandardXAConnection(StandardXADataSource dataSource, String user, String password) throws SQLException
SQLExceptionpublic XAResource getXAResource()
getXAResource in interface XAConnectionpublic Connection getConnection() throws SQLException
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.
getConnection in interface PooledConnectiongetConnection in class StandardPooledConnectionSQLExceptionprotected void newConnectionHandle()
newConnectionHandle in class StandardPooledConnectionpublic void setTransactionManager(TransactionManager tm)
public void close()
throws SQLException
close in interface PooledConnectionclose in class StandardPooledConnectionSQLExceptionpublic void doStart(Xid xid, int flags) throws XAException
XAExceptionpublic void start(Xid xid, int flags) throws XAException
start in interface XAResourceXAExceptionpublic void end(Xid xid, int flags) throws XAException
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.
end in interface XAResourceXAExceptionpublic StandardXAStatefulConnection checkPreparedState(Xid xid) throws XAException
XAExceptionpublic int prepare(Xid xid) throws XAException
prepare in interface XAResourceXAExceptionpublic void commit(Xid xid, boolean onePhase) throws XAException
commit in interface XAResourceXAExceptionpublic void rollback(Xid xid) throws XAException
rollback in interface XAResourceXAExceptionpublic boolean isSameRM(XAResource xares) throws XAException
isSameRM in interface XAResourceXAExceptionpublic void forget(Xid xid) throws XAException
forget in interface XAResourceXAExceptionpublic Xid[] recover(int flag) throws XAException
recover in interface XAResourceXAExceptionpublic boolean setTransactionTimeout(int seconds)
setTransactionTimeout in interface XAResourcepublic int getTransactionTimeout()
getTransactionTimeout in interface XAResourcepublic void setCommitOnPrepare(boolean commitOnPrepare)
public boolean getCommitOnPrepare()
public void run()
public Reference getReference() throws NamingException
getReference in interface ReferenceableNamingExceptionpublic String toString()
toString in class StandardPooledConnectionCopyright © 2014–2015. All rights reserved.