tyrex.resource.jdbc.xa

Class XAConnectionImpl

public final class XAConnectionImpl extends Object implements XAConnection, 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
Connection_underlying
This is the underlying JDBC connection represented by this pooled connection.
Constructor Summary
XAConnectionImpl(XADataSourceImpl resManager, Connection underlying, String userName, String password)
Construct a new XA/pooled connection with the underlying JDBC connection suitable for this driver only.
Method Summary
voidaddConnectionEventListener(ConnectionEventListener listener)
voidclose()
voidcommit(Xid xid, boolean onePhase)
voidend(Xid xid, int flags)
protected voidfinalize()
voidforget(Xid xid)
ConnectiongetConnection()
intgetTransactionTimeout()
ConnectiongetUnderlying(int clientId)
Called to obtain the underlying connections.
XAResourcegetXAResource()
booleaninsideGlobalTx()
Returns true if this connection is inside a global transaction.
booleanisSameRM(XAResource xaRes)
voidnotifyClose(int clientId)
Called by ClientConnection to notify that the application has attempted to close the connection.
voidnotifyError(int clientId, SQLException except)
Called by ClientConnection to notify that an error occured with the underlying connection.
intprepare(Xid xid)
Xid[]recover(int flags)
voidremoveConnectionEventListener(ConnectionEventListener listener)
voidrollback(Xid xid)
booleansetTransactionTimeout(int seconds)
voidstart(Xid xid, int flags)
StringtoString()

Field Detail

_underlying

Connection _underlying
This is the underlying JDBC connection represented by this pooled connection. This variable may initially be null, in which case XAConnectionImpl 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.

Constructor Detail

XAConnectionImpl

XAConnectionImpl(XADataSourceImpl resManager, Connection underlying, String userName, String password)
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 connections underlying 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.

Method Detail

addConnectionEventListener

public void addConnectionEventListener(ConnectionEventListener listener)

close

public void close()

commit

public void commit(Xid xid, boolean onePhase)

end

public void end(Xid xid, int flags)

finalize

protected void finalize()

forget

public void forget(Xid xid)

getConnection

public Connection getConnection()

getTransactionTimeout

public int getTransactionTimeout()

getUnderlying

Connection getUnderlying(int clientId)
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

getXAResource

public XAResource getXAResource()

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 java.sql.Connection interface.

isSameRM

public boolean isSameRM(XAResource xaRes)

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, 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 identifier except The exception raised by the underlying connection

prepare

public int prepare(Xid xid)

recover

public Xid[] recover(int flags)

removeConnectionEventListener

public void removeConnectionEventListener(ConnectionEventListener listener)

rollback

public void rollback(Xid xid)

setTransactionTimeout

public boolean setTransactionTimeout(int seconds)

start

public void start(Xid xid, int flags)

toString

public String toString()
Original code is Copyright (c) 1999-2001, Intalio, Inc. All Rights Reserved. Contributions by MetaBoss team are Copyright (c) 2003-2005, Softaris Pty. Ltd. All Rights Reserved.