org.cougaar.core.relay
Class SimpleRelayExample
java.lang.Object
org.cougaar.util.GenericStateModelAdapter
org.cougaar.core.blackboard.BlackboardClientComponent
org.cougaar.core.plugin.ComponentPlugin
org.cougaar.core.relay.SimpleRelayExample
- All Implemented Interfaces:
- BlackboardClient, org.cougaar.core.component.Component, PluginBase, org.cougaar.util.GenericStateModel
public class SimpleRelayExample
- extends ComponentPlugin
This component is an example SimpleRelay client, which
both sends relays and replies to them.
To use, add this component to an agent and specify a target,
for example in "AgentA" with a target of "AgentB":
<component
name='org.cougaar.core.relay.SimpleRelayExample(target=AgentB)'
class='org.cougaar.core.relay.SimpleRelayExample'
priority='COMPONENT'
insertionpoint='Node.AgentManager.Agent.PluginManager.Plugin'>
<argument>target=AgentB>/argument>
</component>
In the target agent add the component without a target argument:
<component
name='org.cougaar.core.relay.SimpleRelayExample(target=AgentB)'
class='org.cougaar.core.relay.SimpleRelayExample'
priority='COMPONENT'
insertionpoint='Node.AgentManager.Agent.PluginManager.Plugin'/>
You should see output similar to the following, which excludes
logging timestamps and other details:
.. AgentA: Sending (.. query=ping reply=null)
.. AgentB: Reply (.. query=ping reply=echo-ping)
.. AgentA: Received (.. query=ping reply=echo-ping)
It would be straight-forward to extend this example to a more
general remote procedure call (RPC) utility: the query
specifies a String "method" name and Object[] parameters, and
the reply is either a Throwable or a non-error value, plus a
wrapper if the non-error value is null or a Throwable. As in
RMI, the parameters and return value must be Serializable and
treated as immutable.
| Fields inherited from interface org.cougaar.util.GenericStateModel |
ACTIVE, IDLE, LOADED, UNINITIALIZED, UNLOADED |
|
Method Summary |
protected void |
execute()
Called every time this component is scheduled to run. |
void |
load()
|
protected void |
setupSubscriptions()
Called once after initialization, as a "pre-execute()". |
| Methods inherited from class org.cougaar.core.blackboard.BlackboardClientComponent |
currentTimeMillis, cycle, getAgentIdentifier, getAlarmService, getBindingSite, getBlackboardClientName, getBlackboardService, getMessageAddress, getParameter, getParameters, getServiceBroker, halt, precycle, requestCycle, resume, setAgentIdentificationService, setAlarmService, setBindingSite, setBlackboardService, setParameter, setSchedulerService, setServiceBroker, setSuicideService, shouldExecute, start, stop, suspend, toString, unload, wasAwakened |
| Methods inherited from class org.cougaar.util.GenericStateModelAdapter |
getModelState, initialize, transitState |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.cougaar.util.GenericStateModel |
getModelState, halt, initialize, resume, start, stop, suspend, unload |
SimpleRelayExample
public SimpleRelayExample()
load
public void load()
- Specified by:
load in interface org.cougaar.util.GenericStateModel- Overrides:
load in class BlackboardClientComponent
setupSubscriptions
protected void setupSubscriptions()
- Description copied from class:
ComponentPlugin
- Called once after initialization, as a "pre-execute()".
- Specified by:
setupSubscriptions in class ComponentPlugin
execute
protected void execute()
- Description copied from class:
ComponentPlugin
- Called every time this component is scheduled to run.
- Specified by:
execute in class ComponentPlugin