Subj : RE: Nesting host objects To : netscape.public.mozilla.jseng From : Jalenak, Jerry Date : Tue Sep 06 2005 07:28 pm Jon, Thanks for the quick reply. How much of the 'helper' class do I need to register in the scope? I've been playing around with this, and I'm able to get the second level objects constructor to be called, but all of my methods in that class cannot be found. I've only registered the first level identifier - do I need to register all the way down the tree? Jerry Jalenak Software Engineer Netopia, Inc. -----Original Message----- From: Jon Brisbin [mailto:jon.brisbin@npcinternational.com] Sent: Tuesday, September 06, 2005 5:01 PM To: Jalenak, Jerry; MozDev Subject: Re: Nesting host objects Jalenak, Jerry wrote: > All, > > I'm in the process of investigating the use of Rhino and Javascript as > a replacement for an inhouse script implementation. One of the things > I need to do is implement a 'namespace' concept for variables, from > both the Javascript side as well as the Java side. Here is what I am > trying to get to: > > netopia.scriptparms.var > > netopia.javaparms.var2 > > where the 'netopia' host object would implement a factory pattern that > would look up the second level identifier and delegate to it. This > second level identifier would implement a map-backed data structure > where I could look up the variable name (var or var2), and then return > the value associated with the variable. > > Is this possible? Or is there another way to achieve this type of > functionality? > > Thanks. > > /*/Jerry Jalenak/*/ > > //Software Engineer// > > //Netopia, Inc.// > I think you could write a fairly comprehensive helper class that would encapsulate all the functionality you need. You're really just talking about creating a Java class that will do what you want, then exposing that object through Rhino's Scriptable (or ScriptableObject) concept. A good place to start is by checking out the source of Rhino (or downloading the zip file) and regenerating the javadocs to include ALL the classes, not just the public ones, which is the incredibly annoying default. Once you have all the javadocs generated, it will start making a lot more sense on how a ScriptableObject would interact with the Java world. From there, it's just a matter of heads-down coding to make the glue stick. Jon Brisbin NPC International, Inc. .