Note: To use this agent the files PAMXML.jar and FESI.jar must be in your Java classpath. This requires you to modify ipam.bat or ipam12.bat.Description
This filter uses FESI (a ECMAScript interpreter) to apply a script to the incoming product where the script can return the same product or produce its own product. Users of this filter are expected to write their own custom scripts.The ECMA intrepreter is initialized with the JavaAccess, BasicIO, and FileIO extensions by default. Other extensions (e.g. OptionalRegExp, Database) must be explicitly loaded by the script via the loadExtension command.
The agent (instance of activated ScriptFilter) and its received product are available as named variables in the script so the appropriate java methods on those objects are defined (e.g. agent.getId() or product.getDescription()).
See examples in ECMAScriptLib support directory for details. This directory is created the first time that you run with this agent.
Configuration Variables
scriptFileThe script to evaluate the product with.Product
The product depends on what the script creates, which can be any Java object that implements the Product interface.
How it Works
The filter first initalizes the FESI ECMAScript interpreter if is not already loaded. The filter then executes the script as a function passing it two arguments: a reference to this juggler and its input product, which are refered to in the script as the variables agent and product, respectively. The script can then access any ECMAScript as well as Java methods such as in the following snipet of code where it returns a BasicProduct with URL content if a URL pattern is found in the received product's content.// First define some shortcuts - note that partially expanded // package names can be assigned. PAM = Packages.org.mitre.pam; // Load RegExp extension loadExtension('FESI.Extensions.OptionalRegExp'); id = product.getId(); description = product.getDescription(); content = product.getContent(); urlPattern = new RegExp( "http://([\\w.]+)/[^\\s\"'>]*" ); // Check product content for URL pattern; e.g. http://www.cda.mews.org/ if ((result = urlPattern.exec(content)) != null) { outProduct = new PAM.product.view.BasicProduct("Test", description); outProduct.setContent(new java.net.URL(result[0])); return outProduct; }
Revised: 10 September 1999