com.ls.lars.communication
Class ClientCommunication

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.ls.lars.communication.CommunicationTemplate
              |
              +--com.ls.lars.communication.ClientCommunication
All Implemented Interfaces:
ICommunication, IToLars, Runnable, Serializable

public class ClientCommunication
extends CommunicationTemplate

This class is used to connect to the lars platform. It can be used by Applets, Java Applications and other clients to send and receive messages to/from the platform.

Version:
$Revision: 1.5 $
Author:
Last modified by $Author: MHeitz $
See Also:
CommunicationTemplate, ICommunication, Serialized Form

Fields inherited from class com.ls.lars.communication.CommunicationTemplate
agentName, homePlatform, iPKIHandler, logger, STATUS_CONNECTED, STATUS_NOT_CONNECTED
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface com.ls.lars.communication.ICommunication
AUTHENTICATION_PASSWORD, AUTHENTICATION_USER, COMPRESSION_AUTO_COMPRESSION, COMPRESSION_AUTO_COMPRESSION_START_SIZE, COMPRESSION_LEVEL, COMPRESSION_TYPE, COMPRESSION_ZIP_ENTRY_NAME, CONNECTION_TYPE, HOST_ID, HOST_IP, HOST_PORT, HTTP, J_SECURE_SOCKET, J_SOCKET, JMS, JMS_INITIAL_CONTEXT_FACTORY, JMS_JMSMESSENGER_APPLICATION_LOCATION, JMS_PROVIDER_URL, JMS_RECEIVING_QUEUE_NAME, JMS_SECURITY_CREDENTIALS, JMS_SECURITY_PRINCIPAL, JMS_SENDING_QUEUE_NAME, MAXIMUM_MESSAGE_LENGTH, PROTOCOL, RMI, SOCKET, TIMEOUT, USE_OUTBOX
 
Constructor Summary
ClientCommunication(String agentName, Map connectionParameters, IFromLars owner)
          Constructor.
 
Method Summary
 void disconnect()
          Disconnects from the LARS platform and stops the communication thread.
 void executeLifeCycle()
          This medhod waits for messages to arrive and sends them to the owner.
 void setLog(String loggerType, String loggerFile, String loggerLevel)
          Sets the log file and log level for this component.
 void setLogger(ILogger iLogger)
          Sets the logger for this component.
protected  void stopThread()
          stops the ClientCommunication thread
 
Methods inherited from class com.ls.lars.communication.CommunicationTemplate
addConnectionParameter, checkSendSystemReply, connect, createReplyId, disconnectForMigration, finalize, forwardMessage, forwardMessage, getAgentName, getConnectionParameters, getInboxSize, getLarsHost, getNumberOfProcessedMessages, getNumberOfProcessedMessagesPerMinute, getStartTime, isConnected, logInbox, receiveBlockedMessage, receiveBlockedMessage, reconnectAfterMigration, run, sendMessage, sendSynchronousRequest, sendSynchronousRequest, setConnectionParameters, setLog, setMeantimeBetweenConnectionCheck, terminateAction, waitForConnection, waitForConnection
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ls.lars.communication.IToLars
start
 

Constructor Detail

ClientCommunication

public ClientCommunication(String agentName,
                           Map connectionParameters,
                           IFromLars owner)
                    throws ConnectionException
Constructor. The user should suppy the required connection parameters within a java.lang.Map object. This constructor is used, if the agent wants to use and set up a it's own messenger (for example a SocketMessenger for socket communication). The constructor takes a java.util.Map object, containing the connection parameters being used for setting up it's own messenger. The keys for this map are defined in the ICommunication interface.
Parameters:
agentName - The name of the agent (example: "xyz@195.52.158.233/lars")
parameters - The connection parameters being used for establishing the connection
owner - The owner of this class. Required for receiving messages from the platform
Throws:
ConnectionException - if a connection cannot be established
See Also:
ClientMessengerFactory, ICommunication, IFromLars
Method Detail

stopThread

protected void stopThread()
stops the ClientCommunication thread

executeLifeCycle

public void executeLifeCycle()
This medhod waits for messages to arrive and sends them to the owner. It is usually not called explicitly!
Overrides:
executeLifeCycle in class CommunicationTemplate

disconnect

public void disconnect()
Disconnects from the LARS platform and stops the communication thread. No messages can be sent and no messages are received after disconnection.
Overrides:
disconnect in class CommunicationTemplate

setLogger

public void setLogger(ILogger iLogger)
Sets the logger for this component.
Parameters:
iLogger - an ILogger component

setLog

public void setLog(String loggerType,
                   String loggerFile,
                   String loggerLevel)
Sets the log file and log level for this component.
Parameters:
loggerType - the log type for this agent
loggerFile - the log file for this agent
loggerLevel - the log level for this agent