planet.commonapi
Interface Application

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
DHTApplication, DHTApplication, DHTApplication, DHTApplication, ScribeImpl, TrivialApplication

public interface Application
extends java.io.Serializable

Interface which an application must implement in order to run on top of the EndPoint interface.

Any implementation must include a no argument constructor.

Author:
Jordi Pujol 07-jul-2005

Method Summary
 void byStep()
          An upcall to inform this Application for a new step.
 void deliver(Id id, Message message)
          This method is called on the application at the destination node for the given id.
 boolean forward(Message message)
          This method is invoked on applications when the underlying node is about to forward the given message with the provided target to the specified next hop.
 java.lang.String getId()
          Gets the identification of this application.
 void setEndPoint(EndPoint endPoint)
          Sets the EndPoint which permits communicate with underlying node.
 void setId(java.lang.String appId)
          Sets the String identification of this application.
 Application setValues(java.lang.String applicationName)
          Sets the name for this applicaton.
 void update(NodeHandle node, boolean joined)
          Informs to the application that the node has either joined or left the neighbor set of the local node, as that set would be returned by the neighborSet call.
 

Method Detail

forward

public boolean forward(Message message)
This method is invoked on applications when the underlying node is about to forward the given message with the provided target to the specified next hop. Applications can change the contents of the message, specify a different nextHop (through re-routing), or completely terminate the message.

Parameters:
message - The message being sent, containing an internal message along with a destination key and nodeHandle next hop.
Returns:
Whether or not to forward the message further

deliver

public void deliver(Id id,
                    Message message)
This method is called on the application at the destination node for the given id.

Parameters:
id - The destination node id of the message
message - The message being sent

getId

public java.lang.String getId()
Gets the identification of this application.

Returns:
Identification of this application.

setId

public void setId(java.lang.String appId)
Sets the String identification of this application.

Parameters:
appId - Identification of this application.

setEndPoint

public void setEndPoint(EndPoint endPoint)
Sets the EndPoint which permits communicate with underlying node.

Parameters:
endPoint - EndPoint to contact that knows how talk with underlying node.

update

public void update(NodeHandle node,
                   boolean joined)
Informs to the application that the node has either joined or left the neighbor set of the local node, as that set would be returned by the neighborSet call.

Parameters:
node - Node that has joined or left the neighbor set.
joined - If true, the node has joined to the neighbor set. In other case, the node has left the neighbor set.

byStep

public void byStep()
An upcall to inform this Application for a new step. This method is invoked at the end of each simulation step. Before this, may arrive any number of application Messages, depending on your own main application.


setValues

public Application setValues(java.lang.String applicationName)
Sets the name for this applicaton.

Parameters:
applicationName - Name for this application.
Returns:
The same instance, once it has been updated.