|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IAgentRunner<AGENT extends IAgent,PARAMS extends IAgentParameters>
Utility interface for classes that can instantiate & start (possibly multiple) agents at once. All agents must be
of the same class though. Note that this usually is not a problem as the agent class is a shell that may
contain arbitrary agent's logic implementations. (If it proves to be a problem, check whether there is a suitable
implementation of the IMultipleAgentRunner
implementation that you can use.)
Every implementor is instantiated with default values that should be passed into the agent when no
other parameters are provided. Therefore you may use startAgent()
to start agent
with default params, or startAgents(int)
and startAgents(IAgentParameters...)
where you may specify your own params.
Note that the IAgentRunner
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 IAgentRunner
(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 they start and resume them at once when all agents have been instantiated.
Pausing behavior is disabled (== set to false) as default.
USING FROM THE main(String[] args) METHOD
Starting agents from the main method requires special care:
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 (see the Javadoc for the whole class). |
boolean |
isPausing()
Tells, whether the pausing behavior is enabled. |
IAgentRunner<AGENT,PARAMS> |
setMain(boolean state)
Sets 'main' functionality (see the Javadoc for the whole class). |
IAgentRunner<AGENT,PARAMS> |
setPausing(boolean state)
Sets the pausing behavior. |
AGENT |
startAgent()
Starts the agent by providing default parameters (defined during the construction of the implementor). |
java.util.List<AGENT> |
startAgents(int count)
Starts agents by providing every one of them with default parameters (defined during the construction of the implementor). |
java.util.List<AGENT> |
startAgents(PARAMS... agentsParameters)
Start an agent instance configured with 'agentsParameters'. |
Method Detail |
---|
AGENT startAgent() throws PogamutException
PogamutException
java.util.List<AGENT> startAgents(int count) throws PogamutException
Note that if any instantiation/start of the agent fails, all agents are killed before the method throws the exception.
count
- how many agents should be started
PogamutException
java.util.List<AGENT> startAgents(PARAMS... agentsParameters) throws PogamutException
Note that if any instantiation/start of the agent fails, all agents are killed before the method throws the exception.
agentsParameters
-
PogamutException
IAgentRunner<AGENT,PARAMS> 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.
IAgentRunner<AGENT,PARAMS> setMain(boolean state)
state
-
boolean isMain()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |