org.objectweb.jonas_jms
Class JConnection

java.lang.Object
  extended by org.objectweb.jonas_jms.JConnection
All Implemented Interfaces:
javax.jms.Connection
Direct Known Subclasses:
JQueueConnection, JTopicConnection

public class JConnection
extends java.lang.Object
implements javax.jms.Connection

Common methods used in JQueueConnection and JTopicConnection.

Author:
Laurent Chauvirey, Frederic Maistre, Nicolas Tachker Contributor(s): Philippe Durieux Jeff Mesnil connection anonymous Philippe Coq JMS 1.1 integration

Field Summary
protected  boolean closed
           
protected  boolean globaltx
           
protected static java.lang.String INTERNAL_USER_NAME
           
protected  JConnectionFactory jcf
           
protected  java.util.LinkedList sessionlist
           
protected static org.objectweb.transaction.jta.TransactionManager tm
           
protected  java.lang.String user
           
protected  javax.jms.XAConnection xac
           
 
Constructor Summary
protected JConnection(JConnectionFactory jcf, java.lang.String user)
          Prepares the construction of a JConnection.
  JConnection(JConnectionFactory jcf, javax.jms.XAConnectionFactory xacf)
          Constructor of a JConnection for an anonymous user.
  JConnection(JConnectionFactory jcf, javax.jms.XAConnectionFactory xacf, java.lang.String user, java.lang.String passwd)
          Constructor of a JConnection for a specified user.
 
Method Summary
 void close()
          When this method is invoked it should not return until message processing has been orderly shut down.
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
          Creates a connection consumer for this connection (optional operation)
 javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String messageSelector, javax.jms.ServerSessionPool sessionPool, int maxMessages)
          Creates a connection consumer for this connection (optional operation)
 javax.jms.Session createSession(boolean transacted, int acknowledgeMode)
          Creates a Session object.
 void finalClose()
           
 java.lang.String getClientID()
          Get the client identifier for this connection.
 javax.jms.ExceptionListener getExceptionListener()
          Get the ExceptionListener for this Connection.
 javax.jms.ConnectionMetaData getMetaData()
          Get the meta data for this connection.
 java.lang.String getUser()
          Return the user associated to this connection
protected  void sessionClose(javax.jms.Session s)
          A non transacted session has beem closed
protected  boolean sessionOpen(javax.jms.Session s)
          A new non transacted session has been opened
 void setClientID(java.lang.String clientID)
          Set the client identifier for this connection.
 void setExceptionListener(javax.jms.ExceptionListener listener)
          Set an exception listener for this connection.
 void start()
          Start (or restart) a Connection's delivery of incoming messages.
 void stop()
          Used to temporarily stop a Connection's delivery of incoming messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

xac

protected javax.jms.XAConnection xac

closed

protected boolean closed

user

protected java.lang.String user

globaltx

protected boolean globaltx

tm

protected static org.objectweb.transaction.jta.TransactionManager tm

jcf

protected JConnectionFactory jcf

sessionlist

protected java.util.LinkedList sessionlist

INTERNAL_USER_NAME

protected static final java.lang.String INTERNAL_USER_NAME
See Also:
Constant Field Values
Constructor Detail

JConnection

protected JConnection(JConnectionFactory jcf,
                      java.lang.String user)
               throws javax.jms.JMSException
Prepares the construction of a JConnection.

Throws:
javax.jms.JMSException

JConnection

public JConnection(JConnectionFactory jcf,
                   javax.jms.XAConnectionFactory xacf,
                   java.lang.String user,
                   java.lang.String passwd)
            throws javax.jms.JMSException
Constructor of a JConnection for a specified user.

Parameters:
user - user's name
passwd - user's password
Throws:
javax.jms.JMSException

JConnection

public JConnection(JConnectionFactory jcf,
                   javax.jms.XAConnectionFactory xacf)
            throws javax.jms.JMSException
Constructor of a JConnection for an anonymous user.

Throws:
javax.jms.JMSException
Method Detail

sessionOpen

protected boolean sessionOpen(javax.jms.Session s)
A new non transacted session has been opened


sessionClose

protected void sessionClose(javax.jms.Session s)
A non transacted session has beem closed


getUser

public java.lang.String getUser()
Return the user associated to this connection


close

public void close()
           throws javax.jms.JMSException
When this method is invoked it should not return until message processing has been orderly shut down. This means that all message listeners that may have been running have returned and that all pending receives have returned. A close terminates all pending message receives on the connection's sessions' consumers.

Specified by:
close in interface javax.jms.Connection
Throws:
javax.jms.JMSException - - if JMS implementation fails to return the client ID for this Connection due to some internal

finalClose

public void finalClose()
                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination,
                                                             java.lang.String messageSelector,
                                                             javax.jms.ServerSessionPool sessionPool,
                                                             int maxMessages)
                                                      throws javax.jms.JMSException
Creates a connection consumer for this connection (optional operation)

Specified by:
createConnectionConsumer in interface javax.jms.Connection
Parameters:
destination - - the destination to access
messageSelector - - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
sessionPool - - the server session pool to associate with this connection consumer
maxMessages - - the maximum number of messages that can be assigned to a server session at one time
Returns:
the connection consumer
Throws:
javax.jms.JMSException

createDurableConnectionConsumer

public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic,
                                                                    java.lang.String subscriptionName,
                                                                    java.lang.String messageSelector,
                                                                    javax.jms.ServerSessionPool sessionPool,
                                                                    int maxMessages)
                                                             throws javax.jms.JMSException
Creates a connection consumer for this connection (optional operation)

Specified by:
createDurableConnectionConsumer in interface javax.jms.Connection
Parameters:
topic - - the topic to access
subscriptionName - - durable subscription name
messageSelector - - only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
sessionPool - - the server session pool to associate with this connection consumer
maxMessages - - the maximum number of messages that can be assigned to a server session at one time
Returns:
the durable connection consumer
Throws:
javax.jms.JMSException

createSession

public javax.jms.Session createSession(boolean transacted,
                                       int acknowledgeMode)
                                throws javax.jms.JMSException
Creates a Session object.

Specified by:
createSession in interface javax.jms.Connection
Parameters:
transacted - - indicates whether the session is transacted
acknowledgeMode - indicates whether the consumer or the client will acknowledge any messages it receives; ignored if the session is transacted. Legal values are Session.AUTO_ACKNOWLEDGE, Session.CLIENT_ACKNOWLEDGE, and Session.DUPS_OK_ACKNOWLEDGE.
Throws:
javax.jms.JMSException

getClientID

public java.lang.String getClientID()
                             throws javax.jms.JMSException
Get the client identifier for this connection. This value is JMS Provider specific. Either pre-configured by an administrator in a ConnectionFactory or assigned dynamically by the application by calling setClientID method.

Specified by:
getClientID in interface javax.jms.Connection
Returns:
the unique client identifier.
Throws:
javax.jms.JMSException - - if JMS implementation fails to return the client ID for this Connection due to some internal

setClientID

public void setClientID(java.lang.String clientID)
                 throws javax.jms.JMSException
Set the client identifier for this connection. If another connection with clientID is already running when this method is called, the JMS Provider should detect the duplicate id and throw InvalidClientIDException.

Specified by:
setClientID in interface javax.jms.Connection
Parameters:
clientID - - the unique client identifier
Throws:
javax.jms.JMSException - - general exception if JMS implementation fails to set the client ID for this Connection due to some internal error.
InvalidClientIDException - - if JMS client specifies an invalid or duplicate client id.
java.lang.IllegalStateException - - if attempting to set a connection's client identifier at the wrong time or when it has been administratively configured.

getMetaData

public javax.jms.ConnectionMetaData getMetaData()
                                         throws javax.jms.JMSException
Get the meta data for this connection.

Specified by:
getMetaData in interface javax.jms.Connection
Returns:
the connection meta data.
Throws:
javax.jms.JMSException - - general exception if JMS implementation fails to get the Connection meta-data for this Connection.

getExceptionListener

public javax.jms.ExceptionListener getExceptionListener()
                                                 throws javax.jms.JMSException
Get the ExceptionListener for this Connection.

Specified by:
getExceptionListener in interface javax.jms.Connection
Returns:
the ExceptionListener for this Connection.
Throws:
javax.jms.JMSException - - general exception if JMS implementation fails to get the Exception listener for this Connection.

setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener listener)
                          throws javax.jms.JMSException
Set an exception listener for this connection.

Specified by:
setExceptionListener in interface javax.jms.Connection
Parameters:
listener - - the exception listener.
Throws:
javax.jms.JMSException - - general exception if JMS implementation fails to set the Exception listener for this Connection.

start

public void start()
           throws javax.jms.JMSException
Start (or restart) a Connection's delivery of incoming messages.

Specified by:
start in interface javax.jms.Connection
Throws:
javax.jms.JMSException - - if JMS implementation fails to start the message delivery due to some internal error.

stop

public void stop()
          throws javax.jms.JMSException
Used to temporarily stop a Connection's delivery of incoming messages. It can be restarted using its start method. When stopped, delivery to all the Connection's message consumers is inhibited: synchronous receive's block and messages are not delivered to message listeners.

Specified by:
stop in interface javax.jms.Connection
Throws:
javax.jms.JMSException - - if JMS implementation fails to start the message delivery due to some internal error.