|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.enhydra.jdbc.standard.StandardPooledConnection
org.enhydra.jdbc.standard.StandardXAConnection
public class StandardXAConnection
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.
| Field Summary | |
|---|---|
StandardXAConnectionHandle |
connectionHandle
|
protected StandardXAStatefulConnection |
curCon
|
boolean |
thisAutoCommit
|
Thread |
timerThread
|
TransactionManager |
transactionManager
|
protected StandardXADataSource |
xaDataSource
|
| Fields inherited from class org.enhydra.jdbc.standard.StandardPooledConnection |
|---|
con, dataSource, log |
| Fields inherited from interface javax.transaction.xa.XAResource |
|---|
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY |
| Constructor Summary | |
|---|---|
StandardXAConnection(StandardXADataSource dataSource,
String user,
String password)
Creates the first free connection. |
|
| Method Summary | |
|---|---|
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()
|
| Methods inherited from class org.enhydra.jdbc.standard.StandardPooledConnection |
|---|
addConnectionEventListener, connectionErrorOccurred, getPhysicalConnection, removeConnectionEventListener, setLogger |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface javax.sql.PooledConnection |
|---|
addConnectionEventListener, addStatementEventListener, removeConnectionEventListener, removeStatementEventListener |
| Field Detail |
|---|
protected StandardXAStatefulConnection curCon
public Thread timerThread
public TransactionManager transactionManager
public StandardXAConnectionHandle connectionHandle
protected StandardXADataSource xaDataSource
public boolean thisAutoCommit
| Constructor Detail |
|---|
public StandardXAConnection(StandardXADataSource dataSource,
String user,
String password)
throws SQLException
SQLException| Method Detail |
|---|
public XAResource getXAResource()
getXAResource in interface XAConnection
public 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 StandardPooledConnectionSQLException
public void doStart(Xid xid,
int flags)
throws XAException
XAException
public void start(Xid xid,
int flags)
throws XAException
start in interface XAResourceXAException
public 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 XAResourceXAException
public StandardXAStatefulConnection checkPreparedState(Xid xid)
throws XAException
XAException
public int prepare(Xid xid)
throws XAException
prepare in interface XAResourceXAException
public void commit(Xid xid,
boolean onePhase)
throws XAException
commit in interface XAResourceXAException
public void rollback(Xid xid)
throws XAException
rollback in interface XAResourceXAException
public boolean isSameRM(XAResource xares)
throws XAException
isSameRM in interface XAResourceXAException
public void forget(Xid xid)
throws XAException
forget in interface XAResourceXAException
public 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()
run in interface Runnable
public Reference getReference()
throws NamingException
getReference in interface ReferenceableNamingExceptionpublic String toString()
toString in class StandardPooledConnection
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||