Constructor and Description |
---|
CompositeAgent(Agent... agents) |
CompositeAgent(java.util.List<? extends Agent> agents) |
Modifier and Type | Method and Description |
---|---|
int |
doWork()
An agent should implement this method to do its work.
|
void |
onClose()
To be overridden by Agents that need to do resource cleanup on close.
|
void |
onStart()
To be overridden by Agents that need to do resource init on start.
|
java.lang.String |
roleName()
Get the name of this agent's role.
|
public CompositeAgent(java.util.List<? extends Agent> agents)
agents
- the parts of this composite, at least one agent and no null agents allowedjava.lang.IllegalArgumentException
- if an empty array of agents is providedjava.lang.NullPointerException
- if the array or any element is nullpublic CompositeAgent(Agent... agents)
agents
- the parts of this composite, at least one agent and no null agents allowedjava.lang.IllegalArgumentException
- if an empty array of agents is provided, or single agent providedjava.lang.NullPointerException
- if the array or any element is nullpublic java.lang.String roleName()
Agent
public void onStart()
This method will be called by the agent thread thread once on start..
Note that one agent throwing an exception on start will not prevent other agents from being started.
public int doWork() throws java.lang.Exception
Agent
The return value is used for implementing a backoff strategy that can be employed when no work is currently available for the agent to process.
If the Agent wished to terminate and close then a AgentTerminationException
can be thrown.
public void onClose()
This method will be called after the agent thread has terminated or if the agent is closed before it runs.
Note that one agent throwing an exception on close will not prevent other agents from being closed.
Copyright © 2014-2019 Real Logic Ltd. All Rights Reserved.