com.ls.lars.server
Class AgentSocketListener
java.lang.Object
|
+--java.lang.Thread
|
+--com.ls.lars.communication.CommunicationTemplate
|
+--com.ls.lars.server.AgentTemplate
|
+--com.ls.lars.server.AgentListener
|
+--com.ls.lars.server.AgentSocketListener
- All Implemented Interfaces:
- ICommunication, IToLars, Runnable, Serializable
- Direct Known Subclasses:
- AgentJSecureSocketListener, AgentJSocketListener
- public class AgentSocketListener
- extends AgentListener
This class is the wrapper agent needed for the communication of a socket listener.
It waits for incoming socket requests from remote agents.
to Class Specification
Incoming Messages:
AgentSocketListener understands the following messages.
Input parameters to be specified are listed with the messages.
-----------------------------------------------------------------------
set_max_message_length (Config)
-----------------------------------------------------------------------
Function: Sets the maximal message length to be read from a socket.
Parameters: message length (String)
Responses: none
Note: This message can only be sent from a config file.
-----------------------------------------------------------------------
set_compression (Config)
-----------------------------------------------------------------------
Function: Sets the compression settings to compress
messages.
Parameters: connectionCompressionType: zip, gzip (short)
connectionAutoCompression: on, off (boolean)
connectionAutoCompressionStartSize: (int)
connectionCompressionLevel: 0..9 (int)
connectionZipEntryName: (String)
Responses: none
Example:
set_compression
gzip
off
4096
7
Message
-----------------------------------------------------------------------
Config File:
The AgentSocketListener's config file usually has two entries:
The first is for setting the port
the Agent shall listen on for
incoming communication requests.
The second entry is for setting the maximal length of messages
being read from the socket. The message length is to be the
string representation of an integer value, which is to be
placed directly into the tag (without additional
describing tags).
An optional entry is for the compression settings.
There is no need to implement these settings. Default is to use no
compression. If you want to use compression you have all possibilities to
set the configurations.
If you set the compression type, it will be used the compression you have
inserted.
If you set auto compression on, it will only compress if a given message
size was reached. For the auto compression there exists a default start
size, but you can set a specific size with the autoCompressionStartSize
tag.
The compression level tag is only for zip compression. You know that in
zip is the possibility to compress more or less. 0 stands for no
compression and 9 for maximum compression.
The zip entry name is not needed. There is only one entry in a zip stream
(it is only for zip). But if you want you can specify a name.
-----------------------------------------------------------------------
Notes:
The messages that AgentSocketListener will understand have the same XML
format as the individual messages in the config files.
You can only inject one message at a time using AgentSocketListener.
Attention: This agent is using a communication, that is sending and
receiving plain XML text. So if you want that the text to be
encrypted, configure the agent in the configuration file to use
the PKI encryption.
- Version:
- $Revision: 1.13 $
- Author:
- Last modified by $Author: OHittmeyer $
- See Also:
- Serialized Form
Fields inherited from class com.ls.lars.server.AgentTemplate |
agentMaxPool, agentMessageRouterName, agentMinPool, defaultServiceAccessPermission, defaultServiceAccessPrivilege, dynamicObjectController, FULL_SERVICE_ACCESS, iXMLHandlerForConfigLoader, localPlatform, maxInvokeStackCounter, NO_SERVICE_ACCESS, RUN_LEVEL_ACTIONS_INITIALIZED, RUN_LEVEL_CONFIG_FILE_INTERPRETED, RUN_LEVEL_CONFIG_FILE_READ, RUN_LEVEL_EMBRYONIC, RUN_LEVEL_INTERPRET_METHODS_REGISTERED, RUN_LEVEL_POOL_INITIALIZED, RUN_LEVEL_RUNNING, RUN_LEVEL_STOPPED, RUN_LEVEL_TERMINATED |
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 |
Methods inherited from class com.ls.lars.server.AgentTemplate |
executeLifeCycle, executeWhileRunning, getAgentRevisionInformation, getIPKIHandler, getOwnPublicKeyCertificate, initializeAction, interpret, interpretAccessDenied, interpretAgentConnected, interpretCheckRegisteredServices, interpretCloseConnection, interpretDefineObject, interpretDeliveryFailed, interpretGetRevisionInformation, interpretInterpretationSuccessful, interpretLoadObject, interpretLogInbox, interpretMonitorLookup, interpretNotifiedAgent, interpretNotifyCanceled, interpretNotifyNotCanceled, interpretNotUnderstood, interpretPing, interpretRegisterService, interpretSendAsConfigured, interpretSetAccessPrivileges, interpretSetForeignPublicKeyCertificate, interpretSetLog, interpretSetOwnPublicKeyCertificate, interpretSetPkiEnvironment, interpretSetPkiMessages, interpretSetPrivateKey, interpretSetRunLevel, interpretSignatureNotValid, interpretStartupConstraint, loadConfigFile, performDefaultBehavior, reconnectAfterMigration, registerInterpretMethods, registerInterpretMethods, registerInterpretMethods, reInitializeAction, setAgentMessageRouterName, setIXMLHandler, setLocalPlatform, setPKIMessage, toString |
Methods inherited from class com.ls.lars.communication.CommunicationTemplate |
addConnectionParameter, checkSendSystemReply, connect, createReplyId, disconnect, disconnectForMigration, finalize, forwardMessage, forwardMessage, getAgentName, getConnectionParameters, getInboxSize, getLarsHost, getNumberOfProcessedMessages, getNumberOfProcessedMessagesPerMinute, getStartTime, isConnected, logInbox, receiveBlockedMessage, receiveBlockedMessage, run, sendMessage, sendSynchronousRequest, sendSynchronousRequest, setConnectionParameters, setLog, setMeantimeBetweenConnectionCheck, 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, yield |
Methods inherited from interface com.ls.lars.communication.IToLars |
start |
revisionInformation
protected String revisionInformation
- revision information string, managed by our version control system.
socketListener
protected SocketListener socketListener
- manages incoming client requests via sockets
SOCKET_DEFAULT_PORT
protected static final int SOCKET_DEFAULT_PORT
- default port for socket connections: 2000
AgentSocketListener
public AgentSocketListener(String agentName,
String homePlatform,
List agentConfigFiles)
- Constructor that only calls
super(agentName, homePlatform, agentConfigFiles)
- Parameters:
agentName
- name of the agent (example: xyz )homePlatform
- name of the home platform where the agent was created (example: 195.52.158.233/lars)agentConfigFiles
- config file(s), which should be read by the agent when it starts up
getRevisionInformation
protected String getRevisionInformation()
- gets the revision information of this agent
- Overrides:
getRevisionInformation
in class AgentListener
- Returns:
- the revision information
initializeMessages
public void initializeMessages()
- sends initialization messages and initializes and starts socket listener thread
- Overrides:
initializeMessages
in class AgentListener
terminateAction
public boolean terminateAction()
- terminates corresponding listener thread and calls super.terminateAction()
- Overrides:
terminateAction
in class AgentTemplate
- Returns:
AgentTemplate.terminateAction()
interpretSetMaxMessageLength
protected boolean interpretSetMaxMessageLength(Message currentMessage)
- Sets the maximal message length of a message to be read from the socket. For security reasons, the sender of
the message is checked: If the message is not read from a config file, it's content is ignored and a warning
is written to the log file.
Note: the maximal message length is only used in the initializeMessages()
method,
when a new socket listener is created.
- Parameters:
currentMessage
- message which should contain the maximal message length- Returns:
- true, if setting the maximal message length succeeded; false else
interpretSetCompression
protected boolean interpretSetCompression(Message currentMessage)
- Sets the compression settings. For security reasons, the sender of the message is checked: If the message is
not read from a config file, it's content is ignored and a warning is written to the log file.
- Parameters:
currentMessage
- message which should contain the maximal message length- Returns:
- true, if setting the maximal message length succeeded; false else
createSocketListener
protected SocketListener createSocketListener()
- creates and returns the appropriate socket listener (here: a SocketListener)
- Returns:
- new
SocketListener(this, port)
setDefaultPort
protected void setDefaultPort()
- sets port to the default port (here:
SOCKET_DEFAULT_PORT
)
- Overrides:
setDefaultPort
in class AgentListener