xmlBlaster 2.1.0 API

org.xmlBlaster.jms
Class XBConnection

java.lang.Object
  extended by org.xmlBlaster.jms.XBConnection
All Implemented Interfaces:
javax.jms.Connection, javax.jms.QueueConnection, javax.jms.TopicConnection, I_StatusChangeListener

public class XBConnection
extends java.lang.Object
implements javax.jms.QueueConnection, javax.jms.TopicConnection, I_StatusChangeListener

XBConnection holds the connections to xmlBlaster.Since this class serves as a factory for jms sessions, and since the mapping between sessions and connections is: <br/> <ul> <li><b>xmlBlaster</b>: 1 connection -> 1 session</li> <li><b>jms</b>: 1 connection -> n session</li> </ul> we need to map one jms connection (XBConnection) to multiple (n) xmlBlaster connections (one for each session). Then again, each jms session would map to one xmlBlaster session.

Author:
Michele Laghi

Field Summary
private  boolean closed
           
(package private)  java.lang.Object closeSync
           
private  ConnectQos connectQos
           
private  javax.jms.ExceptionListener exceptionListener
           
private  boolean forQueues
           
private  Global global
           
private static java.util.logging.Logger log
           
private static java.lang.String ME
           
private  javax.jms.ConnectionMetaData metaData
           
private  boolean running
           
private  java.util.Map sessionMap
           
private  boolean stillVirgin
          if true, no invocation on this connection has been done.
 
Fields inherited from interface org.xmlBlaster.jms.I_StatusChangeListener
CLOSED, RUNNING
 
Constructor Summary
XBConnection(ConnectQos connectQos, javax.jms.ConnectionMetaData metaData, boolean forQueues)
           
 
Method Summary
(package private)  void checkClosed()
           
 void close()
          Disconnect all sessions administered by this connection.
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination, java.lang.String msgSelector, javax.jms.ServerSessionPool serverSessionPool, int maxMessages)
           
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Queue queue, java.lang.String msgSelector, javax.jms.ServerSessionPool serverSessionPool, int maxMessages)
           
 javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Topic topic, java.lang.String msgSelector, javax.jms.ServerSessionPool serverSessionPool, int maxMessages)
           
 javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic, java.lang.String subscriptionName, java.lang.String msgSelector, javax.jms.ServerSessionPool serverSessionPool, int maxMessages)
           
 javax.jms.QueueSession createQueueSession(boolean transacted, int ackMode)
           
 javax.jms.Session createSession(boolean transacted, int ackMode)
          It creates a session.
 javax.jms.TopicSession createTopicSession(boolean transacted, int ackMode)
           
 java.lang.String getClientID()
           
(package private)  ConnectQos getConnectQos()
           
 javax.jms.ExceptionListener getExceptionListener()
           
 javax.jms.ConnectionMetaData getMetaData()
           
private  void initSession(java.lang.String methodName, XBSession session, boolean transacted, int ackMode)
           
 void setClientID(java.lang.String loginName)
           
 void setExceptionListener(javax.jms.ExceptionListener exeptionListener)
           
 void start()
          Activates the dispatcher of all sessions administered by this connection.
private  void startStop(java.lang.String txt, boolean isStart)
           
 void statusPostChanged(java.lang.String id, int oldStatus, int newStatus)
           
 void statusPreChanged(java.lang.String id, int oldStatus, int newStatus)
          Removes the session from the map to avoid future notification.
 void stop()
          Disactivates the dispatchers of all sessions administered by this connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ME

private static final java.lang.String ME
See Also:
Constant Field Values

global

private Global global

log

private static java.util.logging.Logger log

exceptionListener

private javax.jms.ExceptionListener exceptionListener

metaData

private javax.jms.ConnectionMetaData metaData

connectQos

private ConnectQos connectQos

sessionMap

private java.util.Map sessionMap

running

private boolean running

stillVirgin

private boolean stillVirgin
if true, no invocation on this connection has been done. Used for setClientId check


forQueues

private boolean forQueues

closed

private boolean closed

closeSync

java.lang.Object closeSync
Constructor Detail

XBConnection

XBConnection(ConnectQos connectQos,
             javax.jms.ConnectionMetaData metaData,
             boolean forQueues)
       throws XmlBlasterException
Parameters:
connectQos -
metaData -
forQueues - true if the connection is used as a QueueConnection, false otherwise
Throws:
XmlBlasterException
Method Detail

checkClosed

final void checkClosed()
                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

initSession

private void initSession(java.lang.String methodName,
                         XBSession session,
                         boolean transacted,
                         int ackMode)
                  throws javax.jms.JMSException
Throws:
javax.jms.JMSException

createSession

public javax.jms.Session createSession(boolean transacted,
                                       int ackMode)
                                throws javax.jms.JMSException
It creates a session. The session is responsible of registering itself into this connection in the constructor and to deregister itself when close is invoked. Registering is necessary since the connection is stateful (running/stopped) and all sessions belonging to it must be notified of such state changes.

Specified by:
createSession in interface javax.jms.Connection
Throws:
javax.jms.JMSException

createTopicSession

public javax.jms.TopicSession createTopicSession(boolean transacted,
                                                 int ackMode)
                                          throws javax.jms.JMSException
Specified by:
createTopicSession in interface javax.jms.TopicConnection
Throws:
javax.jms.JMSException

createQueueSession

public javax.jms.QueueSession createQueueSession(boolean transacted,
                                                 int ackMode)
                                          throws javax.jms.JMSException
Specified by:
createQueueSession in interface javax.jms.QueueConnection
Throws:
javax.jms.JMSException

close

public void close()
           throws javax.jms.JMSException
Disconnect all sessions administered by this connection.

Specified by:
close in interface javax.jms.Connection
Throws:
javax.jms.JMSException
See Also:
Connection.close()

getClientID

public java.lang.String getClientID()
                             throws javax.jms.JMSException
Specified by:
getClientID in interface javax.jms.Connection
Throws:
javax.jms.JMSException

getExceptionListener

public javax.jms.ExceptionListener getExceptionListener()
                                                 throws javax.jms.JMSException
Specified by:
getExceptionListener in interface javax.jms.Connection
Throws:
javax.jms.JMSException

getMetaData

public javax.jms.ConnectionMetaData getMetaData()
                                         throws javax.jms.JMSException
Specified by:
getMetaData in interface javax.jms.Connection
Throws:
javax.jms.JMSException

setClientID

public void setClientID(java.lang.String loginName)
                 throws javax.jms.JMSException
Specified by:
setClientID in interface javax.jms.Connection
Throws:
javax.jms.JMSException

setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener exeptionListener)
                          throws javax.jms.JMSException
Specified by:
setExceptionListener in interface javax.jms.Connection
Throws:
javax.jms.JMSException

start

public void start()
           throws javax.jms.JMSException
Activates the dispatcher of all sessions administered by this connection.

Specified by:
start in interface javax.jms.Connection
Throws:
javax.jms.JMSException
See Also:
Connection.start()

startStop

private void startStop(java.lang.String txt,
                       boolean isStart)
                throws javax.jms.JMSException
Throws:
javax.jms.JMSException

stop

public void stop()
          throws javax.jms.JMSException
Disactivates the dispatchers of all sessions administered by this connection.

Specified by:
stop in interface javax.jms.Connection
Throws:
javax.jms.JMSException
See Also:
Connection.stop()

statusPostChanged

public void statusPostChanged(java.lang.String id,
                              int oldStatus,
                              int newStatus)
Specified by:
statusPostChanged in interface I_StatusChangeListener

statusPreChanged

public void statusPreChanged(java.lang.String id,
                             int oldStatus,
                             int newStatus)
Removes the session from the map to avoid future notification. This event comes when the session closes.

Specified by:
statusPreChanged in interface I_StatusChangeListener

createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Destination destination,
                                                             java.lang.String msgSelector,
                                                             javax.jms.ServerSessionPool serverSessionPool,
                                                             int maxMessages)
                                                      throws javax.jms.JMSException
Specified by:
createConnectionConsumer in interface javax.jms.Connection
Throws:
javax.jms.JMSException
See Also:
QueueConnection.createConnectionConsumer(javax.jms.Queue, java.lang.String, javax.jms.ServerSessionPool, int)

createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Topic topic,
                                                             java.lang.String msgSelector,
                                                             javax.jms.ServerSessionPool serverSessionPool,
                                                             int maxMessages)
                                                      throws javax.jms.JMSException
Specified by:
createConnectionConsumer in interface javax.jms.TopicConnection
Throws:
javax.jms.JMSException
See Also:
QueueConnection.createConnectionConsumer(javax.jms.Queue, java.lang.String, javax.jms.ServerSessionPool, int)

createConnectionConsumer

public javax.jms.ConnectionConsumer createConnectionConsumer(javax.jms.Queue queue,
                                                             java.lang.String msgSelector,
                                                             javax.jms.ServerSessionPool serverSessionPool,
                                                             int maxMessages)
                                                      throws javax.jms.JMSException
Specified by:
createConnectionConsumer in interface javax.jms.QueueConnection
Throws:
javax.jms.JMSException
See Also:
QueueConnection.createConnectionConsumer(javax.jms.Queue, java.lang.String, javax.jms.ServerSessionPool, int)

createDurableConnectionConsumer

public javax.jms.ConnectionConsumer createDurableConnectionConsumer(javax.jms.Topic topic,
                                                                    java.lang.String subscriptionName,
                                                                    java.lang.String msgSelector,
                                                                    javax.jms.ServerSessionPool serverSessionPool,
                                                                    int maxMessages)
                                                             throws javax.jms.JMSException
Specified by:
createDurableConnectionConsumer in interface javax.jms.Connection
Specified by:
createDurableConnectionConsumer in interface javax.jms.TopicConnection
Throws:
javax.jms.JMSException
See Also:
TopicConnection.createDurableConnectionConsumer(javax.jms.Topic, java.lang.String, java.lang.String, javax.jms.ServerSessionPool, int)

getConnectQos

ConnectQos getConnectQos()

xmlBlaster 2.1.0 API

Copyright © 1999-2011 The xmlBlaster.org contributers.