Reputation: 21654
Apache JEXL script engine invokes the setter method of the context to consummate an assignment made in script. The context I supply would take over to store the assignment.
a = mylib.hello();
What is the equivalent of a context when a local var is declared?
var b = mylib.goodbye();
In my application design, I need every assignment to be intercepted, and every variable locatable.
What is the assignment mechanism for local vars, and where are they stored? How would I be able to overload/override/intercept that mechanism?
Upvotes: 0
Views: 161
Reputation: 364
To handle local variables and script arguments, JEXL creates scopes (Scope) at parsing time that act as linkable symbol tables. For each variable/parameter, a symbol is created in the parsing scope. There is one scope per script and lambda/function. During execution, per scope, a frame is created that will hold the values of the symbols. To intercept assigning local variables, you'll have to derive the (internal) Frame class and override the 'set' method; there are only a few constructor calls so it's not a massive change. Note that this info is based on the 3.2 trunk and that you'll probably end up with a local fork (package protected classes, etc). It'd be interesting to understand why you need to capture if you can. Cheers
Upvotes: 0