简体   繁体   中英

Where does JEXL store local vars and by what mechanism are local vars assigned?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM