tyrex.resource.jdbc.xa
Class XAConnectionImpl
java.lang.Object
|
+--tyrex.resource.jdbc.xa.XAConnectionImpl
- All Implemented Interfaces:
- javax.sql.PooledConnection, javax.sql.XAConnection, javax.transaction.xa.XAResource
- public final class XAConnectionImpl
- extends java.lang.Object
- implements javax.sql.XAConnection, javax.transaction.xa.XAResource
Implements an X/A connection that can be pooled and managed from
inside a transaction monitor. This is the XA connection returned
to the application server from the XADataSourceImpl
and
will be used to obtain ClientConnection
for the
application.
If the transaction is managed through the JDBC interface, this
connection will reference the underlying JDBC connection directly.
If this resource is enlisted with a global transaction through
the XAResource
interface, it will reference a transactional
connection, or TxConnection
. Such a connection may be
shared by two or more XA connections enlisted with the same
transaction.
- Version:
- 1.0
- Author:
- Assaf Arkin
- See Also:
ClientConnection
,
ConnectionEventListener
,
TxConnection
Field Summary |
(package private) java.sql.Connection |
_underlying
This is the underlying JDBC connection represented
by this pooled connection. |
Fields inherited from interface javax.transaction.xa.XAResource |
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY |
Constructor Summary |
(package private) |
XAConnectionImpl(XADataSourceImpl resManager,
java.sql.Connection underlying,
java.lang.String userName,
java.lang.String password)
Construct a new XA/pooled connection with the underlying JDBC
connection suitable for this driver only. |
Methods inherited from class java.lang.Object |
, clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
_underlying
java.sql.Connection _underlying
- This is the underlying JDBC connection represented
by this pooled connection. This variable may initially be null,
in which case
getUnderlying(int)
will return a new
connection and set this variable. This variable is mutually
exclusive with #_txConn
and is always null for
connections inside a transaction.
XAConnectionImpl
XAConnectionImpl(XADataSourceImpl resManager,
java.sql.Connection underlying,
java.lang.String userName,
java.lang.String password)
throws java.sql.SQLException
- Construct a new XA/pooled connection with the underlying JDBC
connection suitable for this driver only. This is a one to one
mapping between this connection and the underlying connection.
The underlying connection is provided for pooled
connections. XA connections are suspect of being enlisted with
a global transaction which might already bear an underlying
connection. If not, one will be created later on.
- Parameters:
resManager
- the resource manager for the underlying
connectionsunderlying
- the underlying connection. Can be null.userName
- the user name for the underlying connection.
Can be null.password
- the password for the underlying connection.
Can be null.
close
public void close()
throws java.sql.SQLException
- Specified by:
close
in interface javax.sql.PooledConnection
getXAResource
public javax.transaction.xa.XAResource getXAResource()
- Specified by:
getXAResource
in interface javax.sql.XAConnection
addConnectionEventListener
public void addConnectionEventListener(javax.sql.ConnectionEventListener listener)
- Specified by:
addConnectionEventListener
in interface javax.sql.PooledConnection
removeConnectionEventListener
public void removeConnectionEventListener(javax.sql.ConnectionEventListener listener)
- Specified by:
removeConnectionEventListener
in interface javax.sql.PooledConnection
getConnection
public java.sql.Connection getConnection()
throws java.sql.SQLException
- Specified by:
getConnection
in interface javax.sql.PooledConnection
notifyClose
void notifyClose(int clientId)
- Called by
ClientConnection
to notify that the application
has attempted to close the connection. After this call, the client
connection is no longer useable and this pooled connection can be
reused. The event listener is notified immediately.
- Parameters:
clientId
- The ClientConnection
identifier
notifyError
void notifyError(int clientId,
java.sql.SQLException except)
- Called by
ClientConnection
to notify that an error
occured with the underlying connection. If the error is
critical, the underlying connection is closed and the listener
is notified.
- Parameters:
clientId
- The ClientConnection
identifierexcept
- The exception raised by the underlying connection
finalize
protected void finalize()
throws java.lang.Throwable
- Overrides:
finalize
in class java.lang.Object
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
start
public void start(javax.transaction.xa.Xid xid,
int flags)
throws javax.transaction.xa.XAException
- Specified by:
start
in interface javax.transaction.xa.XAResource
end
public void end(javax.transaction.xa.Xid xid,
int flags)
throws javax.transaction.xa.XAException
- Specified by:
end
in interface javax.transaction.xa.XAResource
forget
public void forget(javax.transaction.xa.Xid xid)
throws javax.transaction.xa.XAException
- Specified by:
forget
in interface javax.transaction.xa.XAResource
prepare
public int prepare(javax.transaction.xa.Xid xid)
throws javax.transaction.xa.XAException
- Specified by:
prepare
in interface javax.transaction.xa.XAResource
recover
public javax.transaction.xa.Xid[] recover(int flags)
throws javax.transaction.xa.XAException
- Specified by:
recover
in interface javax.transaction.xa.XAResource
commit
public void commit(javax.transaction.xa.Xid xid,
boolean onePhase)
throws javax.transaction.xa.XAException
- Specified by:
commit
in interface javax.transaction.xa.XAResource
rollback
public void rollback(javax.transaction.xa.Xid xid)
throws javax.transaction.xa.XAException
- Specified by:
rollback
in interface javax.transaction.xa.XAResource
isSameRM
public boolean isSameRM(javax.transaction.xa.XAResource xaRes)
throws javax.transaction.xa.XAException
- Specified by:
isSameRM
in interface javax.transaction.xa.XAResource
setTransactionTimeout
public boolean setTransactionTimeout(int seconds)
throws javax.transaction.xa.XAException
- Specified by:
setTransactionTimeout
in interface javax.transaction.xa.XAResource
getTransactionTimeout
public int getTransactionTimeout()
- Specified by:
getTransactionTimeout
in interface javax.transaction.xa.XAResource
insideGlobalTx
boolean insideGlobalTx()
- Returns true if this connection is inside a global transaction.
If the connection is inside a global transaction it will not
allow commit/rollback directly from the
Connection
interface.
getUnderlying
java.sql.Connection getUnderlying(int clientId)
throws java.sql.SQLException
- Called to obtain the underlying connections. If this connection
is part of a transaction, the transction's underlying connection
is returned, or an exception is thrown if the connection was
terminated due to timeout. If this connection is not part of a
transaction, a non-transactional connection is returned.
- Parameters:
clientId
- The ClientConnection
identifier
Intalio Inc. (C) 1999-2001. All rights reserved.