|
jacquard 1.12.0 by The Web Engineering Factory and Toolworks | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectuk.co.weft.alert.Watcher
uk.co.weft.alert.AbstractFileWatcher
uk.co.weft.alert.FileWatcher
An agent which watches for changes to a file and sends alerts based on those events. This class is primarily an example of how to use Watcher, although it is of course useful in its own right.
This agent knows about the following tokens which can be uses as either command-line parameters or configuration file properties:
These are in addition to the tokens known by Watcher.
In the alert context, this agent sets the following tokens which can be used to substitute into the template:
If you use it you will typically set up a config file such as this:
debug: true
period: 10
mail_from_address: watcher@your.domain
mail_to_address: you@your.domain
subject: Watched file has changed
template: /home/you/tmp/watcher/watcher.template
watchedfile: /home/you/tmp/foo
However you could achieve exactly the same result by using java uk.co.weft.alert.FileWatcher -a watcher@your.domain -f ~/tmp/foo -i 10 -r you@your.domain -s "Watched file has changed" -t ~/tmp/watcher/watcher.template
| Nested Class Summary |
| Nested classes inherited from class uk.co.weft.alert.AbstractFileWatcher |
AbstractFileWatcher.FileValues |
| Field Summary | |
static java.lang.String |
FILETOKEN
|
protected long |
lastModified
when it last changed |
protected long |
lastSize
how big it was |
static java.lang.String |
OBSERVEDVALUESTOKEN
|
protected java.lang.String |
path
the path to the file I watch |
protected java.io.File |
watched
the file I watch |
static java.lang.String |
WHENCHANGEDTOKEN
|
| Fields inherited from class uk.co.weft.alert.Watcher |
alerter, alerts, configuration, debug, DEBUGTOKEN, ERRORTOKEN, INTERVALTOKEN, name, NAMETOKEN, recipient, resourceBundleName, sender, subject, SUBJECTTOKEN, template, TEMPLATETOKEN, thread, tooManyErrors, TOOMANYERRORS, whinges, winks |
| Constructor Summary | |
FileWatcher()
|
|
| Method Summary | |
protected java.util.Vector |
check()
perform a check to see whether the event I am watching for has occurred. |
void |
init(java.util.Map config)
initialise me with this configuration |
static void |
main(java.lang.String[] args)
|
| Methods inherited from class uk.co.weft.alert.AbstractFileWatcher |
mark, maybeEscapePath |
| Methods inherited from class uk.co.weft.alert.Watcher |
coerceToUrl, getAlerts, getArgs, getName, getNextCheck, getResource, getResourceString, getState, getStringWithDefault, getWhinges, grs, grs, maybeCheck, reset, resetWhinges, run, sendAlert, start, stop, usage, whinge |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String FILETOKEN
public static final java.lang.String WHENCHANGEDTOKEN
public static final java.lang.String OBSERVEDVALUESTOKEN
protected java.lang.String path
protected java.io.File watched
protected long lastModified
protected long lastSize
| Constructor Detail |
public FileWatcher()
| Method Detail |
public void init(java.util.Map config)
throws AlertingException
init in class AbstractFileWatcherAlertingException
protected java.util.Vector check()
throws java.lang.Exception
check in class Watcherjava.lang.Exception
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
jacquard 1.12.0 by The Web Engineering Factory and Toolworks | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||