com.cometway.email
Class EmailBugReportAgent

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.email.EmailBugReportAgent
All Implemented Interfaces:
AgentInterface, BugReportInterface, HasStateMachineModel, ISchedulable

public class EmailBugReportAgent
extends ServiceAgent
implements ISchedulable, BugReportInterface

This agent registers itself with the Service Manager as a BugReportInterface and periodically submits the bug reports collects as an email message to a list of recipients using the SendEmailInterface registered with the Service Manager as "send_email".


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
EmailBugReportAgent()
           
 
Method Summary
 boolean addScheduleChangeListener(IScheduleChangeListener l)
          Called by Scheduler to add a listener to our Schedule.
 ISchedule getSchedule()
          Returns the instance to the schedule.
 void initProps()
          Initializes the default Props for this agent: "service_name" is the name this agent uses to register with the Service Manager (default: bug_report), "schedule" describes the schedule used to wake up this agent and email bug reports (default: every 6 hours), "report_title" is used to prefix the subject line of the emails that are sent (default: Bug Report), "reply_to" is used to set the Reply To field of emails that are sent, "recipients" is a comma separated list of email addresses used to send the emails.
 boolean removeScheduleChangeListener(IScheduleChangeListener l)
          Called by Scheduler to remove a listener from our Schedule.
 void resetHistory()
          Checks current bug history and emails any pending reports to the recipients, then resets the history.
 void start()
          Schedules the bug reporting mechanism using the schedule property and registers this agent with the Service Manager.
 void stop()
          Unschedules the bug reporter, and unregisters this agent with the Service Manager.
 void submitBugReport(java.lang.String author, java.lang.String description)
          Submits a bug report from the specified author (or entity) using the description.
 void wakeup()
          Called by Scheduler based on the Schedule returned by getSchedule method.
 
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

EmailBugReportAgent

public EmailBugReportAgent()
Method Detail

initProps

public void initProps()
Initializes the default Props for this agent: "service_name" is the name this agent uses to register with the Service Manager (default: bug_report), "schedule" describes the schedule used to wake up this agent and email bug reports (default: every 6 hours), "report_title" is used to prefix the subject line of the emails that are sent (default: Bug Report), "reply_to" is used to set the Reply To field of emails that are sent, "recipients" is a comma separated list of email addresses used to send the emails.

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

start

public void start()
Schedules the bug reporting mechanism using the schedule property and registers this agent with the Service Manager.

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

stop

public void stop()
Unschedules the bug reporter, and unregisters this agent with the Service Manager.

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

addScheduleChangeListener

public boolean addScheduleChangeListener(IScheduleChangeListener l)
Called by Scheduler to add a listener to our Schedule. Returns false to indicate that we don't need this feature.

Specified by:
addScheduleChangeListener in interface ISchedulable
Parameters:
l - a reference to an IScheduleChangeListener.
Returns:
true if the listener already exists.

getSchedule

public ISchedule getSchedule()
Returns the instance to the schedule.

Specified by:
getSchedule in interface ISchedulable
Returns:
a reference to an ISchedule.

removeScheduleChangeListener

public boolean removeScheduleChangeListener(IScheduleChangeListener l)
Called by Scheduler to remove a listener from our Schedule. Returns false to indicate that we don't need this feature.

Specified by:
removeScheduleChangeListener in interface ISchedulable
Parameters:
l - a reference to an IScheduleChangeListener.
Returns:
true if the listener was removed; false otherwise.

wakeup

public void wakeup()
Called by Scheduler based on the Schedule returned by getSchedule method. When called it calls the resetHistory method.

Specified by:
wakeup in interface ISchedulable

submitBugReport

public void submitBugReport(java.lang.String author,
                            java.lang.String description)
Submits a bug report from the specified author (or entity) using the description.

Specified by:
submitBugReport in interface BugReportInterface

resetHistory

public void resetHistory()
Checks current bug history and emails any pending reports to the recipients, then resets the history.