On Tue, Dec 29, 2009 at 1:46 PM, Mark Storer <[email protected]> wrote:

> On Tue, Dec 29, 2009 at 5:29 AM, Daryl Stultz <[email protected]> wrote:
> > I do appreciate the annotations approach to writing host objects but it's
> > actually off topic from my original post.
>
> I disagree.  Observe:
>
> import org.mozilla.javascript.annotations.*;
> public class MyEntity {
>
> private int foo;
> @JSGetter
> public int getFoo() { return foo; }
> @JSSetter
> public void setFoo(int foo) { this.foo = foo;}
> public void save() { ... }
> }
>
> Done.  No need for a separate wrapper class, you can simply annotate
> what you want exposed, and Rhino will ignore the rest.
>

Ah, "Rhino will ignore the rest". That's good for chopping off the save()
method. In most cases I need to change the behavior of the save() method
rather than hide it. I can't subclass my domain class.

>
> Err... unless.... Are you required to extend ScriptableObject?  That
> could be a deal-breaker for many Domain Objects.  All the examples
> given examples do so...
>

Yeah, my domain classes are (bytecode enhanced) JPA entities. I don't want
to extend ScriptableObject nor implement Scriptable. I'm pretty sure I need
a wrapper. I think I need a ScriptableObject that is the superclass of all
my Js Entity wrappers. The superclass takes a POJO as delegate and
intercepts the calls to properties and functions and forwards them to the
delegate. Is that a reasonable idea or a crazy undertaking?

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:[email protected]
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to