com.ls.lars.communication
Class JMSListener

java.lang.Object
  |
  +--com.ls.lars.communication.JMSListener
All Implemented Interfaces:
Runnable

public class JMSListener
extends Object
implements Runnable

JMSListener is used to listen to the JMS Server Queue for messages. It is used by a LARS server, started by AgentJMSListener. In addition to the listening functionality, this listener can also get ClientMessengerFactory to create a JMS messenger for the agent who sends the incoming message, if there is not one for it. In order to use JMSListener, a JMS provider for example JBoss, has to be started up first.

Version:
$Revision: 1.12 $
Author:
Last modified by $Author: CReich $

Field Summary
static int jmsListenerThreadId
          thread id for socket listeners
protected  Thread listenerThread
          reference to this thread (needed for proper thread termination)
protected  ILogger logger
          the logger used by this Listener class for logging purpose
 
Constructor Summary
JMSListener(String agentName, String newJMSServerURLAddress, String initialContext, String sendingQueueName, String receivingQueueName, String securityPrincipal, String securityCredentials)
          Constructor for JMSListener
 
Method Summary
 int nextJMSListenerId()
          returns the next unique (within this Java Virtual Machine) id to be used in a JMS listener name
 void run()
          Create a connection to the given JMS Server, so that this Listener can listen to the Queue
 void start()
          starts the listener thread and sets the thread name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jmsListenerThreadId

public static int jmsListenerThreadId
thread id for socket listeners

listenerThread

protected Thread listenerThread
reference to this thread (needed for proper thread termination)

logger

protected ILogger logger
the logger used by this Listener class for logging purpose
Constructor Detail

JMSListener

public JMSListener(String agentName,
                   String newJMSServerURLAddress,
                   String initialContext,
                   String sendingQueueName,
                   String receivingQueueName,
                   String securityPrincipal,
                   String securityCredentials)
Constructor for JMSListener
Parameters:
agentName - Agent name of the client
newJMSServerURLAddress - The url address of the JMS server
initialContext - The JNDI initial context factory, usually defined by JMS provider
sendingQueueName - The queue for sending JMS message to JMS server from within LARS
receivingQueueName - The queue for receiving JMS message to JMS server from within LARS
securityPrincipal - The security principal, can be an empty String, but must not be null
securityCredentials - The security credential, can be an empty String, but must not be null
Method Detail

start

public void start()
           throws ProgrammingException
starts the listener thread and sets the thread name
Throws:
ProgrammingException - If this listener was already started before

run

public void run()
Create a connection to the given JMS Server, so that this Listener can listen to the Queue
Specified by:
run in interface Runnable

nextJMSListenerId

public int nextJMSListenerId()
returns the next unique (within this Java Virtual Machine) id to be used in a JMS listener name
Returns:
the next JMS number