|
||||||||||||
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
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
|
java.lang.Thread |
timerThread
|
javax.transaction.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,
java.lang.String user,
java.lang.String password)
Creates the first free connection. |
Method Summary | |
---|---|
StandardXAStatefulConnection |
checkPreparedState(javax.transaction.xa.Xid xid)
Does most of the work of a generic prepare. |
void |
close()
Close this XA connection. |
void |
commit(javax.transaction.xa.Xid xid,
boolean onePhase)
Performs a commit on this resource manager's branch of the global transaction. |
void |
doStart(javax.transaction.xa.Xid xid,
int flags)
Does most of the work of the start() call (below). |
void |
end(javax.transaction.xa.Xid xid,
int flags)
Ends a connection's association with a global transaction. |
void |
forget(javax.transaction.xa.Xid xid)
This is called by a TM when the RM has reported a heuristic completion. |
boolean |
getCommitOnPrepare()
|
java.sql.Connection |
getConnection()
Creates a new StandardXAConnectionHandle for use by an application. |
javax.naming.Reference |
getReference()
|
int |
getTransactionTimeout()
|
javax.transaction.xa.XAResource |
getXAResource()
We are required to maintain a 1-1 mapping between an XAConnection and its corresponding XAResource. |
boolean |
isSameRM(javax.transaction.xa.XAResource xares)
|
protected void |
newConnectionHandle()
|
int |
prepare(javax.transaction.xa.Xid xid)
Prepares to perform a commit. |
javax.transaction.xa.Xid[] |
recover(int flag)
Called by the transaction manager during recovery. |
void |
rollback(javax.transaction.xa.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(javax.transaction.TransactionManager tm)
|
boolean |
setTransactionTimeout(int seconds)
Accessor methods for timeout. |
void |
start(javax.transaction.xa.Xid xid,
int flags)
Associates this XAConnection with a global transaction. |
java.lang.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, removeConnectionEventListener |
Field Detail |
protected StandardXAStatefulConnection curCon
public java.lang.Thread timerThread
public javax.transaction.TransactionManager transactionManager
public StandardXAConnectionHandle connectionHandle
protected StandardXADataSource xaDataSource
public boolean thisAutoCommit
Constructor Detail |
public StandardXAConnection(StandardXADataSource dataSource, java.lang.String user, java.lang.String password) throws java.sql.SQLException
Method Detail |
public javax.transaction.xa.XAResource getXAResource()
getXAResource
in interface javax.sql.XAConnection
public java.sql.Connection getConnection() throws java.sql.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 javax.sql.PooledConnection
getConnection
in class StandardPooledConnection
java.sql.SQLException
protected void newConnectionHandle()
newConnectionHandle
in class StandardPooledConnection
public void setTransactionManager(javax.transaction.TransactionManager tm)
public void close() throws java.sql.SQLException
close
in interface javax.sql.PooledConnection
close
in class StandardPooledConnection
java.sql.SQLException
public void doStart(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.XAException
javax.transaction.xa.XAException
public void start(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.XAException
start
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void end(javax.transaction.xa.Xid xid, int flags) throws javax.transaction.xa.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 javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public StandardXAStatefulConnection checkPreparedState(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
javax.transaction.xa.XAException
public int prepare(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
prepare
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void commit(javax.transaction.xa.Xid xid, boolean onePhase) throws javax.transaction.xa.XAException
commit
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void rollback(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
rollback
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public boolean isSameRM(javax.transaction.xa.XAResource xares) throws javax.transaction.xa.XAException
isSameRM
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public void forget(javax.transaction.xa.Xid xid) throws javax.transaction.xa.XAException
forget
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public javax.transaction.xa.Xid[] recover(int flag) throws javax.transaction.xa.XAException
recover
in interface javax.transaction.xa.XAResource
javax.transaction.xa.XAException
public boolean setTransactionTimeout(int seconds)
setTransactionTimeout
in interface javax.transaction.xa.XAResource
public int getTransactionTimeout()
getTransactionTimeout
in interface javax.transaction.xa.XAResource
public void setCommitOnPrepare(boolean commitOnPrepare)
public boolean getCommitOnPrepare()
public void run()
run
in interface java.lang.Runnable
public javax.naming.Reference getReference() throws javax.naming.NamingException
getReference
in interface javax.naming.Referenceable
javax.naming.NamingException
public java.lang.String toString()
toString
in class StandardPooledConnection
|
||||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |