[
https://issues.apache.org/jira/browse/SLING-397?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bertrand Delacretaz updated SLING-397:
--------------------------------------
Attachment: SLING-397.patch
Patch that uses a different mechanism than initially planned: the new
ScriptableBase class uses rhino's NativeJavaObject class to provide javascript
properties and methods which are not explicitely defined.
NativeJavaObject is what rhino uses as the default wrapper for Java objects, so
the behavior should be consistent.
Currently this is only used in the get(String, Scriptable) method of the
affected classes. All tests pass, but I'm not 100% sure if this is correct
w.r.t Rhino conventions.
I'll apply the patch as soon as SVN is back to a sane state, this should make
all public methods of the wrapped Node and Property objects available in
javascript. A few new tests demonstrate this for some methods that were not
available before.
> Generate javascript wrapper methods from specific interfaces automatically
> --------------------------------------------------------------------------
>
> Key: SLING-397
> URL: https://issues.apache.org/jira/browse/SLING-397
> Project: Sling
> Issue Type: Improvement
> Components: Scripting
> Reporter: Bertrand Delacretaz
> Assignee: Bertrand Delacretaz
> Attachments: SLING-397.patch
>
>
> As discussed http://markmail.org/message/nrnuw2gad5z5wupx, it would be useful
> to have a way to autogenerate javascript wrappers, while allowing some
> methods to be customized.
> Here's the proposed method, from that thread:
> a) ScriptableNode (or any other javascript wrapper class) implements a
> finishInit() method that's called by ScriptableNode.defineClass [1] after all
> jsfunction_ etc. have been processed.
> b) finishInit uses reflection on the Node interface to define all methods
> that haven't been defined yet. The "not defined yet" condition looks a bit
> tricky but doable.
> This can probably be implemented in a base JavascriptWrapper class.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.