| java.lang.Object org.cougaar.lib.aggagent.script.PythAggregator
PythAggregator | public class PythAggregator implements Aggregator(Code) | | An implementation of Aggregator that derives its functionality from a
script written in the JPython language. A PythAggregator 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 PythAggregator 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 Aggregator instance or a function designed to act as
the "aggregate" method of an Aggregator.
This class implements the Aggregator interface, and can be instantiated by
calling the constructor or a static factory method, aggregatorFromScript().
|
Constructor Summary | |
public | PythAggregator(String script) Create a PythAggregator instance by using a script-generated Aggregator
as a delegate. |
PythAggregator | public PythAggregator(String script)(Code) | | Create a PythAggregator instance by using a script-generated Aggregator
as a delegate.
Parameters: script - the JPython script that defines the embodied functionality |
aggregate | public void aggregate(Iterator dataAtoms, List output)(Code) | | An implementation of the aggregate method of interface Aggregator. The
function is actually delegated to a script-generated implementation,
which is fabricated in the constructor.
Parameters: dataAtoms - an iterator that iterates through raw, unaggregateddata atoms Parameters: output - a List into which the produced ResultSetDataAtoms should beplaced |
aggregatorFromScript | public static Aggregator aggregatorFromScript(String script)(Code) | | Create an Aggregator from a JPython script. There are two acceptable
modes for the script. It must produce either a JPython subclass of Java
interface Aggregator or a JPython function that behaves like the method
Aggregator.aggregate(). Either way, the script is required to define the
magic function "instantiate()" to provide the function or Aggregator
instance to the Java context.
Parameters: script - the executable script that declares classes and variables an Aggregator instance derived from the JPython scripts |
|
|