peersim.dynamics
Class MethodInvoker

java.lang.Object
  extended by peersim.dynamics.MethodInvoker
All Implemented Interfaces:
Control, NodeInitializer

public class MethodInvoker
extends java.lang.Object
implements Control, NodeInitializer

This Control invokes a specified method on a protocol. The method is defined by config parameter "method" and the protocol is by "protocol". The method must not have any parameters and must return void. If no protocol is specified, then the method will be invoked on all protocol in the protocol stack that define it.

Although the method cannot have any parameters, it can of course read CommonState. It is guaranteed that the state is up-to-date, inlcuding eg method CommonState.getNode().


Parameter Summary
protocol
          The protocol to operate on.
method
          The method to be invoked.
 
Constructor Summary
MethodInvoker(java.lang.String prefix)
          Standard constructor that reads the configuration parameters.
 
Method Summary
 boolean execute()
          Invokes method on all the nodes.
 void initialize(Node n)
          Invokes method on given node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Parameter Detail

protocol

The protocol to operate on. If not defined, the given method will be invoked on all protocols that define it. In all cases, at least one protocol has to define it.


method

The method to be invoked. It must return void and should not have any parameters specified.

Constructor Detail

MethodInvoker

public MethodInvoker(java.lang.String prefix)
Standard constructor that reads the configuration parameters. Invoked by the simulation engine.

Parameters:
prefix - the configuration prefix for this class
Method Detail

execute

public boolean execute()
Invokes method on all the nodes.

Specified by:
execute in interface Control
Returns:
true if the simulation has to be stopped, false otherwise.

initialize

public void initialize(Node n)
Invokes method on given node.

Specified by:
initialize in interface NodeInitializer