ch.epfl.lsr.apex.services
Class APEXService

java.lang.Object
  extended bych.epfl.lsr.apex.services.APEXService
Direct Known Subclasses:
APEXReliableBroadcastService, APEXReportService

public abstract class APEXService
extends Object

The APEXService gives several properties to an APEX service. It defines a set of option identifiers it is able to handle.

Author:
Marc Stoecklin

Field Summary
protected  APEXManager manager
          The associated manager
static String SERVICENAME
          The Service name
 
Constructor Summary
APEXService()
           
 
Method Summary
abstract  Hashtable getOptions()
          Offers a Hashtable containing all identifiers of options this service is able to handle.
abstract  void handleDiscarded(APEXOption option, APEXMessage message, int code, String reason, String hopName)
          Is called by the 'APEXRelayManager' if a message is discarded since the relay wasn't able / gave up establishing a connection to a destination after serveral attempts or the message hasn't been accepted.
abstract  void handleMessage(APEXMessage message)
          Handles an incoming message destined explicitly to this service.
abstract  void handleOption(APEXOption option, APEXMessage message, String hopName)
          Handles an option is found on an incoming message (handled the first time before even sending the message).
abstract  void handleSent(APEXOption option, APEXMessage message, APEXReply reply, String hopName)
          Is called by the 'APEXRelayManager' if a message is sent to another entity, say an or an message is returned - but at least, the message HAS BEEN sent!
 void setManager(APEXManager manager)
          Updates the manager of this service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SERVICENAME

public static String SERVICENAME
The Service name


manager

protected APEXManager manager
The associated manager

Constructor Detail

APEXService

public APEXService()
Method Detail

handleMessage

public abstract void handleMessage(APEXMessage message)
Handles an incoming message destined explicitly to this service.

Parameters:
message - The incoming message to handle

handleOption

public abstract void handleOption(APEXOption option,
                                  APEXMessage message,
                                  String hopName)
                           throws APEXOptionException
Handles an option is found on an incoming message (handled the first time before even sending the message).
The applicable endpoints (final explicitly used in final options) can be read of the 'APEXOption's method 'getApplicableEndpoints'.

Parameters:
option - The option to handle
message - The whole message where the option is nested in
hopName - The name of the hop (endpoint address or administrative domain)
Throws:
APEXOptionException - Is thrown if the option isn't well-formed.
See Also:
APEXOption

handleSent

public abstract void handleSent(APEXOption option,
                                APEXMessage message,
                                APEXReply reply,
                                String hopName)
Is called by the 'APEXRelayManager' if a message is sent to another entity, say an or an message is returned - but at least, the message HAS BEEN sent!
The intend is to offer a possibility in continuing the action of the service, e.g. the 'APEXReportService' may send a status report.

Parameters:
option - The option to handle
message - The message successfully sent (modified message)
reply - The reply received by the next hop
hopName - The name of the hop (endpoint address or administrative domain)

handleDiscarded

public abstract void handleDiscarded(APEXOption option,
                                     APEXMessage message,
                                     int code,
                                     String reason,
                                     String hopName)
Is called by the 'APEXRelayManager' if a message is discarded since the relay wasn't able / gave up establishing a connection to a destination after serveral attempts or the message hasn't been accepted.

Parameters:
option - The option to handle
message - The message successfully sent (modified message)
hopName - The name of the hop (endpoint address or administrative domain)

getOptions

public abstract Hashtable getOptions()
Offers a Hashtable containing all identifiers of options this service is able to handle. The content of each entry should be a handler (normally this) for the corresponding identifyer.
If no options are handled, the value must be null.

Returns:
Hashtable containing option identifiers this services handles as well as their corresponding handlers.

setManager

public void setManager(APEXManager manager)
Updates the manager of this service.

Parameters:
manager - The manager of this service