com.cometway.ak
Class AgentKernel

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.ak.Agent
          extended by com.cometway.ak.AgentKernel
All Implemented Interfaces:
AgentInterface, AgentKernelInterface, HasStateMachineModel

public class AgentKernel
extends Agent
implements AgentKernelInterface

Reference implementation of the AgentKernelInterface.


Field Summary
 
Fields inherited from class com.cometway.ak.Agent
agent_id, agentController, CREATING_STATE, debugReporter, DESTROYED_STATE, DESTROYING_STATE, errorReporter, FAILED_STATE, printlnReporter, props, RUNNING_STATE, STARTING_STATE, STOPPED_STATE, STOPPING_STATE, warningReporter
 
Constructor Summary
AgentKernel()
           
 
Method Summary
 AgentControllerInterface createAgent(java.lang.Object agentInfo)
          Creates an agent instance using the specified agent information; a String containing the classname of an AgentInterface implementation, or a Props with the classname property.
protected  AgentControllerInterface createAgent(Props agentProps)
          Creates an agent instance using the classname property of the specified Props and automatically adopting any other properties which exist.
protected  java.lang.String getNextAgentID()
          Increments and returns the next agent ID.
 void initProps()
          Provides default values for the following properties if missing: next_agent_id - seed value for agent_id (default: 1001)
 void stop()
          Shuts down the agent kernel and exits the VM by calling System.exit(0).
 
Methods inherited from class com.cometway.ak.Agent
currentStateEquals, debug, destroy, error, error, getAgentController, getDateTimeStr, getProps, getServiceImpl, getStateMachineModel, println, register, registerService, setAgentController, setProps, start, toString, unregister, unregisterService, warning, warning
 
Methods inherited from class com.cometway.props.Props
addListener, append, copy, copyFrom, copyTo, decrementInteger, dump, enableListeners, enumerateKeys, format, getBoolean, getByteArray, getCharacter, getDate, getDate, getDateString, getDouble, getFloat, getHexString, getInteger, getKeys, getLong, getNextKey, getProperty, getProperty, getPropsContainer, getSize, getString, getString, getTokens, getTokens, getTrimmedString, getVector, hasProperty, incrementInteger, insertProps, loadProps, notifyPropsChanged, notifyPropsChangedIgnore, notifyPropsChangedIgnore, parse, propertyMatchesRegEx, readFromFile, regExPropertyMatches, removeAll, removeListener, removeProperty, resumeNotify, saveProps, set, setBoolean, setCharacter, setDefault, setDouble, setFloat, setInteger, setLong, setProperty, setProperty, setProperty, setPropsContainer, suspendNotify, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AgentKernel

public AgentKernel()
Method Detail

createAgent

public AgentControllerInterface createAgent(java.lang.Object agentInfo)
Creates an agent instance using the specified agent information; a String containing the classname of an AgentInterface implementation, or a Props with the classname property. The agent's initProps method is called before this method returns.

Specified by:
createAgent in interface AgentKernelInterface

createAgent

protected AgentControllerInterface createAgent(Props agentProps)
Creates an agent instance using the classname property of the specified Props and automatically adopting any other properties which exist. If the name property isn't provided, the name will be set to the agent's classname. If the agent_id property isn't provided, one will be assigned by the agent kernel. Returns null if unsuccessful.


getNextAgentID

protected java.lang.String getNextAgentID()
Increments and returns the next agent ID.


initProps

public void initProps()
Provides default values for the following properties if missing:

Specified by:
initProps in interface AgentInterface
Overrides:
initProps in class Agent

stop

public void stop()
Shuts down the agent kernel and exits the VM by calling System.exit(0).

Specified by:
stop in interface AgentInterface
Overrides:
stop in class Agent