org.jboss.messaging.ra
Class JBMManagedConnection

java.lang.Object
  extended by org.jboss.messaging.ra.JBMManagedConnection
All Implemented Interfaces:
javax.jms.ExceptionListener, javax.resource.spi.ManagedConnection

public class JBMManagedConnection
extends java.lang.Object
implements javax.resource.spi.ManagedConnection, javax.jms.ExceptionListener

The managed connection

Version:
$Revision: $
Author:
Adrian Brock, Jesper Pedersen

Constructor Summary
JBMManagedConnection(JBMManagedConnectionFactory mcf, JBMConnectionRequestInfo cri, java.lang.String userName, java.lang.String password)
          Constructor
 
Method Summary
 void addConnectionEventListener(javax.resource.spi.ConnectionEventListener l)
          Add a connection event listener.
 void associateConnection(java.lang.Object obj)
          Move a handler from one mc to this one.
 void cleanup()
          Cleanup
 void destroy()
          Destroy the physical connection.
 java.lang.Object getConnection(javax.security.auth.Subject subject, javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
          Get a connection
protected  JBMConnectionRequestInfo getCRI()
          Get the request info for this connection.
 javax.resource.spi.LocalTransaction getLocalTransaction()
          Get the location transaction for the connection.
 java.io.PrintWriter getLogWriter()
          Get the log writer -- NOT SUPPORTED
protected  JBMManagedConnectionFactory getManagedConnectionFactory()
          Get the connection factory for this connection.
 javax.resource.spi.ManagedConnectionMetaData getMetaData()
          Get the meta data for the connection.
protected  javax.jms.Session getSession()
          Get the session for this connection.
protected  java.lang.String getUserName()
          Get the user name
 javax.transaction.xa.XAResource getXAResource()
          Get the XAResource for the connection.
protected  javax.jms.XASession getXASession()
          Get the XA session for this connection.
protected  boolean isXA()
          Is managed connection running in XA mode
protected  void lock()
          Aqquire a lock on the managed connection
 void onException(javax.jms.JMSException exception)
          Notifies user of a JMS exception.
 void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener l)
          Remove a connection event listener.
protected  void removeHandle(JBMSession handle)
          Remove a handle from the handle map.
protected  void sendEvent(javax.resource.spi.ConnectionEvent event)
          Send an event.
 void setLogWriter(java.io.PrintWriter out)
          Set the log writer -- NOT SUPPORTED
protected  void tryLock()
          Aqquire a lock on the managed connection within the specified period
protected  void unlock()
          Unlock the managed connection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JBMManagedConnection

public JBMManagedConnection(JBMManagedConnectionFactory mcf,
                            JBMConnectionRequestInfo cri,
                            java.lang.String userName,
                            java.lang.String password)
                     throws javax.resource.ResourceException
Constructor

Parameters:
mcf - The managed connection factory
cri - The connection request information
userName - The user name
password - The password
Throws:
javax.resource.ResourceException
Method Detail

getConnection

public java.lang.Object getConnection(javax.security.auth.Subject subject,
                                      javax.resource.spi.ConnectionRequestInfo cxRequestInfo)
                               throws javax.resource.ResourceException
Get a connection

Specified by:
getConnection in interface javax.resource.spi.ManagedConnection
Parameters:
subject - The security subject
cxRequestInfo - The request info
Returns:
The connection
Throws:
javax.resource.ResourceException - Thrown if an error occurs

destroy

public void destroy()
             throws javax.resource.ResourceException
Destroy the physical connection.

Specified by:
destroy in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException - Could not property close the session and connection.

cleanup

public void cleanup()
             throws javax.resource.ResourceException
Cleanup

Specified by:
cleanup in interface javax.resource.spi.ManagedConnection
Throws:
javax.resource.ResourceException - Thrown if an error occurs

associateConnection

public void associateConnection(java.lang.Object obj)
                         throws javax.resource.ResourceException
Move a handler from one mc to this one.

Specified by:
associateConnection in interface javax.resource.spi.ManagedConnection
Parameters:
obj - An object of type JBMSession.
Throws:
javax.resource.ResourceException - Failed to associate connection.
javax.resource.spi.IllegalStateException - ManagedConnection in an illegal state.

lock

protected void lock()
Aqquire a lock on the managed connection


tryLock

protected void tryLock()
                throws javax.jms.JMSException
Aqquire a lock on the managed connection within the specified period

Throws:
javax.jms.JMSException - Thrown if an error occurs

unlock

protected void unlock()
Unlock the managed connection


addConnectionEventListener

public void addConnectionEventListener(javax.resource.spi.ConnectionEventListener l)
Add a connection event listener.

Specified by:
addConnectionEventListener in interface javax.resource.spi.ManagedConnection
Parameters:
l - The connection event listener to be added.

removeConnectionEventListener

public void removeConnectionEventListener(javax.resource.spi.ConnectionEventListener l)
Remove a connection event listener.

Specified by:
removeConnectionEventListener in interface javax.resource.spi.ManagedConnection
Parameters:
l - The connection event listener to be removed.

getXAResource

public javax.transaction.xa.XAResource getXAResource()
                                              throws javax.resource.ResourceException
Get the XAResource for the connection.

Specified by:
getXAResource in interface javax.resource.spi.ManagedConnection
Returns:
The XAResource for the connection.
Throws:
javax.resource.ResourceException - XA transaction not supported

getLocalTransaction

public javax.resource.spi.LocalTransaction getLocalTransaction()
                                                        throws javax.resource.ResourceException
Get the location transaction for the connection.

Specified by:
getLocalTransaction in interface javax.resource.spi.ManagedConnection
Returns:
The local transaction for the connection.
Throws:
javax.resource.ResourceException - Thrown if operation fails.

getMetaData

public javax.resource.spi.ManagedConnectionMetaData getMetaData()
                                                         throws javax.resource.ResourceException
Get the meta data for the connection.

Specified by:
getMetaData in interface javax.resource.spi.ManagedConnection
Returns:
The meta data for the connection.
Throws:
javax.resource.ResourceException - Thrown if the operation fails.
javax.resource.spi.IllegalStateException - Thrown if the managed connection already is destroyed.

setLogWriter

public void setLogWriter(java.io.PrintWriter out)
                  throws javax.resource.ResourceException
Set the log writer -- NOT SUPPORTED

Specified by:
setLogWriter in interface javax.resource.spi.ManagedConnection
Parameters:
out - The log writer
Throws:
javax.resource.ResourceException - If operation fails

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws javax.resource.ResourceException
Get the log writer -- NOT SUPPORTED

Specified by:
getLogWriter in interface javax.resource.spi.ManagedConnection
Returns:
Always null
Throws:
javax.resource.ResourceException - If operation fails

onException

public void onException(javax.jms.JMSException exception)
Notifies user of a JMS exception.

Specified by:
onException in interface javax.jms.ExceptionListener
Parameters:
exception - The JMS exception

isXA

protected boolean isXA()
Is managed connection running in XA mode

Returns:
True if XA; otherwise false

getXASession

protected javax.jms.XASession getXASession()
Get the XA session for this connection.

Returns:
The XA session

getSession

protected javax.jms.Session getSession()
Get the session for this connection.

Returns:
The session

sendEvent

protected void sendEvent(javax.resource.spi.ConnectionEvent event)
Send an event.

Parameters:
event - The event to send.

removeHandle

protected void removeHandle(JBMSession handle)
Remove a handle from the handle map.

Parameters:
handle - The handle to remove.

getCRI

protected JBMConnectionRequestInfo getCRI()
Get the request info for this connection.

Returns:
The connection request info for this connection.

getManagedConnectionFactory

protected JBMManagedConnectionFactory getManagedConnectionFactory()
Get the connection factory for this connection.

Returns:
The connection factory for this connection.

getUserName

protected java.lang.String getUserName()
Get the user name

Returns:
The user name


Copyright © 2006 JBoss Inc. All Rights Reserved.