Package org.jpos.bsh

Class BSHLogListener

  • All Implemented Interfaces:
    java.util.EventListener, Configurable, LogListener

    public class BSHLogListener
    extends java.lang.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