ie.nuigalway.ecrg.jade.jmsagentgateway
Class JmsListener

java.lang.Object
  |
  +--ie.nuigalway.ecrg.jade.jmsagentgateway.JmsListener
All Implemented Interfaces:
javax.jms.ExceptionListener, javax.jms.MessageListener

public class JmsListener
extends java.lang.Object
implements javax.jms.MessageListener, javax.jms.ExceptionListener

Listener for destinations in the subscription manager

Version:
0.5 12 January 2004
Author:
Edward Curry

Field Summary
private  jade.content.ContentManager cm
           
private  jade.content.lang.Codec codec
           
private  javax.jms.Connection conn
           
private  JmsAgentGatewayGui gui
           
private  Subscription jmsSub
           
private static org.apache.log4j.Category log
           
private  jade.content.onto.Ontology ontology
           
private  ProviderInfo proInfo
           
private  javax.jms.Session session
           
private  jade.proto.SubscriptionResponder.Subscription sub
           
private  SubscriptionModel subModel
           
 
Constructor Summary
JmsListener(jade.proto.SubscriptionResponder.Subscription sub, jade.content.ContentManager cm, JmsAgentGatewayGui gui, SubscriptionModel subModel)
          Constructor for the JmsListener object
 
Method Summary
 SubscriptionModel getSubscriptionModel()
          Gets the subscriptionModel attribute of the JmsListener object
private  void incMsgCounter()
          Increment message counter tracking the number of messages sent to this subscription
 void onException(javax.jms.JMSException jmse)
          Method is executed when an execption is thrown by the JMS Provider Attempts to reconnect to the provider
 void onMessage(javax.jms.Message msg)
          Method is executed when a message is receivd from the agents queue
private  void setupConnection()
          Method is executed in order to create a connection to a JMS server and listen to the specified destination
 void stop()
          Method is executed to disconnect from a JMS server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.log4j.Category log

conn

private javax.jms.Connection conn

session

private javax.jms.Session session

sub

private jade.proto.SubscriptionResponder.Subscription sub

cm

private jade.content.ContentManager cm

codec

private jade.content.lang.Codec codec

ontology

private jade.content.onto.Ontology ontology

jmsSub

private Subscription jmsSub

proInfo

private ProviderInfo proInfo

gui

private JmsAgentGatewayGui gui

subModel

private SubscriptionModel subModel
Constructor Detail

JmsListener

public JmsListener(jade.proto.SubscriptionResponder.Subscription sub,
                   jade.content.ContentManager cm,
                   JmsAgentGatewayGui gui,
                   SubscriptionModel subModel)
            throws java.lang.Exception
Constructor for the JmsListener object

Parameters:
sub - Subscription for listener
cm - Content manager for message ontologies
gui - GUI associated with the agent
subModel - GUI Model of this subscription
Throws:
java.lang.Exception - Error during listener startup
Method Detail

setupConnection

private void setupConnection()
                      throws java.lang.Exception
Method is executed in order to create a connection to a JMS server and listen to the specified destination

Throws:
java.lang.Exception - Description of the Exception

onMessage

public void onMessage(javax.jms.Message msg)
Method is executed when a message is receivd from the agents queue

Specified by:
onMessage in interface javax.jms.MessageListener
Parameters:
msg - JMS Message received

onException

public void onException(javax.jms.JMSException jmse)
Method is executed when an execption is thrown by the JMS Provider Attempts to reconnect to the provider

Specified by:
onException in interface javax.jms.ExceptionListener
Parameters:
jmse - JMS Exception thrown

stop

public void stop()
          throws java.lang.Exception
Method is executed to disconnect from a JMS server

Throws:
java.lang.Exception - Error in closeing JMS Connection

incMsgCounter

private void incMsgCounter()
Increment message counter tracking the number of messages sent to this subscription


getSubscriptionModel

public SubscriptionModel getSubscriptionModel()
Gets the subscriptionModel attribute of the JmsListener object

Returns:
The subscriptionModel value