com.atomikos.jdbc
Class ExternalXAPooledConnectionImp

java.lang.Object
  extended by com.atomikos.jdbc.ExternalXAPooledConnectionImp
All Implemented Interfaces:
DTPPooledConnection, XPooledConnection, EventListener, ConnectionEventListener, PooledConnection
Direct Known Subclasses:
ExclusiveExternalXAPooledConnectionImp

public class ExternalXAPooledConnectionImp
extends Object
implements DTPPooledConnection, ConnectionEventListener

An implementation of a DTPPooledConnection that can be managed by internal as well as external pools.


Field Summary
protected  Connection connectionProxy_
           
protected  Date creationTime_
           
protected  boolean discarded_
           
protected  boolean invalidated_
           
protected  Date lastUse_
           
protected  Vector listeners_
           
protected  PrintWriter logWriter_
           
protected  HeuristicMessage msg_
           
protected  XAConnection myConn_
           
protected  TransactionalResource resource_
           
protected  XAResourceTransaction restx_
           
 
Constructor Summary
  ExternalXAPooledConnectionImp(XAConnection c, TransactionalResource resource)
           
protected ExternalXAPooledConnectionImp(XAConnection c, TransactionalResource resource, PrintWriter logWriter)
           
 
Method Summary
 void addConnectionEventListener(ConnectionEventListener l)
           
 void close()
          Closes the underlying connection for keeps.
 void connectionClosed(ConnectionEvent e)
           
 void connectionErrorOccurred(ConnectionEvent e)
           
 Connection getConnection()
          To get the connection to work with.
 Connection getConnection(HeuristicMessage msg)
          Get a connection with a given heuristic message.
 boolean getInvalidated()
           
 Date getLastUse()
          For pool management .
 TransactionalResource getTransactionalResource()
          Get the transactional resource for this connection.
 boolean isDiscarded()
          Tests if the connection can be put back into the pool.
 boolean isInResourceTransaction()
          Test if the connection is currently associated with a resource transaction.
 void removeConnectionEventListener(ConnectionEventListener l)
           
protected  void setDiscarded()
           
 void setInvalidated()
           
 void setLastUse(Date date)
          For pool management reasons.
 void setResourceTransaction(ResourceTransaction restx)
          Associate a resource transaction with this connection.
protected static void suspendResourceTransaction(ResourceTransaction restx)
           
 String toString()
           
 ResourceTransaction unsetResourceTransaction()
          Unsets the resource transaction property for this connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

lastUse_

protected Date lastUse_

myConn_

protected XAConnection myConn_

listeners_

protected Vector listeners_

invalidated_

protected boolean invalidated_

creationTime_

protected Date creationTime_

discarded_

protected boolean discarded_

resource_

protected TransactionalResource resource_

restx_

protected XAResourceTransaction restx_

logWriter_

protected PrintWriter logWriter_

msg_

protected HeuristicMessage msg_

connectionProxy_

protected Connection connectionProxy_
Constructor Detail

ExternalXAPooledConnectionImp

public ExternalXAPooledConnectionImp(XAConnection c,
                                     TransactionalResource resource)

ExternalXAPooledConnectionImp

protected ExternalXAPooledConnectionImp(XAConnection c,
                                        TransactionalResource resource,
                                        PrintWriter logWriter)
Method Detail

suspendResourceTransaction

protected static void suspendResourceTransaction(ResourceTransaction restx)

toString

public String toString()
Specified by:
toString in interface XPooledConnection
Overrides:
toString in class Object

getTransactionalResource

public TransactionalResource getTransactionalResource()
Description copied from interface: DTPPooledConnection
Get the transactional resource for this connection.

Specified by:
getTransactionalResource in interface DTPPooledConnection
Returns:
TransactionalResource The resource to which this connection belongs.

setResourceTransaction

public void setResourceTransaction(ResourceTransaction restx)
                            throws SQLException
Description copied from interface: DTPPooledConnection
Associate a resource transaction with this connection. After returning, the resource transaction should be ready for resume() calls.

Specified by:
setResourceTransaction in interface DTPPooledConnection
Parameters:
restx - The resource transaction to be associated with this connection.
Throws:
SQLException - If a SQL error occurs.

unsetResourceTransaction

public ResourceTransaction unsetResourceTransaction()
Description copied from interface: DTPPooledConnection
Unsets the resource transaction property for this connection. Called to dissociate the connection with a resourcetransaction.

Specified by:
unsetResourceTransaction in interface DTPPooledConnection
Returns:
ResourceTransaction The resource transaction associated with the connection, or null if none.

getConnection

public Connection getConnection()
                         throws SQLException
To get the connection to work with.

Specified by:
getConnection in interface XPooledConnection
Specified by:
getConnection in interface PooledConnection
Returns:
Connection The connection to work on. Any statement that is created will have a default timeout of 60 seconds. It is recommended that a timeout is used in any case, in order to avoid blocking rollbacks!
Throws:
SQLException

setInvalidated

public void setInvalidated()
Specified by:
setInvalidated in interface XPooledConnection

getInvalidated

public boolean getInvalidated()
Specified by:
getInvalidated in interface XPooledConnection

close

public void close()
           throws SQLException
Description copied from interface: XPooledConnection
Closes the underlying connection for keeps.

Specified by:
close in interface XPooledConnection
Specified by:
close in interface PooledConnection
Throws:
SQLException

addConnectionEventListener

public void addConnectionEventListener(ConnectionEventListener l)
Specified by:
addConnectionEventListener in interface PooledConnection

removeConnectionEventListener

public void removeConnectionEventListener(ConnectionEventListener l)
Specified by:
removeConnectionEventListener in interface PooledConnection

setLastUse

public void setLastUse(Date date)
Description copied from interface: XPooledConnection
For pool management reasons.

Specified by:
setLastUse in interface XPooledConnection

getLastUse

public Date getLastUse()
Description copied from interface: XPooledConnection
For pool management .

Specified by:
getLastUse in interface XPooledConnection

isDiscarded

public boolean isDiscarded()
Description copied from interface: DTPPooledConnection
Tests if the connection can be put back into the pool. Some implementations of reusable connections may not be fully compliant, in that an application-level close() does not automatically imply that the connection can be reused. This function tests if the connection can be reused.

Specified by:
isDiscarded in interface DTPPooledConnection
Returns:
boolean True iff the connection will NOT be used again by the current client. As a consequence, it can be put back into the pool or replaced, whichever the pool instance prefers.

setDiscarded

protected void setDiscarded()

connectionClosed

public void connectionClosed(ConnectionEvent e)
Specified by:
connectionClosed in interface ConnectionEventListener

connectionErrorOccurred

public void connectionErrorOccurred(ConnectionEvent e)
Specified by:
connectionErrorOccurred in interface ConnectionEventListener

getConnection

public Connection getConnection(HeuristicMessage msg)
                         throws SQLException
Description copied from interface: DTPPooledConnection
Get a connection with a given heuristic message.

Specified by:
getConnection in interface DTPPooledConnection
Parameters:
msg - The message to include in the tx logs.
Returns:
Connection The connection to use.
Throws:
SQLException
See Also:
DTPPooledConnection.getConnection(com.atomikos.icatch.HeuristicMessage)

isInResourceTransaction

public boolean isInResourceTransaction()
Description copied from interface: DTPPooledConnection
Test if the connection is currently associated with a resource transaction.

Specified by:
isInResourceTransaction in interface DTPPooledConnection
Returns:
boolean True iff in a transaction.
See Also:
DTPPooledConnection.isInResourceTransaction()


Copyright © 2011. All Rights Reserved.