|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cometway.props.Props
com.cometway.ak.Agent
public abstract class Agent
An abstract implementation of the AgentInterface. There is built-in support for routing agent output to the agent's output and error streams, and masking this output through the use of hide_println, hide_debug, and hide_warning props. This implementation of AgentInterface recognizes these properties:
| Field Summary | |
|---|---|
protected java.lang.String |
agent_id
This is where the agent_id is cached for use by the toString method. |
protected AgentControllerInterface |
agentController
This is a reference to the AgentController assigned to this agent. |
static java.lang.String |
CREATING_STATE
The agent is being created; initProps method called. |
protected ReporterInterface |
debugReporter
This is a reference to the Reporter assigned to this agent for debug output. |
static java.lang.String |
DESTROYED_STATE
The agent has been destroyed and can no longer be used. |
static java.lang.String |
DESTROYING_STATE
The agent is being destroyed; destroy method called. |
protected ReporterInterface |
errorReporter
This is a reference to the Reporter assigned to this agent for error output. |
static java.lang.String |
FAILED_STATE
The agent has failed; DESTROYING_STATE automatically entered. |
protected ReporterInterface |
printlnReporter
This is a reference to the Reporter assigned to this agent for println output. |
protected Props |
props
Deprecated. use the getProps method if you need a Props reference. |
static java.lang.String |
RUNNING_STATE
The agent is running and ready to be stoppped. |
static java.lang.String |
STARTING_STATE
The agent is starting; start method called. |
static java.lang.String |
STOPPED_STATE
The agent is ready to be started or destroyed. |
static java.lang.String |
STOPPING_STATE
The agent is stopping; stop method called. |
protected ReporterInterface |
warningReporter
This is a reference to the Reporter assigned to this agent for warning output. |
| Constructor Summary | |
|---|---|
Agent()
|
|
| Method Summary | |
|---|---|
boolean |
currentStateEquals(java.lang.String stateName)
Returns true if the specified state is the current state. |
void |
debug(java.lang.String message)
Prints a debug message tagged with this agent's identity to the output stream. |
void |
destroy()
Override this method to perform special cleanup before an agent is destroyed. |
void |
error(java.lang.String message)
Prints an error message tagged with this agent's identity to the error stream. |
void |
error(java.lang.String message,
java.lang.Exception e)
Prints an error message tagged with this agent's identity followed by a stack trace of the passed Exception to the error stream. |
protected AgentControllerInterface |
getAgentController()
Returns the AgentController for this agent. |
static java.lang.String |
getDateTimeStr()
Returns the formatted date-time as a String. |
Props |
getProps()
Returns the Props assigned to this agent. |
java.lang.Object |
getServiceImpl(java.lang.String service_name)
Returns a reference to the requested Service from the ServiceManager; null if the requested service does not exist, or the ServiceManager has not been loaded. |
StateMachineModelInterface |
getStateMachineModel()
Called by AgentController to retrieve a reference to this agent's state machine model. |
void |
initProps()
Override this method to initialize this agent's properties before it is started. |
void |
println(java.lang.String message)
Prints a message tagged with this agent's identity to the output stream. |
void |
register()
Registers this instance with the service manager using the service_name property. |
void |
registerService(java.lang.String service_name,
java.lang.Object serviceImpl)
Registers the specified object with the service manager using the specified property. |
void |
setAgentController(AgentControllerInterface agentController)
Assigns an AgentController to this agent. |
void |
setProps(Props p)
Called by the agent kernel to assign a Props to this agent. |
void |
start()
Override this method to initiate activities for this agent. |
void |
stop()
Override this method to handle stop requests from the agent kernel. |
java.lang.String |
toString()
Returns the string representation of this agent using the format <agent_id>_<name> taken from this agent's Props the first time this method is called, and cached for future calls. |
void |
unregister()
Unregisters this service implementation instance with the service manager using the service_name property. |
void |
unregisterService(java.lang.String service_name,
java.lang.Object serviceImpl)
Unregisters the service implementation instance with the service manager using the specified property. |
void |
warning(java.lang.String message)
Prints a warning message tagged with this agent's identity to the error stream. |
void |
warning(java.lang.String message,
java.lang.Exception e)
Prints an warning message tagged with this agent's identity followed by a stack trace of the passed Exception to error stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String CREATING_STATE
public static final java.lang.String STOPPED_STATE
public static final java.lang.String STARTING_STATE
public static final java.lang.String RUNNING_STATE
public static final java.lang.String STOPPING_STATE
public static final java.lang.String FAILED_STATE
public static final java.lang.String DESTROYING_STATE
public static final java.lang.String DESTROYED_STATE
protected Props props
protected AgentControllerInterface agentController
protected java.lang.String agent_id
protected ReporterInterface printlnReporter
protected ReporterInterface debugReporter
protected ReporterInterface warningReporter
protected ReporterInterface errorReporter
| Constructor Detail |
|---|
public Agent()
| Method Detail |
|---|
public void setProps(Props p)
setProps in interface AgentInterfacepublic final Props getProps()
getProps in interface AgentInterfacepublic void initProps()
initProps in interface AgentInterfacepublic final boolean currentStateEquals(java.lang.String stateName)
public final void setAgentController(AgentControllerInterface agentController)
setAgentController in interface AgentInterfaceprotected final AgentControllerInterface getAgentController()
public StateMachineModelInterface getStateMachineModel()
getStateMachineModel in interface HasStateMachineModelpublic void start()
start in interface AgentInterfacepublic void stop()
stop in interface AgentInterfacepublic void destroy()
destroy in interface AgentInterfacepublic void debug(java.lang.String message)
debug in interface AgentInterfacepublic void warning(java.lang.String message)
warning in interface AgentInterface
public void warning(java.lang.String message,
java.lang.Exception e)
warning in interface AgentInterfacepublic void error(java.lang.String message)
error in interface AgentInterface
public void error(java.lang.String message,
java.lang.Exception e)
error in interface AgentInterfacepublic void println(java.lang.String message)
println in interface AgentInterfacepublic java.lang.Object getServiceImpl(java.lang.String service_name)
public void register()
public void registerService(java.lang.String service_name,
java.lang.Object serviceImpl)
public void unregister()
public void unregisterService(java.lang.String service_name,
java.lang.Object serviceImpl)
public java.lang.String toString()
toString in interface AgentInterfacetoString in class Propspublic static java.lang.String getDateTimeStr()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||