|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hsqldb.jdbc.pool.JDBCXAResource
public class JDBCXAResource
Used by a global transaction service to control HSQLDB transactions. Not for use by end-users. End manage global transactions using transaction APIs such as JTA.
According to section 12.3 of the JDBC 3.0 spec, there is a 1:1 correspondence between XAConnection and XAResource, and A given XAConnection object may be associated with at most one transaction at a time. Therefore, there may be at any time at most one transaction managed by a XAResource object. One implication is, the XAResource can track the current transaction state with a scalar. Another implication is, the Xids for most of the XAResource interface methods just introduce unnecessary complexity and an unnecessary point of failure-- there can be only one transaction for this object, so why track another identifier for it. My strategy is to just "validate" that the Xid does not change within a transaction. Exceptions to this are the commit and rollback methods, which the JDBC spec says can operate against any XAResource instance from the same XADataSource. N.b. The JDBC Spec does not state whether the prepare and forget methods are XAResource-specific or XADataSource-specific.
XAResource
Field Summary |
---|
Fields inherited from interface javax.transaction.xa.XAResource |
---|
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY |
Constructor Summary | |
---|---|
JDBCXAResource(JDBCXADataSource xaDataSource,
JDBCConnection connection)
Constructs a resource using the given data source and connection. |
Method Summary | |
---|---|
void |
commit(Xid xid,
boolean onePhase)
Per the JDBC 3.0 spec, this commits the transaction for the specified Xid, not necessarily for the transaction associated with this XAResource object. |
void |
commitThis(boolean onePhase)
This commits the connection associated with this XAResource. |
void |
end(Xid xid,
int flags)
|
void |
forget(Xid xid)
The XAResource API spec indicates implies that this is only for 2-phase transactions. |
int |
getTransactionTimeout()
|
boolean |
isSameRM(XAResource xares)
Stub. |
int |
prepare(Xid xid)
Vote on whether to commit the global transaction. |
int |
prepareThis()
|
Xid[] |
recover(int flag)
Obtain a list of Xids of the current resource manager for XAResources currently in the 'prepared' * state. |
void |
rollback(Xid xid)
Per the JDBC 3.0 spec, this rolls back the transaction for the specified Xid, not necessarily for the transaction associated with this XAResource object. |
void |
rollbackThis()
This rolls back the connection associated with this XAResource. |
boolean |
setTransactionTimeout(int seconds)
|
void |
start(Xid xid,
int flags)
|
boolean |
withinGlobalTransaction()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JDBCXAResource(JDBCXADataSource xaDataSource, JDBCConnection connection)
xaDataSource
- JDBCXADataSourceconnection
- A non-wrapped JDBCConnection which we need in order to
do real (non-wrapped) commits, rollbacks, etc. This is not for the end
user. We need the real thing.Method Detail |
---|
public boolean withinGlobalTransaction()
public void commit(Xid xid, boolean onePhase) throws XAException
commit
in interface XAResource
xid
- XidonePhase
- boolean
XAException
- on errorpublic void commitThis(boolean onePhase) throws XAException
onePhase
- boolean
XAException
- generically, since the more specific exceptions
require a JTA API to compile.public void end(Xid xid, int flags) throws XAException
end
in interface XAResource
XAException
public void forget(Xid xid) throws XAException
forget
in interface XAResource
xid
- Xid
XAException
- on errorXAResource.forget(Xid)
public int getTransactionTimeout() throws XAException
getTransactionTimeout
in interface XAResource
XAException
- on errorpublic boolean isSameRM(XAResource xares) throws XAException
isSameRM
in interface XAResource
xares
- XAResource
XAException
- on errorpublic int prepare(Xid xid) throws XAException
prepare
in interface XAResource
xid
- Xid
XAException
- to vote negative.public int prepareThis() throws XAException
XAException
public Xid[] recover(int flag) throws XAException
recover
in interface XAResource
flag
- int
XAException
- on errorpublic void rollback(Xid xid) throws XAException
rollback
in interface XAResource
xid
- Xid
XAException
- on errorpublic void rollbackThis() throws XAException
XAException
- generically, since the more
specific exceptions require a JTA API to compile.public boolean setTransactionTimeout(int seconds) throws XAException
setTransactionTimeout
in interface XAResource
seconds
- int
XAException
- on errorpublic void start(Xid xid, int flags) throws XAException
start
in interface XAResource
XAException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |