cz.cuni.amis.pogamut.ut2004.utils
Class UT2004ServerRunner<SERVER extends IUT2004Server,PARAMS extends UT2004AgentParameters>

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.utils.runner.impl.AgentRunner<SERVER,PARAMS>
      extended by cz.cuni.amis.pogamut.ut2004.utils.UT2004ServerRunner<SERVER,PARAMS>
All Implemented Interfaces:
IAgentRunner<SERVER,PARAMS>

public class UT2004ServerRunner<SERVER extends IUT2004Server,PARAMS extends UT2004AgentParameters>
extends AgentRunner<SERVER,PARAMS>

Class used for creating, connecting and starting servers with default settings that are taken from the properties.

The address where the instances will connect are defined either in the constructor or taken from the properties of the PogamutPlatform.

For more information about the class see AgentRunner.


Field Summary
protected  java.lang.String host
          Default host where the instances are going to be connected as defaults, see IAgentParameters.assignDefaults(IAgentParameters).
protected  java.lang.String name
          Default name that will serve as a basis for IAgentId, see IAgentParameters.assignDefaults(IAgentParameters).
protected  int port
          Default port where the instances are going to be connected as defaults, see IAgentParameters.assignDefaults(IAgentParameters).
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.utils.runner.impl.AgentRunner
agents, consoleLogging, defaultLogLevel, factory, killed, latch, listener, log, main, mutex
 
Constructor Summary
UT2004ServerRunner(IAgentFactory<SERVER,PARAMS> factory)
          Construct the runner without specifying anything as default.
UT2004ServerRunner(IAgentFactory<SERVER,PARAMS> factory, java.lang.String name)
          Construct the runner + specify the default name, host:port will be taken from the Pogamut platform properties.
UT2004ServerRunner(IAgentFactory<SERVER,PARAMS> factory, java.lang.String name, java.lang.String host, int port)
          Construct the runner + specify all defaults.
 
Method Summary
protected  IAgentParameters newDefaultAgentParameters()
          Provides default parameters that is, IAgentId using name and SocketConnectionAddress using host and port.
 SERVER startAgent()
          Starts the agent by providing default parameters (defined during the construction of the implementor).
 java.util.List<SERVER> startAgents(int count)
          Starts agents by providing every one of them with default parameters (defined during the construction of the implementor).
 java.util.List<SERVER> startAgents(PARAMS... agentParameters)
          Start an agent instance configured with 'agentsParameters'.
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.utils.runner.impl.AgentRunner
createAgentWithParams, fillInDefaults, fillInDefaults, getLog, isMain, isPausing, killAgent, killAgents, newAgentId, postStartedHook, postStartHook, preInitHook, preResumeHook, preStartHook, setConsoleLogging, setLog, setLogLevel, setMain, setPausing, startAgent, startAgentWithParams, startAgentWithParamsMain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

host

protected java.lang.String host
Default host where the instances are going to be connected as defaults, see IAgentParameters.assignDefaults(IAgentParameters).


port

protected int port
Default port where the instances are going to be connected as defaults, see IAgentParameters.assignDefaults(IAgentParameters).


name

protected java.lang.String name
Default name that will serve as a basis for IAgentId, see IAgentParameters.assignDefaults(IAgentParameters).

Constructor Detail

UT2004ServerRunner

public UT2004ServerRunner(IAgentFactory<SERVER,PARAMS> factory,
                          java.lang.String name,
                          java.lang.String host,
                          int port)
Construct the runner + specify all defaults.

Parameters:
factory - to be used for creating new IUT2004Server instances
name - default name that serve as a basis for IAgentId
host - default host where the instances are going to be connected
port - default port where the instances are going to be connected

UT2004ServerRunner

public UT2004ServerRunner(IAgentFactory<SERVER,PARAMS> factory,
                          java.lang.String name)
Construct the runner + specify the default name, host:port will be taken from the Pogamut platform properties.

Parameters:
factory - factory to be used for creating new IUT2004Server instances
name - default name that serve as a basis for IAgentId

UT2004ServerRunner

public UT2004ServerRunner(IAgentFactory<SERVER,PARAMS> factory)
Construct the runner without specifying anything as default. Default name for server agents will be "UTServer Factory" and host:port will be taken from the Pogamut platform properties.

Parameters:
factory - factory to be used for creating new IUT2004Server instances
Method Detail

startAgent

public SERVER startAgent()
                                        throws PogamutException
Description copied from interface: IAgentRunner
Starts the agent by providing default parameters (defined during the construction of the implementor).

Specified by:
startAgent in interface IAgentRunner<SERVER extends IUT2004Server,PARAMS extends UT2004AgentParameters>
Overrides:
startAgent in class AgentRunner<SERVER extends IUT2004Server,PARAMS extends UT2004AgentParameters>
Returns:
agent instance configured with default parameters that has been started
Throws:
PogamutException

startAgents

public java.util.List<SERVER> startAgents(int count)
                                                         throws PogamutException
Description copied from interface: IAgentRunner
Starts agents by providing every one of them with default parameters (defined during the construction of the implementor).

Note that if any instantiation/start of the agent fails, all agents are killed before the method throws the exception.

Specified by:
startAgents in interface IAgentRunner<SERVER extends IUT2004Server,PARAMS extends UT2004AgentParameters>
Overrides:
startAgents in class AgentRunner<SERVER extends IUT2004Server,PARAMS extends UT2004AgentParameters>
Parameters:
count - how many agents should be started
Returns:
list of started agents
Throws:
PogamutException

startAgents

public java.util.List<SERVER> startAgents(PARAMS... agentParameters)
                                                         throws PogamutException
Description copied from interface: IAgentRunner
Start an agent instance configured with 'agentsParameters'. The length of the 'agentsParameters' array determines how many agents are going to be started.

Note that if any instantiation/start of the agent fails, all agents are killed before the method throws the exception.

Specified by:
startAgents in interface IAgentRunner<SERVER extends IUT2004Server,PARAMS extends UT2004AgentParameters>
Overrides:
startAgents in class AgentRunner<SERVER extends IUT2004Server,PARAMS extends UT2004AgentParameters>
Returns:
list of started agents
Throws:
PogamutException

newDefaultAgentParameters

protected IAgentParameters newDefaultAgentParameters()
Provides default parameters that is, IAgentId using name and SocketConnectionAddress using host and port.

Specified by:
newDefaultAgentParameters in class AgentRunner<SERVER extends IUT2004Server,PARAMS extends UT2004AgentParameters>
Returns:
new default parameters