org.ow2.jasmine.adapter.jmx.pool.outbound
Class ManagedConnectionImpl

java.lang.Object
  extended by org.ow2.jasmine.adapter.jmx.pool.outbound.ManagedConnectionImpl
All Implemented Interfaces:
javax.resource.spi.ManagedConnection

public class ManagedConnectionImpl
extends java.lang.Object
implements javax.resource.spi.ManagedConnection

Manager of a connection.

Author:
Guillaume Renault

Constructor Summary
ManagedConnectionImpl(ManagedConnectionFactoryImpl mcfi)
          create a new connection manager.
 
Method Summary
 void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
          Adds a connection event listener to the ManagedConnection instance.
 void associateConnection(java.lang.Object connection)
          Used by the container to change the association of an application-level connection handle with a ManagedConneciton instance.
 void cleanup()
          Application server calls this method to force any cleanup on the ManagedConnection instance.
 void close(JMXConnectionImpl connectionJMX)
          Close the JMX Connection.
 void destroy()
          Destroys the physical connection to the underlying resource manager.
 java.lang.Object getConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
          Creates a new connection handle for the underlying physical connection represented by the ManagedConnection instance.
 ManagedConnectionFactoryImpl getLocalMCFI()
          Get the managed factory on which this manager is associated.
 javax.resource.spi.LocalTransaction getLocalTransaction()
          Not implemented.
 java.io.PrintWriter getLogWriter()
          Not implemented.
 javax.resource.spi.ManagedConnectionMetaData getMetaData()
          Not implemented.
 javax.transaction.xa.XAResource getXAResource()
          Not implemented.
 void release(JMXConnectionImpl connectionJMX)
          Release the JMX connection.
 void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
          Removes an already registered connection event listener from the ManagedConnection instance.
 void setLogWriter(java.io.PrintWriter out)
          Not implemented.
 void signalEvent(int code, java.lang.Object ch)
          Called on event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagedConnectionImpl

public ManagedConnectionImpl(ManagedConnectionFactoryImpl mcfi)
create a new connection manager.

Parameters:
mcfi - the managed factory on which this manager will be associated
Method Detail

getLocalMCFI

public ManagedConnectionFactoryImpl getLocalMCFI()
Get the managed factory on which this manager is associated.

Returns:
the managed factory on which this manager is associated

signalEvent

public void signalEvent(int code,
                        java.lang.Object ch)
Called on event.

Parameters:
code - the code of the event.
ch - the object to handle

release

public void release(JMXConnectionImpl connectionJMX)
Release the JMX connection.

Parameters:
connectionJMX - JMX connection to release

close

public void close(JMXConnectionImpl connectionJMX)
Close the JMX Connection.

Parameters:
connectionJMX - the JMX Connection to close

addConnectionEventListener

public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Adds a connection event listener to the ManagedConnection instance. The registered ConnectionEventListener instances are notified of connection close and error events, also of local transaction related events on the Managed Connection.

Specified by:
addConnectionEventListener in interface javax.resource.spi.ManagedConnection
Parameters:
listener - a new ConnectionEventListener to be registered
See Also:
ManagedConnection.addConnectionEventListener(ConnectionEventListener)

associateConnection

public void associateConnection(java.lang.Object connection)
                         throws javax.resource.ResourceException
Used by the container to change the association of an application-level connection handle with a ManagedConneciton instance. The container should find the right ManagedConnection instance and call the associateConnection method. The resource adapter is required to implement the associateConnection method. The method implementation for a ManagedConnection should dissociate the connection handle (passed as a parameter) from its currently associated ManagedConnection and associate the new connection handle with itself. Not implemented.

Specified by:
associateConnection in interface javax.resource.spi.ManagedConnection
Parameters:
connection - Application-level connection handle
Throws:
javax.resource.ResourceException - generic exception if operation fails
See Also:
ManagedConnection.associateConnection(Object)

cleanup

public void cleanup()
             throws javax.resource.ResourceException
Application server calls this method to force any cleanup on the ManagedConnection instance. The method ManagedConnection.cleanup initiates a cleanup of the any client-specific state as maintained by a ManagedConnection instance. The cleanup should invalidate all connection handles that had been created using this ManagedConnection instance. Any attempt by an application component to use the connection handle after cleanup of the underlying ManagedConnection should result in an exception. The cleanup of ManagedConnection is always driven by an application server. An application server should not invoke ManagedConnection.cleanup when there is an uncompleted transaction (associated with a ManagedConnection instance) in progress. The invocation of ManagedConnection.cleanup method on an already cleaned-up connection should not throw an exception. The cleanup of ManagedConnection instance resets its client specific state and prepares the connection to be put back in to a connection pool. The cleanup method should not cause resource adapter to close the physical pipe and reclaim system resources associated with the physical connection.

Specified by:
cleanup in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException - generic exception if operation fails
See Also:
ManagedConnection.cleanup()

destroy

public void destroy()
             throws javax.resource.ResourceException
Destroys the physical connection to the underlying resource manager. To manage the size of the connection pool, an application server can explictly call ManagedConnection.destroy to destroy a physical connection. A resource adapter should destroy all allocated system resources for this ManagedConnection instance when the method destroy is called.

Specified by:
destroy in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException - generic exception if operation failed
See Also:
ManagedConnection.destroy()

getConnection

public java.lang.Object getConnection(javax.security.auth.Subject subject,
                                      javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
                               throws javax.resource.ResourceException
Creates a new connection handle for the underlying physical connection represented by the ManagedConnection instance. This connection handle is used by the application code to refer to the underlying physical connection. This connection handle is associated with its ManagedConnection instance in a resource adapter implementation specific way. The ManagedConnection uses the Subject and additional ConnectionRequest Info (which is specific to resource adapter and opaque to application server) to set the state of the physical connection.

Specified by:
getConnection in interface javax.resource.spi.ManagedConnection
Parameters:
subject - security context as JAAS subject
cxRequestInfo - ConnectionRequestInfo instance
Returns:
generic Object instance representing the connection handle. For CCI, the connection handle created by a ManagedConnection instance is of the type javax.resource.cci.Connection.
Throws:
javax.resource.ResourceException - - generic exception if operation fails
See Also:
ManagedConnection.getConnection(Subject, ConnectionRequestInfo)

getLocalTransaction

public javax.resource.spi.LocalTransaction getLocalTransaction()
                                                        throws javax.resource.ResourceException
Not implemented.

Specified by:
getLocalTransaction in interface javax.resource.spi.ManagedConnection
Returns:
null
Throws:
javax.resource.ResourceException - generic exception if operation fails
See Also:
ManagedConnection.getLocalTransaction()

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws javax.resource.ResourceException
Not implemented.

Specified by:
getLogWriter in interface javax.resource.spi.ManagedConnection
Returns:
null
Throws:
javax.resource.ResourceException - generic exception if operation fails
See Also:
ManagedConnection.getLogWriter()

getMetaData

public javax.resource.spi.ManagedConnectionMetaData getMetaData()
                                                         throws javax.resource.ResourceException
Not implemented.

Specified by:
getMetaData in interface javax.resource.spi.ManagedConnection
Returns:
null
Throws:
javax.resource.ResourceException - generic exception if operation fails
See Also:
ManagedConnection.getMetaData()

getXAResource

public javax.transaction.xa.XAResource getXAResource()
                                              throws javax.resource.ResourceException
Not implemented.

Specified by:
getXAResource in interface javax.resource.spi.ManagedConnection
Returns:
null
Throws:
javax.resource.ResourceException - generic exception if operation fails
See Also:
ManagedConnection.getXAResource()

removeConnectionEventListener

public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener listener)
Removes an already registered connection event listener from the ManagedConnection instance.

Specified by:
removeConnectionEventListener in interface javax.resource.spi.ManagedConnection
Parameters:
listener - already registered connection event listener to be removed
See Also:
ManagedConnection.removeConnectionEventListener(ConnectionEventListener)

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
                  throws javax.resource.ResourceException
Not implemented.

Specified by:
setLogWriter in interface javax.resource.spi.ManagedConnection
Parameters:
out - Character Output stream to be associated
Throws:
javax.resource.ResourceException - generic exception if operation fails
See Also:
ManagedConnection.setLogWriter(PrintWriter)


Copyright © 2008 OW2 Consortium. All Rights Reserved.