Hi,

Looking at how best to implement SLING-154, the ideal way to make sure
all Node methods are available in javascript seems to be:

1) ScriptableNode implements just some specific methods using the
ScriptableObject's defineClass conventions [1]: js_function.. etc.
That's for methods where we need to return wrapped objects instead of
plain java ones, for example.

2) All other methods of the Node interface (and its ancestors) are
made available as is in javascript, using some inheritance mechanism,
without having to define all of them in ScriptableNode.java.

I think this would work:

a) ScriptableNode 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.

The same would apply to ScriptableProperty and related classes, of course.

WDYT? I'm not too familiar with this defineClass business, maybe
there's a simpler way?

-Bertrand


[1] http://tinyurl.com/2d2cth

Reply via email to