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.
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
appID |
| Constructor and Description |
|---|
Application() |
Application(Application app)
Copy constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
public Application()
public Application(Application app)
app - public abstract Message handle(Message msg, DTNHost host)
msg - The incoming message.host - The host this application instance is attached to.null
if the application wants the router to stop forwarding the
message.public abstract void update(DTNHost host)
host - The host this application instance is attached to.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.
public void setAppID(java.lang.String appID)
appID - public abstract Application replicate()
public void setAppListeners(java.util.List<ApplicationListener> aListeners)
public java.util.List<ApplicationListener> getAppListeners()
public void sendEventToListeners(java.lang.String event,
java.lang.Object params,
DTNHost host)
event - The event to send.params - Any additional parameters to send.host - The host which where the app is running.