org.jboss.jca.core.connectionmanager.listener
Class AbstractConnectionListener

java.lang.Object
  extended by org.jboss.jca.core.connectionmanager.listener.AbstractConnectionListener
All Implemented Interfaces:
Comparable, EventListener, javax.resource.spi.ConnectionEventListener, org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener
Direct Known Subclasses:
NoTxConnectionListener, TxConnectionListener

public abstract class AbstractConnectionListener
extends Object
implements ConnectionListener

Abstract implementation of the ConnectionListener interface contract.

Version:
$Rev: $
Author:
Gurkan Erdogdu

Field Summary
protected  boolean trace
          Log trace
 
Constructor Summary
protected AbstractConnectionListener(ConnectionManager cm, javax.resource.spi.ManagedConnection managedConnection, Pool pool, Object context, org.jboss.jca.common.api.metadata.common.FlushStrategy flushStrategy)
          Creates a new instance of the listener that is responsible for tracking the owned connection instance.
 
Method Summary
 int compareTo(Object o)
          Compare
 void connectionClosed(javax.resource.spi.ConnectionEvent event)
          
 void connectionErrorOccurred(javax.resource.spi.ConnectionEvent event)
          
 void delist()
          Delist the managed connection
 void enlist()
          Enlist the managed connection
protected  org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager getCachedConnectionManager()
          Gets cached connection manager
protected  ConnectionManager getConnectionManager()
          Gets connection manager.
 Object getContext()
          Retrieve the context used by the pool.
 long getLastValidatedTime()
          Retrieve the last time this connection was validated.
protected abstract  CoreLogger getLogger()
          Get the logger
 javax.resource.spi.ManagedConnection getManagedConnection()
          
 Pool getPool()
          Retrieve the pool for this listener.
 ConnectionState getState()
          Retrieve the state of this connection.
 boolean isManagedConnectionFree()
          Is the managed connection free?
 boolean isTimedOut(long timeout)
          Has the connection timed out?
 boolean isTrackByTx()
          Get whether the listener is track by transaction
 void localTransactionCommitted(javax.resource.spi.ConnectionEvent event)
          
 void localTransactionRolledback(javax.resource.spi.ConnectionEvent event)
          
 void localTransactionStarted(javax.resource.spi.ConnectionEvent event)
          
 void registerConnection(Object handle)
          Register a new connection
 void setLastValidatedTime(long lastValidated)
          Set the last time, in milliseconds, that this connection was validated.
 void setState(ConnectionState newState)
          Set the state of this connection.
 void setTrackByTx(boolean trackByTx)
          Set whether the listener is track by transaction
 void tidyup()
          Tidyup
 String toString()
          
protected  void toString(StringBuffer buffer)
          Add specific properties.
 void unregisterConnection(Object handle)
          Unregister a connection
protected  void unregisterConnections()
          Unregister connections.
 void used()
          Mark the connection as used
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

trace

protected boolean trace
Log trace

Constructor Detail

AbstractConnectionListener

protected AbstractConnectionListener(ConnectionManager cm,
                                     javax.resource.spi.ManagedConnection managedConnection,
                                     Pool pool,
                                     Object context,
                                     org.jboss.jca.common.api.metadata.common.FlushStrategy flushStrategy)
Creates a new instance of the listener that is responsible for tracking the owned connection instance.

Parameters:
cm - connection manager
managedConnection - managed connection
pool - pool
context - pool internal context
flushStrategy - flushStrategy
Method Detail

getCachedConnectionManager

protected org.jboss.jca.core.api.connectionmanager.ccm.CachedConnectionManager getCachedConnectionManager()
Gets cached connection manager

Returns:
cached connection manager

getConnectionManager

protected ConnectionManager getConnectionManager()
Gets connection manager.

Returns:
connection manager

getLogger

protected abstract CoreLogger getLogger()
Get the logger

Returns:
The value

delist

public void delist()
            throws javax.resource.ResourceException
Delist the managed connection

Throws:
javax.resource.ResourceException - if exception occurs

enlist

public void enlist()
            throws SystemException
Enlist the managed connection

Throws:
SystemException - for errors

getContext

public Object getContext()
Retrieve the context used by the pool.

Returns:
the context

getLastValidatedTime

public long getLastValidatedTime()
Retrieve the last time this connection was validated.

Returns:
the last time the connection was validated

getManagedConnection

public javax.resource.spi.ManagedConnection getManagedConnection()

Specified by:
getManagedConnection in interface org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener

getPool

public Pool getPool()
Retrieve the pool for this listener.

Returns:
the pool

getState

public ConnectionState getState()
Retrieve the state of this connection.

Returns:
the state

isManagedConnectionFree

public boolean isManagedConnectionFree()
Is the managed connection free?

Returns:
true when it is free

isTimedOut

public boolean isTimedOut(long timeout)
Has the connection timed out?

Parameters:
timeout - the timeout
Returns:
true for timed out, false otherwise

isTrackByTx

public boolean isTrackByTx()
Get whether the listener is track by transaction

Returns:
true for track by transaction, false otherwise

registerConnection

public void registerConnection(Object handle)
Register a new connection

Parameters:
handle - the connection handle

setLastValidatedTime

public void setLastValidatedTime(long lastValidated)
Set the last time, in milliseconds, that this connection was validated.

Parameters:
lastValidated - the last time the connection was validated in milliseconds.

setState

public void setState(ConnectionState newState)
Set the state of this connection.

Parameters:
newState - new state

setTrackByTx

public void setTrackByTx(boolean trackByTx)
Set whether the listener is track by transaction

Parameters:
trackByTx - true for track by transaction, false otherwise

tidyup

public void tidyup()
            throws javax.resource.ResourceException
Tidyup

Invoked just before returning the connection to the pool when the connection is not being destroyed.

Throws:
javax.resource.ResourceException - for any error

unregisterConnection

public void unregisterConnection(Object handle)
Unregister a connection

Parameters:
handle - the connection handle

unregisterConnections

protected void unregisterConnections()
Unregister connections.


used

public void used()
Mark the connection as used


connectionClosed

public void connectionClosed(javax.resource.spi.ConnectionEvent event)

Specified by:
connectionClosed in interface javax.resource.spi.ConnectionEventListener

connectionErrorOccurred

public void connectionErrorOccurred(javax.resource.spi.ConnectionEvent event)

Specified by:
connectionErrorOccurred in interface javax.resource.spi.ConnectionEventListener

localTransactionCommitted

public void localTransactionCommitted(javax.resource.spi.ConnectionEvent event)

Specified by:
localTransactionCommitted in interface javax.resource.spi.ConnectionEventListener

localTransactionRolledback

public void localTransactionRolledback(javax.resource.spi.ConnectionEvent event)

Specified by:
localTransactionRolledback in interface javax.resource.spi.ConnectionEventListener

localTransactionStarted

public void localTransactionStarted(javax.resource.spi.ConnectionEvent event)

Specified by:
localTransactionStarted in interface javax.resource.spi.ConnectionEventListener

compareTo

public int compareTo(Object o)
Compare

Specified by:
compareTo in interface Comparable
Parameters:
o - The other object
Returns:
0 if equal; -1 if less than based on lastUse; otherwise 1

toString

public String toString()

Overrides:
toString in class Object

toString

protected void toString(StringBuffer buffer)
Add specific properties.

Parameters:
buffer - buffer instance


Copyright © 2008 Red Hat Middleware LLC (http://www.jboss.com/)