org.jboss.jca.core.connectionmanager.listener

## Class AbstractConnectionListener

- java.lang.Object
- - org.jboss.jca.core.connectionmanager.listener.AbstractConnectionListener

- All Implemented Interfaces:
    java.lang.Comparable, java.util.EventListener, javax.resource.spi.ConnectionEventListener, org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener, org.jboss.jca.core.spi.transaction.ConnectableResourceListener
  Direct Known Subclasses:
    NoTxConnectionListener, TxConnectionListener

      public abstract class AbstractConnectionListener
      extends java.lang.Object
      implements ConnectionListener, org.jboss.jca.core.spi.transaction.ConnectableResourceListener

  Abstract implementation of the `ConnectionListener` interface contract.
  Author:
    Gurkan Erdogdu, Jesper Pedersen

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.concurrent.CopyOnWriteArraySet<java.lang.Object>` | `connectionHandles` Connection handles
    `protected java.util.Map<java.lang.Object,java.lang.Exception>` | `connectionTraces` Connection traces
    `protected java.lang.Boolean` | `tracking` Tracking

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractConnectionListener(ConnectionManager cm, javax.resource.spi.ManagedConnection managedConnection, Pool pool, ManagedConnectionPool mcp, org.jboss.jca.common.api.metadata.common.FlushStrategy flushStrategy, java.lang.Boolean tracking)` Creates a new instance of the listener that is responsible for tracking the owned connection instance.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compareTo(java.lang.Object o)` Compare
    `void` | `connectionClosed(javax.resource.spi.ConnectionEvent event)`
    `void` | `connectionErrorOccurred(javax.resource.spi.ConnectionEvent event)`
    `boolean` | `controls(javax.resource.spi.ManagedConnection mc, java.lang.Object connection)` Controls the managed connection / connection pair
    `boolean` | `delist()` Delist the managed connection
    `void` | `destroy()` Destroys this connection listener and its managed connection.
    `void` | `dissociate()` Dissociate the connection listener
    `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.
    `java.lang.Exception` | `getException()` Get exception
    `long` | `getLastCheckedOutTime()` Retrieve the last time this connection was obtained from the pool
    `long` | `getLastReturnedTime()` Retrieve the last time this connection was returned to the pool
    `long` | `getLastValidatedTime()` Retrieve the last time this connection was validated.
    `protected abstract CoreLogger` | `getLogger()` Get the logger
    `javax.resource.spi.ManagedConnection` | `getManagedConnection()` Retrieve the managed connection for this listener.
    `ManagedConnectionPool` | `getManagedConnectionPool()` Get the managed connection pool
    `int` | `getNumberOfConnections()` Get number of connection handles
    `Pool` | `getPool()` Retrieve the pool for this listener.
    `ConnectionState` | `getState()` Retrieve the state of this connection.
    `void` | `handleClosed(java.lang.Object h)` Handle closed
    `void` | `handleCreated(java.lang.Object h)` Handle created
    `boolean` | `isEnlisted()` Is enlisted
    `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(java.lang.Object handle)` Register a new connection
    `void` | `setLastCheckedOutTime(long v)` Set the last time this connection was obtained from the pool
    `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
    `boolean` | `supportsLazyAssociation()` Supports lazy association
    `boolean` | `supportsLazyEnlistment()` Supports lazy enlistment
    `void` | `tidyup()` Tidyup Invoked just before returning the connection to the pool when the connection is not being destroyed.
    `void` | `toPool()` Mark the connection as in pool
    `java.lang.String` | `toString()`
    `protected void` | `toString(java.lang.StringBuffer buffer)` Add specific properties.
    `void` | `unregisterConnection(java.lang.Object handle)` Unregister a connection
    `void` | `unregisterConnections()` Unregister connections.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### connectionHandles

          protected java.util.concurrent.CopyOnWriteArraySet<java.lang.Object> connectionHandles

      Connection handles

    - #### connectionTraces

          protected java.util.Map<java.lang.Object,java.lang.Exception> connectionTraces

      Connection traces

    - #### tracking

          protected java.lang.Boolean tracking

      Tracking

  - ### Constructor Detail

    - #### AbstractConnectionListener

          protected AbstractConnectionListener(ConnectionManager cm,
                                               javax.resource.spi.ManagedConnection managedConnection,
                                               Pool pool,
                                               ManagedConnectionPool mcp,
                                               org.jboss.jca.common.api.metadata.common.FlushStrategy flushStrategy,
                                               java.lang.Boolean tracking)

      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
        `mcp` - managed connection pool
        `flushStrategy` - flushStrategy
        `tracking` - tracking

  - ### 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

    - #### getNumberOfConnections

          public int getNumberOfConnections()

      Get number of connection handles
      Returns:
        The value

    - #### isEnlisted

          public boolean isEnlisted()

      Is enlisted
      Returns:
        True if enlisted, otherwise false

    - #### delist

          public boolean delist()
                         throws javax.resource.ResourceException

      Delist the managed connection
      Returns:
        `True` if the listener was delisted succesfully, otherwise `false`
      Throws:
        `javax.resource.ResourceException` - if exception occurs

    - #### enlist

          public void enlist()
                      throws javax.transaction.SystemException

      Enlist the managed connection
      Throws:
        `javax.transaction.SystemException` - for errors

    - #### getManagedConnectionPool

          public ManagedConnectionPool getManagedConnectionPool()

      Get the managed connection pool
      Returns:
        The value

    - #### getLastValidatedTime

          public long getLastValidatedTime()

      Retrieve the last time this connection was validated.
      Returns:
        the last time the connection was validated

    - #### getLastReturnedTime

          public long getLastReturnedTime()

      Retrieve the last time this connection was returned to the pool
      Returns:
        the last time the connection was returned to the pool

    - #### getLastCheckedOutTime

          public long getLastCheckedOutTime()

      Retrieve the last time this connection was obtained from the pool
      Returns:
        the last time the connection was obtained from the pool

    - #### setLastCheckedOutTime

          public void setLastCheckedOutTime(long v)

      Set the last time this connection was obtained from the pool
      Parameters:
        `v` - The value

    - #### getManagedConnection

          public javax.resource.spi.ManagedConnection getManagedConnection()

      Retrieve the managed connection for this listener.
      Specified by:
        `getManagedConnection` in interface `org.jboss.jca.core.api.connectionmanager.listener.ConnectionListener`
      Returns:
        the managed connection

    - #### 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(java.lang.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(java.lang.Object handle)

      Unregister a connection
      Parameters:
        `handle` - the connection handle

    - #### unregisterConnections

          public void unregisterConnections()

      Unregister connections.

    - #### toPool

          public void toPool()

      Mark the connection as in pool

    - #### 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`

    - #### getException

          public java.lang.Exception getException()

      Get exception
      Returns:
        The exception that occured, or `null`

    - #### controls

          public boolean controls(javax.resource.spi.ManagedConnection mc,
                                  java.lang.Object connection)

      Controls the managed connection / connection pair
      Parameters:
        `mc` - The managed connection
        `connection` - The connection; optional
      Returns:
        True if the connection listener controls the pair, otherwise false

    - #### dissociate

          public void dissociate()
                          throws javax.resource.ResourceException

      Dissociate the connection listener
      Throws:
        `javax.resource.ResourceException` - if exception occurs

    - #### supportsLazyAssociation

          public boolean supportsLazyAssociation()

      Supports lazy association
      Returns:
        `True` if supported, otherwise `false`

    - #### supportsLazyEnlistment

          public boolean supportsLazyEnlistment()

      Supports lazy enlistment
      Returns:
        `True` if supported, otherwise `false`

    - #### 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`

    - #### handleCreated

          public void handleCreated(java.lang.Object h)

      Handle created
      Specified by:
        `handleCreated` in interface `org.jboss.jca.core.spi.transaction.ConnectableResourceListener`
      Parameters:
        `h` - The handle

    - #### handleClosed

          public void handleClosed(java.lang.Object h)

      Handle closed
      Specified by:
        `handleClosed` in interface `org.jboss.jca.core.spi.transaction.ConnectableResourceListener`
      Parameters:
        `h` - The handle

    - #### destroy

          public void destroy()

      Destroys this connection listener and its managed connection.

    - #### compareTo

          public int compareTo(java.lang.Object o)

      Compare
      Specified by:
        `compareTo` in interface `java.lang.Comparable`
      Parameters:
        `o` - The other object
      Returns:
        0 if equal; -1 if less than based on lastReturned; otherwise 1

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

    - #### toString

          protected void toString(java.lang.StringBuffer buffer)

      Add specific properties.
      Parameters:
        `buffer` - buffer instance

Copyright © 2014 IronJacamar (http://www.ironjacamar.org)