com.cometway.io
Class FileReaper

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.ak.Agent
          extended by com.cometway.ak.ScheduledAgent
              extended by com.cometway.io.FileReaper
All Implemented Interfaces:
AgentInterface, HasStateMachineModel, ISchedulable

public class FileReaper
extends ScheduledAgent

This agent uses a Scheduler to periodically wakeup when it scans the directory specified by scan_dir and deletes all files older than file_lifespan_ms (specified in milliseconds). Optionally, the property filename_suffix can be specified to delete only files with a specific extension (such as .txt). Properties used: schedule, scan_dir (./), file_lifespan_ms (300000), filename_suffix (optional).


Nested Class Summary
 class FileReaper.FilenameFilterImpl
           
 
Field Summary
protected  FileReaper.FilenameFilterImpl filenameFilter
           
protected static java.text.SimpleDateFormat SDF
           
 
Fields inherited from class com.cometway.ak.ScheduledAgent
schedule
 
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
FileReaper()
           
 
Method Summary
 void initProps()
          Override this method to provide default properties for subclasses.
 void wakeup()
          Override this method to handle schedule wakeup notifications.
 
Methods inherited from class com.cometway.ak.ScheduledAgent
addScheduleChangeListener, getSchedule, removeScheduleChangeListener, schedule, start, stop, unschedule
 
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
 

Field Detail

SDF

protected static java.text.SimpleDateFormat SDF

filenameFilter

protected FileReaper.FilenameFilterImpl filenameFilter
Constructor Detail

FileReaper

public FileReaper()
Method Detail

initProps

public void initProps()
Description copied from class: ScheduledAgent
Override this method to provide default properties for subclasses. ScheduledAgent recognizes the following properties: schedule (scheduled string or none) agent_classname and agent_name (used by default wakeup implementation to instantiate and start a new agent based on this agent's properties).

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

wakeup

public void wakeup()
Description copied from class: ScheduledAgent
Override this method to handle schedule wakeup notifications. By default this agent will create and start a new agent based on the properties of this agent and: 1) agent_classname, the java class name of the agent instance to be created, 2) agent_name, the name property assigned to the new agent instance, 3) agent_id, the unique id property assigned to the new agent instance. The wakeup driven agents are only started (not stopped) and if they have a problem during execution (exception thrown) this agent would be unscheduled automatically.

Specified by:
wakeup in interface ISchedulable
Overrides:
wakeup in class ScheduledAgent