On Dec 28, 6:34 pm, Mark Storer <[email protected]> wrote: > IIRC, there's an annotation-based object exposer in the source, but I don't > see anything in the .jar... > > Yep.http://mxr.mozilla.org/mozilla/source/js/rhino/src/org/mozilla/javasc... > > I'm not aware of any code actually *using* those annotations. Furthermore, > the entire "annotations.*" package is missing from the jar file.
I implemented the annotation based mechanism a half year ago or so, here's my announcement on this list: http://groups.google.com/group/mozilla.dev.tech.js-engine.rhino/browse_frm/thread/bb20ab11868c35e9/3968cc0ccaade961 So far it isn't available in any released version, so you have to use a recent snapshot from CVS or ftp://ftp.mozilla.org/pub/js/. The annotations are a direct replacement for the name based scheme, so the whole host class initialization process is the same as described here: http://www.mozilla.org/rhino/apidocs/org/mozilla/javascript/ScriptableObject.html#defineClass(org.mozilla.javascript.Scriptable,%20java.lang.Class) I've been using this exclusively in Helma NG, so I would consider it save and fairly well-tested. For examples, look at the Binary or Stream class in this package: http://github.com/hns/helma-ng/tree/master/src/org/helma/wrappers/ The most important thing you need to know is that you can override all method and property names. For example, @JSGetter getFoo() will generate a property called "foo", but you can use @JSGetter("bar") to name the property "bar". Hannes > --Mark Storer > > > > On Fri, Dec 25, 2009 at 6:27 PM, Daryl Stultz <[email protected]> wrote: > > Hey all, > > > I've been using Rhino for some time now in my application. I simply use > > POJO > > objects and let them get auto-wrapped by Rhino. I've been reading the docs > > about host objects and I seem a bit unclear what the purpose is. I don't > > see > > what the benefit of writing > > > public void jsFunction_resetCount() > > vs just > > public void resetCount(). > > > Is it just the ability to add dynamic properties to an object? > > > Ultimately I'm looking for a better solution to my application design. I've > > got a domain object, say MyEntity and a wrapper class called JsMyEntity > > that > > forwards methods to MyEntity delegate. This is so I can restrict access to > > various methods of the domain class and I have a "JS API" class that > > clearly > > defines what's exposed to JavaScript. > > > I don't like writing the wrapper class. It's too much maintenance and prone > > to error. I'm looking for some feature of Rhino or JavaScript that might > > let > > me more easily define what methods of the domain class are accessible. I'm > > wondering if a host object has such features. Any input on how others are > > handling this type of thing would be appreciated. > > > Thanks. > > > -- > > 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 > > -- > --Mark Storer > Professional Geek _______________________________________________ dev-tech-js-engine-rhino mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
