org.ow2.jotm.jms
Class JConnection

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

public class JConnection
extends Object
implements Connection

managed Connection. this is a wrapper above the XAConnection in the MOM.


Field Summary
protected  boolean closed
           
protected  boolean globaltx
           
protected static String INTERNAL_USER_NAME
           
protected  JConnectionFactory jcf
           
protected  org.objectweb.util.monolog.api.Logger logger
           
protected  LinkedList<Session> sessionlist
           
protected static TransactionManager tm
           
protected  String user
           
protected  XAConnection xac
           
 
Constructor Summary
protected JConnection(JConnectionFactory jcf, String user, org.objectweb.util.monolog.api.Logger logger)
          Prepares the construction of a JConnection.
  JConnection(JConnectionFactory jcf, XAConnectionFactory xacf, org.objectweb.util.monolog.api.Logger logger)
          Constructor of a JConnection for an anonymous user.
  JConnection(JConnectionFactory jcf, XAConnectionFactory xacf, String user, String passwd, org.objectweb.util.monolog.api.Logger logger)
          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.
 ConnectionConsumer createConnectionConsumer(Destination destination, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
          Creates a connection consumer for this connection (optional operation)
 ConnectionConsumer createDurableConnectionConsumer(Topic topic, String subscriptionName, String messageSelector, ServerSessionPool sessionPool, int maxMessages)
          Creates a connection consumer for this connection (optional operation)
 Session createSession(boolean transacted, int acknowledgeMode)
          Creates a Session object.
 void finalClose()
           
 String getClientID()
          Get the client identifier for this connection.
 ExceptionListener getExceptionListener()
          Get the ExceptionListener for this Connection.
 ConnectionMetaData getMetaData()
          Get the meta data for this connection.
 String getUser()
          Return the user associated to this connection
protected  void sessionClose(Session s)
          A non transacted session has beem closed
protected  boolean sessionOpen(Session s)
          A new non transacted session has been opened
 void setClientID(String clientID)
          Set the client identifier for this connection.
 void setExceptionListener(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 XAConnection xac

closed

protected boolean closed

user

protected String user

globaltx

protected boolean globaltx

tm

protected static TransactionManager tm

jcf

protected JConnectionFactory jcf

sessionlist

protected LinkedList<Session> sessionlist

INTERNAL_USER_NAME

protected static final String INTERNAL_USER_NAME
See Also:
Constant Field Values

logger

protected org.objectweb.util.monolog.api.Logger logger
Constructor Detail

JConnection

protected JConnection(JConnectionFactory jcf,
                      String user,
                      org.objectweb.util.monolog.api.Logger logger)
Prepares the construction of a JConnection.

Parameters:
jcf - the Connection Factory
user - the user using this connection

JConnection

public JConnection(JConnectionFactory jcf,
                   XAConnectionFactory xacf,
                   String user,
                   String passwd,
                   org.objectweb.util.monolog.api.Logger logger)
            throws JMSException
Constructor of a JConnection for a specified user.

Parameters:
jcf - the Connection Factory
xacf - The XAConnection used in the MOM
user - user's name
passwd - user's password
Throws:
JMSException - could not create the XAConnection

JConnection

public JConnection(JConnectionFactory jcf,
                   XAConnectionFactory xacf,
                   org.objectweb.util.monolog.api.Logger logger)
            throws JMSException
Constructor of a JConnection for an anonymous user.

Parameters:
jcf - the Connection Factory
xacf - The XAConnection used in the MOM
Throws:
JMSException - could not create the XAConnection
Method Detail

sessionOpen

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

Parameters:
s - Session that has been opened
Returns:
true if OK, false if connection closed.

sessionClose

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

Parameters:
s - Session that has been opened

getUser

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

Returns:
user's name

close

public void close()
           throws 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 Connection
Throws:
JMSException - - if JMS implementation fails to return the client ID for this Connection due to some internal

finalClose

public void finalClose()
                throws JMSException
Throws:
JMSException

createConnectionConsumer

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

Specified by:
createConnectionConsumer in interface 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:
JMSException

createDurableConnectionConsumer

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

Specified by:
createDurableConnectionConsumer in interface 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:
JMSException

createSession

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

Specified by:
createSession in interface 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:
JMSException

getClientID

public String getClientID()
                   throws 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 Connection
Returns:
the unique client identifier.
Throws:
JMSException - - if JMS implementation fails to return the client ID for this Connection due to some internal

setClientID

public void setClientID(String clientID)
                 throws 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 Connection
Parameters:
clientID - - the unique client identifier
Throws:
JMSException - - general exception if JMS implementation fails to set the client ID for this Connection due to some internal error.
IllegalStateException - - if attempting to set a connection's client identifier at the wrong time or when it has been administratively configured.

getMetaData

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

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

getExceptionListener

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

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

setExceptionListener

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

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

start

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

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

stop

public void stop()
          throws 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 Connection
Throws:
JMSException - - if JMS implementation fails to start the message delivery due to some internal error.


Copyright ? 2005-2010 OW2 Consortium. All Rights Reserved.