Joram ${version}

org.objectweb.joram.mom.util
Class BridgeUnifiedModule

java.lang.Object
  extended byorg.objectweb.joram.mom.util.BridgeUnifiedModule
All Implemented Interfaces:
javax.jms.ExceptionListener, javax.jms.MessageListener, java.io.Serializable
Direct Known Subclasses:
BridgePtpModule, BridgePubSubModule

public class BridgeUnifiedModule
extends java.lang.Object
implements javax.jms.ExceptionListener, javax.jms.MessageListener, java.io.Serializable

The BridgeUnifiedModule class is a bridge module based on the JMS 1.1 unified semantics and classes.

See Also:
Serialized Form

Nested Class Summary
protected  class BridgeUnifiedModule.ConsumerDaemon
          The ConsumerDaemon thread allows to call MessageConsumer.receive() for requesting a foreign JMS message without blocking the JORAM server.
protected  class BridgeUnifiedModule.ReconnectionDaemon
          The ReconnectionDaemon thread is responsible for reconnecting the bridge module with the foreign JMS server in case of disconnection.
protected  class BridgeUnifiedModule.StartupDaemon
          The StartupDaemon thread is responsible for retrieving the needed JMS administered objects from the JNDI server.
 
Field Summary
protected  fr.dyade.aaa.agent.AgentId agentId
          Identifier of the agent using this module.
protected  java.lang.String clientID
          JMS clientID field.
protected  javax.jms.Connection cnx
          Connection to the foreign JMS server.
protected  javax.jms.ConnectionFactory cnxFact
          Connection factory object for connecting to the foreign JMS server.
protected  java.lang.String cnxFactName
          ConnectionFactory JNDI name.
protected  javax.jms.MessageConsumer consumer
          Consumer object.
protected  BridgeUnifiedModule.ConsumerDaemon consumerDaemon
          Daemon used for requesting messages.
protected  javax.jms.Session consumerSession
          Session for getting messages from the foreign JMS destination.
protected  javax.jms.Destination dest
          Foreign JMS destination object.
protected  java.lang.String destName
          Destination JNDI name.
protected  java.lang.String jndiFactory
          Name of the JNDI factory class to use.
protected  java.lang.String jndiUrl
          JNDI URL.
protected  boolean listener
          true if a listener has been set on the JMS consumer.
protected  java.lang.String notUsableMessage
          Message explaining why the module is not usable.
protected  java.lang.String password
          User password for connecting to the foreign JMS server.
protected  javax.jms.MessageProducer producer
          Producer object.
protected  javax.jms.Session producerSession
          Session for sending messages to the foreign JMS destination.
protected  java.util.Vector qout
          Vector holding the pending messages to send after reconnection.
protected  BridgeUnifiedModule.ReconnectionDaemon reconnectionDaemon
          Daemon used for the reconnection process.
protected  java.lang.String selector
          Selector for filtering messages.
protected  boolean usable
          true if the module is fully usable.
protected  java.lang.String userName
          User identification for connecting to the foreign JMS server.
 
Constructor Summary
BridgeUnifiedModule()
          Constructs a BridgeUnifiedModule module.
 
Method Summary
protected  void acknowledge(Message message)
          Acknowledges a message successfuly delivered to the foreign JMS server.
 void close()
          Interrupts the daemons and closes the connection.
 void connect()
          Launches the connection process to the foreign JMS server.
protected  void doConnect()
          Opens a connection with the foreign JMS server and creates the JMS resources for interacting with the foreign JMS destination.
 void init(fr.dyade.aaa.agent.AgentId agentId, java.util.Properties prop)
          Initializes the module's parameters.
 void onException(javax.jms.JMSException exc)
          Implements the javax.jms.ExceptionListener interface for catching the failures of the connection to the remote JMS server.
 void onMessage(javax.jms.Message jmsMessage)
          Implements the javax.jms.MessageListener interface for processing the asynchronous deliveries coming from the foreign JMS server.
 void receive()
          Asynchronous method requesting a delivery from the foreign JMS destination.
 Message receiveNoWait()
          Synchronous method requesting an immediate delivery from the foreign JMS destination.
 void send(Message message)
          Sends a message to the foreign JMS destination.
protected  void setConsumer()
          Sets the JMS consumer on the foreign destination.
 void setMessageListener()
          Sets a message listener on the foreign JMS destination.
protected  void unsetConsumer()
          Unsets the JMS consumer.
 void unsetMessageListener()
          Unsets the set message listener on the foreign JMS destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agentId

protected fr.dyade.aaa.agent.AgentId agentId
Identifier of the agent using this module.


jndiFactory

protected java.lang.String jndiFactory
Name of the JNDI factory class to use.


jndiUrl

protected java.lang.String jndiUrl
JNDI URL.


cnxFactName

protected java.lang.String cnxFactName
ConnectionFactory JNDI name.


destName

protected java.lang.String destName
Destination JNDI name.


cnxFact

protected javax.jms.ConnectionFactory cnxFact
Connection factory object for connecting to the foreign JMS server.


dest

protected javax.jms.Destination dest
Foreign JMS destination object.


userName

protected java.lang.String userName
User identification for connecting to the foreign JMS server.


password

protected java.lang.String password
User password for connecting to the foreign JMS server.


clientID

protected java.lang.String clientID
JMS clientID field.


selector

protected java.lang.String selector
Selector for filtering messages.


usable

protected boolean usable
true if the module is fully usable.


notUsableMessage

protected java.lang.String notUsableMessage
Message explaining why the module is not usable.


cnx

protected transient javax.jms.Connection cnx
Connection to the foreign JMS server.


producerSession

protected transient javax.jms.Session producerSession
Session for sending messages to the foreign JMS destination.


consumerSession

protected transient javax.jms.Session consumerSession
Session for getting messages from the foreign JMS destination.


producer

protected transient javax.jms.MessageProducer producer
Producer object.


consumer

protected transient javax.jms.MessageConsumer consumer
Consumer object.


listener

protected transient boolean listener
true if a listener has been set on the JMS consumer.


qout

protected transient java.util.Vector qout
Vector holding the pending messages to send after reconnection.


consumerDaemon

protected transient BridgeUnifiedModule.ConsumerDaemon consumerDaemon
Daemon used for requesting messages.


reconnectionDaemon

protected transient BridgeUnifiedModule.ReconnectionDaemon reconnectionDaemon
Daemon used for the reconnection process.

Constructor Detail

BridgeUnifiedModule

public BridgeUnifiedModule()
Constructs a BridgeUnifiedModule module.

Method Detail

init

public void init(fr.dyade.aaa.agent.AgentId agentId,
                 java.util.Properties prop)
Initializes the module's parameters.

Parameters:
agentId - Identifier of the agent using the module.
prop - JMS properties required for establishing the link with the foreign JMS server.
Throws:
java.lang.IllegalArgumentException - If the provided properties are invalid.

connect

public void connect()
             throws javax.jms.JMSException
Launches the connection process to the foreign JMS server.

Throws:
javax.jms.IllegalStateException - If the module can't access the foreign JMS server.
javax.jms.JMSException - If the needed JMS resources can't be created.

setMessageListener

public void setMessageListener()
                        throws javax.jms.IllegalStateException
Sets a message listener on the foreign JMS destination.

Throws:
javax.jms.IllegalStateException - If the module state does not allow to set a listener.

unsetMessageListener

public void unsetMessageListener()
Unsets the set message listener on the foreign JMS destination.


receiveNoWait

public Message receiveNoWait()
                      throws javax.jms.IllegalStateException
Synchronous method requesting an immediate delivery from the foreign JMS destination.

Returns:
The JMS message formatted into a JORAM MOM message, or null if no message is available or if the request fails.
Throws:
javax.jms.IllegalStateException - If the module state does not allow to request a message.

receive

public void receive()
             throws javax.jms.IllegalStateException
Asynchronous method requesting a delivery from the foreign JMS destination.

Throws:
javax.jms.IllegalStateException - If the module state does not allow to request a message.

send

public void send(Message message)
          throws javax.jms.JMSException
Sends a message to the foreign JMS destination.

Throws:
javax.jms.IllegalStateException - If the module's state does not permit message sendings.
javax.jms.MessageFormatException - If the MOM message could not be converted into a foreign JMS message.
javax.jms.JMSException

close

public void close()
Interrupts the daemons and closes the connection.


onException

public void onException(javax.jms.JMSException exc)
Implements the javax.jms.ExceptionListener interface for catching the failures of the connection to the remote JMS server.

Reacts by launching a reconnection process.

Specified by:
onException in interface javax.jms.ExceptionListener

onMessage

public void onMessage(javax.jms.Message jmsMessage)
Implements the javax.jms.MessageListener interface for processing the asynchronous deliveries coming from the foreign JMS server.

Specified by:
onMessage in interface javax.jms.MessageListener

doConnect

protected void doConnect()
                  throws javax.jms.JMSException
Opens a connection with the foreign JMS server and creates the JMS resources for interacting with the foreign JMS destination.

Throws:
javax.jms.JMSException - If the needed JMS resources could not be created.

setConsumer

protected void setConsumer()
                    throws javax.jms.JMSException
Sets the JMS consumer on the foreign destination.

Throws:
javax.jms.JMSException - If the JMS consumer could not be created.

unsetConsumer

protected void unsetConsumer()
Unsets the JMS consumer.


acknowledge

protected void acknowledge(Message message)
Acknowledges a message successfuly delivered to the foreign JMS server.


Joram ${version}

Copyright © 2005 Scalagent - All rights reserved