org.mule.module.jca
Class MuleManagedConnection

java.lang.Object
  extended by org.mule.module.jca.MuleManagedConnection
All Implemented Interfaces:
ManagedConnection

public class MuleManagedConnection
extends Object
implements ManagedConnection

MuleManagedConnection TODO


Method Summary
 void addConnection(MuleConnection connection)
          Associate connection handle with the physical connection.
 void addConnectionEventListener(ConnectionEventListener listener)
          Adds a connection event listener to the ManagedConnection instance.
 void associateConnection(Object connection)
          Used by the container to change the association of an application-level connection handle with a ManagedConnection instance.
 void cleanup()
          Initiates a cleanup of the client-specific state maintained by a ManagedConnection instance.
 void destroy()
          Destroys the physical connection.
 Object getConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo)
          Creates a new connection handle to the Mail Server represented by the ManagedConnection instance.
 LocalTransaction getLocalTransaction()
          Returns a javax.resource.spi.LocalTransaction instance.
 PrintWriter getLogWriter()
          Gets the log writer for this ManagedConnection instance.
 MuleManagedConnectionFactory getManagedConnectionFactory()
          Returns the ManagedConnectionFactory that created this instance of ManagedConnection.
 ManagedConnectionMetaData getMetaData()
          Gets the metadata information for this connection's underlying EIS resource manager instance.
 PasswordCredential getPasswordCredential()
          Gets the password for the user associated with the ManagedConnection instance.
 String getUsername()
          Gets the user name of the user associated with the ManagedConnection instance.
 XAResource getXAResource()
          Returns a javax.transaction.xa.XAresource instance.
 void removeConnection(MuleConnection connection)
          Removes the associated connection handle from the connections set to the physical connection.
 void removeConnectionEventListener(ConnectionEventListener listener)
          Removes an already registered connection event listener from the ManagedConnection instance.
 void setLogWriter(PrintWriter out)
          Sets the log writer for this ManagedConnection instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getConnection

public Object getConnection(Subject subject,
                            ConnectionRequestInfo connectionRequestInfo)
                     throws ResourceException
Creates a new connection handle to the Mail Server represented by the ManagedConnection instance. This connection handle is used by the application code to refer to the underlying physical connection.

Specified by:
getConnection in interface ManagedConnection
Parameters:
subject - security context as JAAS subject
connectionRequestInfo - ConnectionRequestInfo instance
Returns:
Connection instance representing the connection handle
Throws:
ResourceException - if the method fails to get a connection

destroy

public void destroy()
             throws ResourceException
Destroys the physical connection.

Specified by:
destroy in interface ManagedConnection
Throws:
ResourceException - if the method fails to destroy the connection

cleanup

public void cleanup()
             throws ResourceException
Initiates a cleanup of the client-specific state maintained by a ManagedConnection instance. The cleanup should invalidate all connection handles created using this ManagedConnection instance.

Specified by:
cleanup in interface ManagedConnection
Throws:
ResourceException - if the cleanup fails

associateConnection

public void associateConnection(Object connection)
                         throws ResourceException
Used by the container to change the association of an application-level connection handle with a ManagedConnection instance. The container should find the right ManagedConnection instance and call the associateConnection method.

Specified by:
associateConnection in interface ManagedConnection
Parameters:
connection - application-level connection handle
Throws:
ResourceException - if the attempt to change the association fails

addConnectionEventListener

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

Specified by:
addConnectionEventListener in interface ManagedConnection
Parameters:
listener - a new ConnectionEventListener to be registered

removeConnectionEventListener

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

Specified by:
removeConnectionEventListener in interface ManagedConnection
Parameters:
listener - already registered connection event listener to be removed

getXAResource

public XAResource getXAResource()
                         throws ResourceException
Returns a javax.transaction.xa.XAresource instance. An application server enlists this XAResource instance with the Transaction Manager if the ManagedConnection instance is being used in a JTA transaction that is being coordinated by the Transaction Manager.

Because this implementation does not support transactions, the method throws an exception.

Specified by:
getXAResource in interface ManagedConnection
Returns:
the XAResource instance
Throws:
ResourceException - if transactions are not supported

getLocalTransaction

public LocalTransaction getLocalTransaction()
                                     throws ResourceException
Returns a javax.resource.spi.LocalTransaction instance. The LocalTransaction interface is used by the container to manage local transactions for a RM instance.

Because this implementation does not support transactions, the method throws an exception.

Specified by:
getLocalTransaction in interface ManagedConnection
Returns:
javax.resource.spi.LocalTransaction instance
Throws:
ResourceException - if transactions are not supported

getMetaData

public ManagedConnectionMetaData getMetaData()
                                      throws ResourceException
Gets the metadata information for this connection's underlying EIS resource manager instance. The ManagedConnectionMetaData interface provides information about the underlying EIS instance associated with the ManagedConnection instance.

Specified by:
getMetaData in interface ManagedConnection
Returns:
ManagedConnectionMetaData ManagedConnectionMetaData instance
Throws:
ResourceException - if the metadata cannot be retrieved

setLogWriter

public void setLogWriter(PrintWriter out)
                  throws ResourceException
Sets the log writer for this ManagedConnection instance. The log writer is a character output stream to which all logging and tracing messages for this ManagedConnection instance will be printed.

Specified by:
setLogWriter in interface ManagedConnection
Parameters:
out - character output stream to be associated
Throws:
ResourceException - if the method fails

getLogWriter

public PrintWriter getLogWriter()
                         throws ResourceException
Gets the log writer for this ManagedConnection instance.

Specified by:
getLogWriter in interface ManagedConnection
Returns:
the character output stream associated with this ManagedConnection instance
Throws:
ResourceException - if the method fails

getUsername

public String getUsername()
Gets the user name of the user associated with the ManagedConnection instance.

Returns:
the username for this connection

getPasswordCredential

public PasswordCredential getPasswordCredential()
Gets the password for the user associated with the ManagedConnection instance.

Returns:
the password for this connection

addConnection

public void addConnection(MuleConnection connection)
Associate connection handle with the physical connection.

Parameters:
connection - connection handle

removeConnection

public void removeConnection(MuleConnection connection)
Removes the associated connection handle from the connections set to the physical connection.

Parameters:
connection - the connection handle

getManagedConnectionFactory

public MuleManagedConnectionFactory getManagedConnectionFactory()
Returns the ManagedConnectionFactory that created this instance of ManagedConnection.

Returns:
the ManagedConnectionFactory for this connection


Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.