core
Class Application

java.lang.Object
  extended by core.Application
Direct Known Subclasses:
PingApplication

public abstract class Application
extends java.lang.Object

Base class for applications. Nodes that have an application running will forward all incoming messages to the application handle() method before they are processed further. The application can change the properties of the message before returning it or return null to signal to the router that it wants the message to be dropped.

In addition, the application's update() method is called every simulation cycle.

Configuration of application is done by picking a unique application instance name (e.g., mySimpleApp) and setting its type property to the concrete application class: mySimpleApp.type = SimpleApplication . These application instances can be assigned to node groups using the Group.application setting: Group1.application = mySimpleApp.


Field Summary
 java.lang.String appID
           
 
Constructor Summary
Application()
           
Application(Application app)
          Copy constructor.
 
Method Summary
 java.lang.String getAppID()
           Returns an unique application ID.
 java.util.List<ApplicationListener> getAppListeners()
           
abstract  Message handle(Message msg, DTNHost host)
          This method handles application functionality related to processing of the bundle.
abstract  Application replicate()
           
 void sendEventToListeners(java.lang.String event, java.lang.Object params, DTNHost host)
          Sends an event to all listeners.
 void setAppID(java.lang.String appID)
          Sets the application ID.
 void setAppListeners(java.util.List<ApplicationListener> aListeners)
           
abstract  void update(DTNHost host)
          Called every simulation cycle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

appID

public java.lang.String appID
Constructor Detail

Application

public Application()

Application

public Application(Application app)
Copy constructor.

Parameters:
app -
Method Detail

handle

public abstract Message handle(Message msg,
                               DTNHost host)
This method handles application functionality related to processing of the bundle. Application handles a messages, which arrives to the node hosting this application. After performing application specific handling, this method returns a list of messages. If node wishes to continue forwarding the incoming

Parameters:
msg - The incoming message.
host - The host this application instance is attached to.
Returns:
the (possibly modified) message to forward or null if the application wants the router to stop forwarding the message.

update

public abstract void update(DTNHost host)
Called every simulation cycle.

Parameters:
host - The host this application instance is attached to.

getAppID

public java.lang.String getAppID()

Returns an unique application ID. The application will only receive messages with this application ID. If the AppID is set to null the application will receive all messages.

Returns:
Application ID.

setAppID

public void setAppID(java.lang.String appID)
Sets the application ID. Should only set once when the application is created. Changing the value during simulation runtime is not recommended unless you really know what you're doing.

Parameters:
appID -

replicate

public abstract Application replicate()

setAppListeners

public void setAppListeners(java.util.List<ApplicationListener> aListeners)

getAppListeners

public java.util.List<ApplicationListener> getAppListeners()

sendEventToListeners

public void sendEventToListeners(java.lang.String event,
                                 java.lang.Object params,
                                 DTNHost host)
Sends an event to all listeners.

Parameters:
event - The event to send.
params - Any additional parameters to send.
host - The host which where the app is running.