Hi Betrand,

Sorry for the delay. Yes this sounds doable. But we should limit such
wrappings to the absolute minimum, otherwise we enter the maintenance
nightmare area ;-)

Maybe some part of the Property and Node interfaces may be implemented
in a common parent class (eg. ScriptableItem) to not replicate the Item
interface based method support.

Regards
Felix

Am Donnerstag, den 28.02.2008, 10:46 +0100 schrieb Bertrand Delacretaz:
> 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