org.jpos.bsh
Class BSHLogListener
java.lang.Object
org.jpos.bsh.BSHLogListener
- All Implemented Interfaces:
- EventListener, Configurable, LogListener
public class BSHLogListener
- extends Object
- implements LogListener, Configurable
This is a log listener that reads its actions from Bean Shell scripts.
You can define many scripts, and the order in wich they are called, also you
can define scripts whose name depends on the event being processed, and the
realm of the object that generated it.
This way you can set a configuration like this:
<log-listener class="org.jpos.bsh.BSHLoglistener">
<property name="source" value="general.bsh"/>
<property name="source" value="tag_$tag.bsh"/> <!--this is to handle specific tags-->
<property name="source" value="realm_$realm.bsh"/> <!-- to handle specific realms-->
<property name="source" value="tag_$tag_realm_$realm.bsh"/> <!-- to handle specific tags from specific realms-->
</log-listener>
If a source with the given name is not found, or it canbe read, it is not processed, so this lets
you change what is processed in real time, if you put a file called
tag_SystemMonitor_realm_monitor.bsh it will be executed whenever the system
monitor is run.
If you want to filter an event so that the remaining log listeners don't see
it, you have to set event = null in your script.
Other Configuration Options:
| Name | Type | Description |
| filter-by-default | boolean |
If true, filter the events if no script is processed, this way you can put a
Log Listener that filters every thing unless you put some script file, even if
it is empty, you also can dynamically change what kind of message are filtered
by placing empty files with names like tag_SystemMonitor_realm_monitor.bsh in
the previous example, if you "touch" a file with this name these events will
begin to be processed. |
| preload-scripts | boolean | If true scripts a
loaded once, and kept in memory, being realoaded only if they are touched. This
is good when you have lots of RAM memory but ou have troubles with
speed |
| save-name-space | boolean | If true the namespace
of the script instance will be saved so that in the next event you can access
them from the script, by default it's off, this property is overriden if the
script exposes a boolean variable named saveNameSpace |
| reload | long | this property is used
if the preload-script property is true, is the time in milliseconds between
updates in the script, during this time BSHLogListener will not check if the
script source was modified or deleted on disk |
|
Constructor Summary |
BSHLogListener()
Creates a new instance of BSHLogListener |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cfg
protected Configuration cfg
- Holds the configuration for this object
patterns
protected static final String[] patterns
scripts
protected Map<String,BSHLogListener.ScriptInfo> scripts
BSHLogListener
public BSHLogListener()
- Creates a new instance of BSHLogListener
setConfiguration
public void setConfiguration(Configuration cfg)
- Specified by:
setConfiguration in interface Configurable
- Parameters:
cfg - Configuration object
replace
protected static String[] replace(String[] src,
String[] patterns,
String[] to)
log
public LogEvent log(LogEvent ev)
- Specified by:
log in interface LogListener
loadCode
protected String loadCode(File f)
throws IOException
- Throws:
IOException
getScriptInfo
protected BSHLogListener.ScriptInfo getScriptInfo(String filename)
addScriptInfo
protected void addScriptInfo(String filename,
String code,
long lastModified)
Copyright © 1998-2012 jPOS.org. All Rights Reserved.