com.cometway.email
Class AutoReplyAgent

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.ak.Agent
          extended by com.cometway.ak.ServiceAgent
              extended by com.cometway.ak.RequestAgent
                  extended by com.cometway.email.AutoReplyAgent
All Implemented Interfaces:
AgentInterface, RequestAgentInterface, HasStateMachineModel

public class AutoReplyAgent
extends RequestAgent

This agent sets itself up to receive messages from a ReceiveEmailAgent and automatically respond to the sender using the SendEmailAgent. In most cases, this will be subclassed and the getReply method should be overridden.


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
AutoReplyAgent()
           
 
Method Summary
 java.lang.String getReply(AgentRequest request)
          This method can be overridden to provide an automatic response message.
 void handleRequest(AgentRequest request)
          Processes an email AgentRequest by parsing out the recipient's Reply To address, and responding with the text message returned by calling the getReply method.
 void initProps()
          Initializes properties for this agent:
 void start()
          Registers with the Service Manager to receive and respond to e-mail requests.
 
Methods inherited from class com.cometway.ak.ServiceAgent
stop
 
Methods inherited from class com.cometway.ak.Agent
currentStateEquals, debug, destroy, error, error, getAgentController, getDateTimeStr, getProps, getServiceImpl, getStateMachineModel, println, register, registerService, setAgentController, setProps, 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

AutoReplyAgent

public AutoReplyAgent()
Method Detail

initProps

public void initProps()
Initializes properties for this agent:
service_name - is the agent's email address,
 reply_to - the agent's reply to email address (usually the same as service_name),
 send_email_service_name - is the service name of the SendEmailAgent (send_email),
 reply_message - is the static text response this agent replys with.

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

start

public void start()
Registers with the Service Manager to receive and respond to e-mail requests.

Specified by:
start in interface AgentInterface
Overrides:
start in class ServiceAgent

handleRequest

public void handleRequest(AgentRequest request)
Processes an email AgentRequest by parsing out the recipient's Reply To address, and responding with the text message returned by calling the getReply method. The message is sent using the SendEmailInterface registered with the ServiceManager as specified by the "send_email_service_name" property. Note: This method will do nothing if the sender (Reply To from the message) is the same as the "reply_to" property as this would cause a mail loop.


getReply

public java.lang.String getReply(AgentRequest request)
This method can be overridden to provide an automatic response message. By default it returns the text message provided by the "reply_message" property.