It might be tricky to implement this in scripting based on other languages also. As typically the compile and instantiation phase are done in same call and one does not get chance to inspect the field variable.
For example n Groovy the script string is internally converted to Script class and then its run method is invoked. So to do any field processing one would need to get a handle to the script object before it is evaluated. One way is that for dynamic language like Javascript, groovy etc we can have object which hide this lookup logic by intercepting the method call and the executing them Chetan Mehrotra On Tue, Mar 15, 2011 at 8:07 PM, Felix Meschberger <[email protected]> wrote: > Hi, > > Sounds like an excellent idea ! > > Can this be generalized to also support JSP and other scripting > languages compiling to Java Bytecode ? > > Regards > Felix > > Am Dienstag, den 15.03.2011, 01:51 +0000 schrieb Justin Edelson: >> I was looking at how much code is involved in referencing an OSGi >> service from a script built using the scripting.java bundle and think >> it's a bit verbose: >> >> SlingBindings bindings = (SlingBindings) >> request.getAttribute(SlingBindings.class.getName()); >> SlingScriptHelper sling = bindings.getSling(); >> Interface service = sling.getService(Interface.class); >> >> I was thinking about adding some kind of annotation-based injection >> support so that you could replace these lines with just: >> >> >> @Inject >> private Interface service; >> >> public void service(request, response) { >> // some code using service >> >> } >> >> @Inject seems like the obvious candidate to support for this. WDYT? >> >> Justin > > >
