com.ls.lars.server
Class AgentMessageRouter

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

public final class AgentMessageRouter
extends AgentTemplate

This class is the wrapper agent for the MessageRouter class. Almost every agent sends AgentMessageRouter a register message in its initialization phase (see AgentTemplate.initializeMessages()) to become registered in the local platform's message router. If an agent terminates, it sends a sender_rip service message (AgentMessageRouter is a service provider for that), see AgentTemplate.terminateAction()). Additionally AgentMessageRouter is responsible for registerering and unregistering service providers. It is also responsible for maintaining message groups to which agents can be subscribed and unsubscribed. Finally AgentMessageRouter is used by agents that have moved, to tell their home platform's message router their new location.

Note: AgentMessageRouter logs ERROR and WARNING log information in both the system's log file and it's own log file, all log messages with a less important log level are logged only in AgentMessageRouter's own log file.


to Class Specification
  Incoming Messages:
      AgentMessageRouter offers the following services.
      Input parameters you have to specify are listed with the messages
      and must be transmitted using a Map.
      -----------------------------------------------------------------------
      notify_agent_connected
      -----------------------------------------------------------------------
      Function:   Registers the sender of this message at the
                  AgentMessageRouter for being notified, as soon as
                  one or more defined agent(s) got connected to
                  the local platform.
      Parameters: awaitedAgent    (String or Map)
      Responses:  agent_connected, as soon as awaitedAgent has been
                  connected to the platform.
                  Content of this message is the name of the connected
                  agent.
      -----------------------------------------------------------------------
      agent_connected
      -----------------------------------------------------------------------
      Function:   Notifies the AgentMessageRouter that a given agent
                  connectedAgent is available on the platform.
                  When the AgentMessageRouter receives this message,
                  it will notify all registered agents, who wants
                  to get informed about the availability of
                  connectedAgent.
                  Note:
                  The AgentMessageRouter interprets this message for
                  internal use, only. Therefore the AgentMessageRouter
                  checks the sender of this message in order to prevent
                  any misuse of it.
      Parameters: connectedAgent (String)
      Responses:  none
      -----------------------------------------------------------------------
      notify_service_status_changed
      -----------------------------------------------------------------------
      Function:   Registers the sender of this message at the
                  AgentMessageRouter for being notified, when the status of a
                  defined service has changed (i.e. a service provider 
                  registers or unregisters for that service).
      Parameters: awaitedService (String)
      Response:   service_status_changed, every time the status of that service
                  has changed.
                  Content of this message is:
                   - the name of the service
                   - the string "INCREASED" or "DECREASED", depending whether
                     a service provider did register or unregister
                   - the actual number of service providers for that service
                  Note:
                  The 'service_status_changed' response message can only be
                  sent by the message router. If you want to prevent the
                  misuse of this message by other parties, you should ensure
                  the message's sender to be Message.ADDRESS_LARS_INTERNAL.
      -----------------------------------------------------------------------
      initialize_inbox_check
      -----------------------------------------------------------------------
      Function:   Registers this agent to the notifierAgent
                  (mostly AgentCron) for being notified regularly,
                  in order to check the inbox size of all connected
                  messengers. This check implies a warning, which
                  will be written to the SystemLogger, if the size of
                  an inbox exceeds the given delimiterSize.
                  The period of getting notified will
                  be structured as in AgentCron.
      Parameters: notifierAgent (String)
                  delimiterSize (String)
                  period        (Map) (compare AgentCron).

      For configuring the inbox_check the right way, you should place the
      following message into the config file of AgentMessageRouter
      (the period definition can be changed to your needs):

         
            startup_constraint
            
               AgentCron
               
                  check_inbox_size
                  
                     3
                     AgentCron
                     
                        INTERVAL
                        10
                        0
                        0
                     
                  
               
            
         

      Responses:  none
      -----------------------------------------------------------------------
      check_inbox_size
      -----------------------------------------------------------------------
      Function:   Tells the AgentMessageRouter to check the inboxes
                  of all connected messengers.
                  Normally, this message is being sent from the
                  notifierAgent as given in the
                  initialize_inbox_check message.
      Parameters: none
      Responses:  none
      -----------------------------------------------------------------------
      agent_not_notified
      -----------------------------------------------------------------------
      Function:   Informs the AgentMessageRouter that its notification
                  request per notify_agent has not been
                  processed properly.
      Parameters: same information as being sent with the according
                  notify_agent message
      Responses:  none
      -----------------------------------------------------------------------
      register
      -----------------------------------------------------------------------
      Function:   Tells the lars platform's message router to forward any
                  messages to the sender to the agent message router
                  specified in the parameter. The newMessageRouter is the
                  complete address of the agent message router which will
                  handle further messages to the sender.
      Parameters: newMessageRouter (String)
      Responses:  none
      -----------------------------------------------------------------------
      unregister
      -----------------------------------------------------------------------
      Function:   Removes a forwarding entry from the platform's
                  message router.
      Parameters: none
      Responses:  none
      -----------------------------------------------------------------------
      register_service
      -----------------------------------------------------------------------
      Function:   sender wants to become a service provider for the 
                  given services
      Parameters: service (String) or services (List);
                  The service(s) this agent wants to become a service 
                  provider for.
      Responses:  none
      Note:  If multiple services are specified (message content is a
             Collection), the agent is registered as service provider for
             all services or for none of them.
      -----------------------------------------------------------------------
      unregister_service
      -----------------------------------------------------------------------
      Function:   sender doesn't want to be a service provider for 
                  the specified services any more
      Parameters: service (String) or services (List);
                  The service(s) this agent doesn't want
                  to be a service provider for any more.
      Responses:  none
      -----------------------------------------------------------------------
      unregister_all_services
      -----------------------------------------------------------------------
      Function:   sender doesn't want to be a service provider for any 
                  service
      Parameters: none
      Responses:  none
      -----------------------------------------------------------------------
      subscribe_to_message_group
      -----------------------------------------------------------------------
      Function:   subscribes a single agent or a list of agents
                  to the specified message group. If the group
                  is not existing, a new group is created.
                  Any message sent to this group will be
                  published to all subscribed agents.
      Parameters: group: the name of the group to subscribe to.
                  agent (String) or agent (List):
                     the agent(s) that should be subscribed
                  transaction (String):
                     on (default): subscribe all agents or none of them
                     off: subscribe as many agents as possible
      Responses:  subscribe_to_message_group_succeeded:
                      if all agent(s) could be subscribed,
                      content of the answer is the content of the request
                  subscribe_to_message_group_failed:
                      if the agent(s) could not be subscribed,
                      content of the answer is the content of the request
                  subscribe_to_message_group_partially:
                      If not all agents could be subscribed.
                      This answer can be sent only, if the parameter
                      'transaction' of the request was set to 'off'.
                      Content of this answer is the content of
                      the request plus the two additional keys/value pairs:
                        succeeded: value is a collection of names of agents,
                                   that are now subscribed to the message
                                   group
                        failed:    value is a collection of names of agents,
                                   that could not be subscribed to the
                                   message group
      Note:  If multiple agents are specified (value of key 'agent' in
             message content is a Collection), all of those agents are
             added to the specified message group or none of them.
      -----------------------------------------------------------------------
      unsubscribe_from_message_group
      -----------------------------------------------------------------------
      Function:   unsubscribes a single agent or a list of
                  agents from the specified message group.
                  If the group gets empty it is removed from
                  the list of message groups.
      Parameters: group: the name of the group to unsubscribe from
                  agent (String) or agent (List);
                      The agent(s) that should be unsubscribed.
      Responses:  unsubscribe_from_message_group_succeeded
                      if all agents could be unsubscribed
                  unsubscribe_from_message_group_failed
                      if not all agents could be unsubscribed
                  Content of both messages is the content of
                  the original message.
      -----------------------------------------------------------------------
      unsubscribe_from_all_message_groups
      -----------------------------------------------------------------------
      Function:   unsubscribes a single agent from all message
                  groups it is subscribed to. All groups that
                  get empty are removed from the list of
                  message groups.
      Parameters: agent (String)
                      The agent that should be unsubscribed.
      Responses:  unsubscribe_from_all_message_groups_succeeded
                      if the agent could be unsubscribed from
                      all groups.
                  unsubscribe_from_all_message_groups_failed
                      if the agent could not be unsubscribed
                      from all groups.
                  Content of both messages is the content of
                  the original message.
      -----------------------------------------------------------------------
      remove_message_group
      -----------------------------------------------------------------------
      Function:   removes a complete message group from the
                  list of message groups
      Parameters: group (String)
                      the name of the group that should be removed
      Responses:  remove_message_group_succeeded
                      if the group could be removed, or did not exist
                  remove_message_group_failed
                      if the message or the group name are malformed
                  Content of both messages is the content of
                  the original message.
      -----------------------------------------------------------------------
      close_connection
      -----------------------------------------------------------------------
      Function:   AgentMessageRouter will instruct the underlying
                  message router to send a 'close_connection'
                  message to all connected messengers.
      Parameters: none
      Responses:  none
      Note:       This message can be send either by the AgentManager,
                  or by the message router. Other originators will
                  be ignored.
      -----------------------------------------------------------------------
      sender_rip
      -----------------------------------------------------------------------
      Function:   sender died and wants all references to him
                  to be removed (service registrations, message groups,
                  forwards, agent connect-notifications)
      Parameters: none
      Responses:  none
      -----------------------------------------------------------------------
      log_system_information
      -----------------------------------------------------------------------
      Function:   logs all known services, message groups and platforms
      Parameters: none
      Responses:  none
      -----------------------------------------------------------------------
      ask_group_members
      -----------------------------------------------------------------------
      Function:   asks for members of one or multiple message groups
      Parameters: Map with
                       key 'group': value is a String or a List of Strings
                                    specifying the name of the group(s) the
                                    sender is interested in
      Response:   response_group_members message:
                      hash content contains the key 'group' and as value one
                      Map or a List of maps (one for each
                      group of the request) with
                        - the key 'name' and as value the group name
                        - the key 'agent' and as value the subscribed
                          agent(s) (String or List)
                        - the key 'error' and as value
                          ILarsConstants.NO_GROUP_AVAILABLE, if the group
                          does not exist or is empty
      -----------------------------------------------------------------------
      ask_service_provider_members
      -----------------------------------------------------------------------
      Function:   asks for providers for one or multiple services
      Parameters: Map with
                       key "service_provider":
                                    value is a String or a List of Strings
                                    specifying the name of the service(s)
                                    the sender is interested in
      Response:   response_service_provider_members message:
                      hash content contains the key "service_provider" and
                      as value one Map or a List of Maps (one
                      for each service of the request) with
                        - the key 'name' and as value the service name
                        - the key 'agent' and as value the service provider
                          agent(s) (String or List)
                        - the key 'error' and as value
                          ILarsConstants.NO_SERVICE_PROVIDER_AVAILABLE,
                          if the service is unknown or no service providers
                          for it are registered
      -----------------------------------------------------------------------
      show_all_provided_services
      -----------------------------------------------------------------------
      Function:   asks for a list of services, which are provided on the
                  local lars platform.
      Parameters: none
      Response:   provided_services message:
                       hash content contains the key "service" and as value a
                       List with the names of all provided services.
  ---------------------------------------------------------------------------
  Config File:
      AgentMessageRouter does not have a config file by default.
      It should however register the log_system_information service
      (with help of a register_service message in its config file)
      if system information should be available in the logfile:
 
<MESSAGE> <service>register_service</service> <content>log_system_information</content> </MESSAGE>
      When the message router shall watch the inbox size of all
      connected messengers, the config file of AgentMessageRouter
      has to contain the according settings for sending the required
      'initialize_inbox_check' message. As the initialization of the
      inbox checks sends a 'notify_agent' to the given notifier agent,
      the config file of AgentMessageRouter should contain an adequate
      'startup_constraint' message (compare to AgentTemplate).
 

Version:
$Revision: 1.21 $
Author:
Last modified by $Author: MHeitz $
See Also:
Serialized Form

Field Summary
protected  String revisionInformation
          revision information string, managed by our version control system
 
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 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
AgentMessageRouter(String agentName, String homePlatform, List agentConfigFiles)
          Constructor with the agentName, its homePlatform and a List containing the names of the configuration file(s) of the new agent.
It calls super(agentName, homePlatform, agentConfigFiles) and gets a reference to the local platform's message router by calling MessageRouter.getMessageRouter().
 
Method Summary
 void executeWhileRunning()
          Receives a message from this agent's inbox.
protected  String getRevisionInformation()
          gets the revision information of this agent
 void initializeMessages()
          Registers as a service provider for "sender_rip" service, that is sent, if an agent terminates.
protected  boolean interpretAgentConnected(Message currentMessage)
          Notifies this agent that a specifc agent has been connected to the platform
protected  boolean interpretAgentNotNotified(Message currentMessage)
          Writes a log message to the system's log file and to the agent's log file, because a "agent_not_notified" message was received (probably from AgentCron).
protected  boolean interpretAskGroupMembers(Message currentMessage)
          interprets the message "ask_group_members" and responds by sending the names of the agents to the requester
protected  boolean interpretAskServiceProviderMembers(Message currentMessage)
          interprets the message "ask_service_providers_members" and responds by sending the names of the agents to the requester
protected  boolean interpretCheckInboxSize(Message currentMessage)
          Checks the inbox size of all local agents.
protected  boolean interpretCloseConnection(Message currentMessage)
          Instructs the underlying message router to forward this 'close_connection' to all connected messengers.
protected  boolean interpretInitializeInboxCheck(Message currentMessage)
          Initializes the settings for periodical checking the inbox size of all messengers.
protected  boolean interpretLogSystemInformation(Message currentMessage)
          Writes all registered services to the system logfile.
protected  boolean interpretNotifyAgentConnected(Message currentMessage)
          Asks AgentMessageRouter to notify the sender of the given message, if any of the agents given in the content of this message connects or is currently connected.
protected  boolean interpretNotifyServiceStatusChanged(Message currentMessage)
          Asks AgentMessageRouter to notify the sender of the given message, if the status of the given service has changed.
protected  boolean interpretRegister(Message currentMessage)
          registers the sender of the given message in this platform's message router
protected  boolean interpretRegisterService(Message currentMessage)
          Adds an agent to the list(s) of service providers for the specified service(s).
protected  boolean interpretRemoveMessageGroup(Message currentMessage)
          Removes the specified message group from the list of all message groups.
protected  boolean interpretSenderRip(Message currentMessage)
          Removes an agent from all lists of service providers, afterwards that agent is no service provider any more.
protected  boolean interpretShowAllProvidedServices(Message currentMessage)
          interprets the message "show_all_provided_services", which returns the names of all services being provided on the local lars platform.
protected  boolean interpretSubscribeToMessageGroup(Message currentMessage)
          Adds the specified agent(s) to the message group specified.
protected  boolean interpretUnregister(Message currentMessage)
          deletes the sender of the given message from register in MessageRouter
protected  boolean interpretUnregisterAllServices(Message currentMessage)
          Removes an agent from all lists of service providers, afterwards that agent is no service provider any more.
protected  boolean interpretUnregisterService(Message currentMessage)
          Removes an agent from the list(s) of service providers for the specified service(s)
protected  boolean interpretUnsubscribeFromAllMessageGroups(Message currentMessage)
          Removes the specified agent from all message groups existing.
protected  boolean interpretUnsubscribeFromMessageGroup(Message currentMessage)
          Removes the specified agent(s) from the message group specified.
 boolean terminateAction()
          Checks, if AgentMessageRouter's run level is less than STOPPED and AgentMessageRouter has clients waiting for connection notifications AgentMessageRouter has service provider(s) as clients AgentMessageRouter has message group member(s) as clients If none of those conditions is true, super.terminateAction is called.
 
Methods inherited from class com.ls.lars.server.AgentTemplate
executeLifeCycle, getAgentRevisionInformation, getIPKIHandler, getOwnPublicKeyCertificate, initializeAction, interpret, interpretAccessDenied, interpretCheckRegisteredServices, interpretDefineObject, interpretDeliveryFailed, interpretGetRevisionInformation, interpretInterpretationSuccessful, interpretLoadObject, interpretLogInbox, interpretMonitorLookup, interpretNotifiedAgent, interpretNotifyCanceled, interpretNotifyNotCanceled, interpretNotUnderstood, interpretPing, 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 class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ls.lars.communication.IToLars
start
 

Field Detail

revisionInformation

protected String revisionInformation
revision information string, managed by our version control system
Constructor Detail

AgentMessageRouter

public AgentMessageRouter(String agentName,
                          String homePlatform,
                          List agentConfigFiles)
Constructor with the agentName, its homePlatform and a List containing the names of the configuration file(s) of the new agent.
It calls super(agentName, homePlatform, agentConfigFiles) and gets a reference to the local platform's message router by calling MessageRouter.getMessageRouter().
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.
Method Detail

getRevisionInformation

protected String getRevisionInformation()
gets the revision information of this agent
Overrides:
getRevisionInformation in class AgentTemplate
Returns:
the revision information

initializeMessages

public void initializeMessages()
Registers as a service provider for "sender_rip" service, that is sent, if an agent terminates.

Note: AgentTemplate.initializeMessages() is not called, because otherwise this AgentMessageRouter would send a "register" message to itself

Overrides:
initializeMessages in class AgentTemplate

executeWhileRunning

public void executeWhileRunning()
Receives a message from this agent's inbox. If the message is not for this agent, the local lars platform's MessageRouter is called to route the Message (see this.messageRouter.routeMessage(currentMessage)); else it is interpreted.
Overrides:
executeWhileRunning in class AgentTemplate

terminateAction

public boolean terminateAction()
Checks, if AgentMessageRouter's run level is less than STOPPED and If none of those conditions is true, super.terminateAction is called.
Overrides:
terminateAction in class AgentTemplate
Returns:
false, if any of the above conditions is true; super.terminateAction() else
See Also:
AgentTemplate.terminateAction()

interpretNotifyAgentConnected

protected boolean interpretNotifyAgentConnected(Message currentMessage)
Asks AgentMessageRouter to notify the sender of the given message, if any of the agents given in the content of this message connects or is currently connected.
Parameters:
currentMessage - "notify_agent_connected" message
Returns:
true, if registering this notification request is successful; false else

interpretAgentConnected

protected boolean interpretAgentConnected(Message currentMessage)
Notifies this agent that a specifc agent has been connected to the platform
Overrides:
interpretAgentConnected in class AgentTemplate
Parameters:
currentMessage - "agent_connected" message
Returns:
true when the message has been handled successful

interpretNotifyServiceStatusChanged

protected boolean interpretNotifyServiceStatusChanged(Message currentMessage)
Asks AgentMessageRouter to notify the sender of the given message, if the status of the given service has changed.
Parameters:
currentMessage - "notify_service_status_changed" message
Returns:
true, if registering this notification request is successful; false else

interpretInitializeInboxCheck

protected boolean interpretInitializeInboxCheck(Message currentMessage)
Initializes the settings for periodical checking the inbox size of all messengers.
Parameters:
currentMessage - "initialize_inbox_check" message
Returns:
always true

interpretCheckInboxSize

protected boolean interpretCheckInboxSize(Message currentMessage)
Checks the inbox size of all local agents. If the size exceeds the delimiter as given in interpretInitializeInboxCheck(Message), a warning will be logged out.
For checking the inbox within a defined interval, AgentCron will be utilized.
(The configuration of this schedule is being done with the "initialize_inbox_check" message).
Parameters:
currentMessage - "check_inbox_size" message
Returns:
true, if successful; else false
See Also:
AgentCron

interpretAgentNotNotified

protected boolean interpretAgentNotNotified(Message currentMessage)
Writes a log message to the system's log file and to the agent's log file, because a "agent_not_notified" message was received (probably from AgentCron).
Parameters:
currentMessage - "agent_not_notified" message
Returns:
always returns true

interpretRegister

protected boolean interpretRegister(Message currentMessage)
registers the sender of the given message in this platform's message router
Parameters:
currentMessage - "register" message
Returns:
true, if successful; else false
See Also:
MessageRouter.addForward(java.lang.String, java.lang.String)

interpretUnregister

protected boolean interpretUnregister(Message currentMessage)
deletes the sender of the given message from register in MessageRouter
Parameters:
currentMessage - message to be interpreted
Returns:
boolean if successful true, else false
See Also:
MessageRouter.removeForward(java.lang.String)

interpretRegisterService

protected boolean interpretRegisterService(Message currentMessage)
Adds an agent to the list(s) of service providers for the specified service(s).

Note: If multiple services are specified (message content is a Collection), the agent is registered as service provider for all services or for none of them.

Overrides:
interpretRegisterService in class AgentTemplate
Parameters:
currentMessage - "register" message containing one or more services in its content
Returns:
true, if registering the service(s) succeeded; false else

interpretUnregisterService

protected boolean interpretUnregisterService(Message currentMessage)
Removes an agent from the list(s) of service providers for the specified service(s)
Parameters:
currentMessage - "unregister_service" message containing one or more services in its content
Returns:
true, if unregistering the service(s) succeeded; false else

interpretUnregisterAllServices

protected boolean interpretUnregisterAllServices(Message currentMessage)
Removes an agent from all lists of service providers, afterwards that agent is no service provider any more.
Parameters:
currentMessage - "unregister_all_services" message
Returns:
true, if unregistering the services succeeded; false else

interpretSubscribeToMessageGroup

protected boolean interpretSubscribeToMessageGroup(Message currentMessage)
Adds the specified agent(s) to the message group specified.

Note: If multiple agents are specified (value of key 'agent' in message content is a Collection), the behaviour depends on the value of the 'transaction' key in the content: If it is not set or it is set to 'on', all of the specified agents or none of them are added to the given message group; else all possible ones are added.

Parameters:
currentMessage - "subscribe" message containing the group name and one or more agent names in the content
Returns:
true, if subscribing the agent(s) succeeded; false if not all agents could be subscribed

interpretUnsubscribeFromMessageGroup

protected boolean interpretUnsubscribeFromMessageGroup(Message currentMessage)
Removes the specified agent(s) from the message group specified.
Parameters:
currentMessage - "unsubscribe" message containing the group name and one or more agent names as content
Returns:
true, if unsubscribing the agent(s) succeeded; false if not all agents could be unsubscribed

interpretUnsubscribeFromAllMessageGroups

protected boolean interpretUnsubscribeFromAllMessageGroups(Message currentMessage)
Removes the specified agent from all message groups existing.
Parameters:
currentMessage - "unsubscribe" message containing the agent name in the content
Returns:
true, if unsubscribing the agent succeeded; false the agent could not be unsubscribed from all groups

interpretRemoveMessageGroup

protected boolean interpretRemoveMessageGroup(Message currentMessage)
Removes the specified message group from the list of all message groups. No further messages can be sent to that group.
Parameters:
currentMessage - message containing the goup name in the content to be removed
Returns:
true, if the group could be removed; false otherwise

interpretCloseConnection

protected boolean interpretCloseConnection(Message currentMessage)
Instructs the underlying message router to forward this 'close_connection' to all connected messengers.
Overrides:
interpretCloseConnection in class AgentTemplate
Parameters:
currentMessage - "close_connection" message
Returns:
false when another instance than AgentManager or the message router tried to misuse this message, else true

interpretSenderRip

protected boolean interpretSenderRip(Message currentMessage)
Removes an agent from all lists of service providers, afterwards that agent is no service provider any more.
Parameters:
currentMessage - "sender_rip" message
Returns:
true, if unregistering the services succeeded; false else

interpretLogSystemInformation

protected boolean interpretLogSystemInformation(Message currentMessage)
Writes all registered services to the system logfile.
Parameters:
currentMessage - "log_system_information" message
Returns:
always true

interpretAskGroupMembers

protected boolean interpretAskGroupMembers(Message currentMessage)
interprets the message "ask_group_members" and responds by sending the names of the agents to the requester
Parameters:
currentMessage - "ask_group_members" message, that contains a "group" key in its content's Map.
Returns:
true, if the message could be interpreted; false else

interpretAskServiceProviderMembers

protected boolean interpretAskServiceProviderMembers(Message currentMessage)
interprets the message "ask_service_providers_members" and responds by sending the names of the agents to the requester
Parameters:
currentMessage - "ask_service_provider_members" message
Returns:
true, if the message could be interpreted; false else

interpretShowAllProvidedServices

protected boolean interpretShowAllProvidedServices(Message currentMessage)
interprets the message "show_all_provided_services", which returns the names of all services being provided on the local lars platform.
Parameters:
currentMessage - "show_all_provided_services" message
Returns:
always true