|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
AGENT
- common ancestor of all agents that are going to be startedPARAMS
- MODULE
- public interface IMultipleAgentRunner<AGENT extends IAgent,PARAMS extends IAgentParameters,MODULE extends GuiceAgentModule>
Utility interface for classes that can instantiate & start (possibly multiple) agents at once. Agents may be also of different classes.
Every implementor is instantiated with default values that should be passed into the agent when no other parameters are provided.
Note that the IMultipleAgentRunner
utilize IAgentParameters.assignDefaults(IAgentParameters)
to fill
missing fields into IAgentParameters
which allows you to instantiate the IAgentParameters
implementor
with custom data leaving the rest to the IMultipleAgentRunner
(eases the pain of starting agents greatly).
The interface also provides a "synchronizing" feature via setPausing(boolean)
. If set true,
the runner will pause all agents after their construction and resume them at once when all agents has been instantiated.
Pausing behavior is disabled (== set to false) as default.
NOTE: it might seem strange why there exists IAgentRunner
and IMultipleAgentRunner
interfaces when
IAgentRunner
can be implemented using IMultipleAgentRunner
. Even though that is true, it would
be infeasible as IMultipleAgentRunner
always needs to instantiate new factories for every IAgentDescriptor
passed (unlike the IAgentRunner
that may utilize the same factory instance repeatedly).
USING FROM THE main(String[] args) METHOD
Starting agents from the main method requires special care:
IAgentRunner.setMain(boolean)
with 'true' and the runner will behave differently.
(Note that all startAgent methods will block!)
Method Summary | |
---|---|
boolean |
isMain()
Whether the runner is set to provide 'main' functionality. |
boolean |
isPausing()
Tells, whether the pausing behavior is enabled. |
IMultipleAgentRunner<AGENT,PARAMS,MODULE> |
setMain(boolean state)
Sets 'main' functionality. |
IMultipleAgentRunner<AGENT,PARAMS,MODULE> |
setPausing(boolean state)
Sets the pausing behavior. |
java.util.List<AGENT> |
startAgents(IAgentDescriptor<PARAMS,MODULE>... agentDescriptors)
Start an agent instances described by 'agentDescriptors'. |
Method Detail |
---|
java.util.List<AGENT> startAgents(IAgentDescriptor<PARAMS,MODULE>... agentDescriptors)
IAgentDescriptor.getCount()
determines how many agents are going to be instantiated and started.
Note that if any instantiation/start of the agent fails, all agents are killed before the method throws the exception.
agentsParameters
-
IMultipleAgentRunner<AGENT,PARAMS,MODULE> setPausing(boolean state)
If set true, the runner will pause all agents after their construction and resume them at once whenever all agents has been successfully started.
state
-
boolean isPausing()
If enabled, the runner will pause all agents after their construction and resume them at once whenever all agents has been instantiated.
IMultipleAgentRunner<AGENT,PARAMS,MODULE> setMain(boolean state)
state
-
boolean isMain()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |