|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jboss.minerva.xa.XAConnectionImpl
A transaction wrapper around a java.sql.Connection. This provides access to an XAResource (there is a one-to-one mapping between XAResource and XAConnection) and a java.sql.Connection (in this implementation, there is also a one-to-one mapping between XAConnection and java.sql.Connection). In order to pool java.sql.Connections in a transactional environment, this is the class that should be pooled - though you could pool the connections, there is no need to create and destroy these wrappers so frequently.
Note that there con only be one transaction at a time accessing one of these wrappers, and requests to a pool for multiple connections on behalf of one transaction should use the same wrapper. This is because there is no distinction between connections and transactions in a java.sql.Connection, and work done by one connection on behalf of a transaction would not be visible to another connection working on behalf of the same transaction - you would have effectively created two transactions.
This also implies that an XAConnection should not be released to a connection pool until the work has been committed or rolled back. However, it must sent the close notification as usual in order to be delisted from the transaction. So the ConnectionEventListener must not release the XAConnection to a pool when it receives the close event. Instead, it should also register a TransactionListener that will be notified when the Transaction is finished, and release the XAConnection at that time.
TransactionListener
Constructor Summary | |
XAConnectionImpl(java.sql.Connection con,
XAResourceImpl resource)
Creates a new transactional wrapper. |
Method Summary | |
void |
addConnectionEventListener(javax.sql.ConnectionEventListener listener)
|
void |
addPoolEventListener(PoolEventListener listener)
Adds a new listener. |
void |
clearTransactionListener()
Clears the transaction listener. |
void |
clientConnectionClosed()
Indicates that the connection given to the client has been closed. |
void |
close()
Shuts down this wrapper (and the underlying Connection) permanently. |
java.sql.Connection |
getConnection()
|
javax.transaction.xa.XAResource |
getXAResource()
|
void |
removeConnectionEventListener(javax.sql.ConnectionEventListener listener)
|
void |
removePoolEventListener(PoolEventListener listener)
Removes a listener. |
void |
rollback()
Rolls back the underlying connection. |
void |
setConnectionError(java.sql.SQLException e)
Indicates that the connection given to the client has had an error. |
void |
setTransactionListener(TransactionListener tl)
Sets the transaction listener. |
void |
transactionFailed()
Indicates that the outstanding transaction has finished with a fatal error, and this object should be closed or permanently removed from a pool. |
void |
transactionFinished()
Indicates that the outstanding transaction has finished and this object can be closed or returned to a pool. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XAConnectionImpl(java.sql.Connection con, XAResourceImpl resource)
con
- The underlying non-transactional Connection.resource
- The transaction resource used to enlist this
connection in a transaction.Method Detail |
public void setTransactionListener(TransactionListener tl)
public void clearTransactionListener()
public void close()
close
in interface javax.sql.PooledConnection
public void clientConnectionClosed()
public void transactionFinished()
addConnectionEventListener(javax.sql.ConnectionEventListener)
public void transactionFailed()
addConnectionEventListener(javax.sql.ConnectionEventListener)
public void setConnectionError(java.sql.SQLException e)
public void rollback() throws java.sql.SQLException
public javax.transaction.xa.XAResource getXAResource()
getXAResource
in interface javax.sql.XAConnection
public void addConnectionEventListener(javax.sql.ConnectionEventListener listener)
addConnectionEventListener
in interface javax.sql.PooledConnection
public void removeConnectionEventListener(javax.sql.ConnectionEventListener listener)
removeConnectionEventListener
in interface javax.sql.PooledConnection
public java.sql.Connection getConnection()
getConnection
in interface javax.sql.PooledConnection
public void addPoolEventListener(PoolEventListener listener)
PooledObject
addPoolEventListener
in interface PooledObject
public void removePoolEventListener(PoolEventListener listener)
PooledObject
removePoolEventListener
in interface PooledObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |