| java.lang.Object org.cougaar.lib.aggagent.script.PythAlert
PythAlert | abstract public class PythAlert (Code) | | An implementation of the Alert class that derives its functionality from a
script written in the JPython language. A PythAlert 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 PythAlert 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 Alert instance or a function designed to act as the
abstract "handleUpdate" method of an Alert.
This class contains a static factory method, parseAlert(), for generating
Alert instances.
|
parseAlert | public static Alert parseAlert(String script)(Code) | | Create an Alert from a JPython script. There are two acceptable modes
for the script. It must produce either an instance of a JPython subclass
of Java class Alert or a JPython function that behaves like the method
Alert.handleUpdate (i.e., takes one argument (that being the Alert's own
self), returns no result, and updates the Alert's state to reflect the
current result set data). Either way, the script is required to define
the magic function "instantiate()" to provide the function or predicate
instance to the Java context.
Parameters: script - the executable script that declares classes and variables an Alert instance derived from the JPython scripts |
|
|