Skip to main content

script-finder handler

It is responsible for retrieve business objects from the persistence layer using BSH scripts. The following attributes are supported

Attribute
Usage

if

EL expression that must be evaluated to true prior to handler action

unless

 EL expression that must be evaluated to false prior to handler action

The contained bsh script must return a collection of business objects. If the returned object is not a collection object, the engine will treat the returned object as a singleton.

In the following example, the script finder retrives all countries saved to disk in the previous example:

<datanode name="root">
    ...
    <finder name="country" type="country" >
        <script-finder >
            import java.io.*;
            files[] = new File(".").listFiles ( new FilenameFilter () {
                public boolean accept (File dir, String name) {
                    return name.startsWith("coutnry.");
                }
            );
            v = new java.util.Vector();
            for (int i = 0; i < files.length; i++)
            {
                f = new FileInputStream (files[i]);
                ois = new ObjectInputStream (f);
                v.add (ois.readObject ();
                ois.close ();
                f.close();
            }
            return v;
        </script-finder>
    </finder>
    ...
</datanode>