| java.lang.Object org.cougaar.lib.aggagent.script.PythMelder
PythMelder | public class PythMelder implements DataAtomMelder(Code) | | An implementation of DataAtomMelder that derives its functionality from a
script written in the JPython language. A PythMelder is configured in two
stages: one is to declare a function or class, and the other is to pass
the function or an instance of the class to the controlling Java context.
The necessity of using a two-stage initialization procedure for both types
of PythMelder implementations is due to JPython's resolute refusal to
allow an expression to declare a new function or class (or, indeed, any
multiline construct). One possibility is to use a "magic" function through
which the Java and JPython contexts can communicate. For the sake of
uniformity, this option is used here. The magic function is "instantiate",
which the script should define in the global context as a no-arg function
that returns either an DataAtomMelder instance or a function designed to
act as the "aggregate" method of an DataAtomMelder.
This class implements the DataAtomMelder interface, and can be instantiated
by calling the constructor or a static factory method, melderFromScript().
|
Constructor Summary | |
public | PythMelder(String script) Create a PythMelder instance by using a script-generated DataAtomMelder
as a delegate. |
PythMelder | public PythMelder(String script)(Code) | | Create a PythMelder instance by using a script-generated DataAtomMelder
as a delegate.
Parameters: script - the JPython script that defines the embodied functionality |
meld | public void meld(List idNames, CompoundKey id, List atoms, List output)(Code) | | An implementation of the aggregate method of interface DataAtomMelder. The
function is actually delegated to a script-generated implementation,
which is fabricated in the constructor.
Parameters: idNames - a list of names for the identifier fields |
melderFromScript | public static DataAtomMelder melderFromScript(String script)(Code) | | Create an DataAtomMelder from a JPython script. There are two acceptable
modes for the script. It must produce either a JPython subclass of Java
interface DataAtomMelder or a JPython function that behaves like the method
DataAtomMelder.aggregate(). Either way, the script is required to define the
magic function "instantiate()" to provide the function or DataAtomMelder
instance to the Java context.
Parameters: script - the executable script that declares classes and variables an DataAtomMelder instance derived from the JPython scripts |
|
|