Subj : Re: How to handle unknown JavaScripts functions with Rhino To : =?UTF-8?B?RGlldGVyIFNhbGF0aMOp?= From : Igor Bukanov Date : Thu Sep 04 2003 04:21 pm Dieter Salathé wrote: > Hi, > > in our project we have the following problem: > we have to provide script objects, where the supported functions are > not known at development or deploy time, like: > > function foo(plugin) { > plugin.bar("Parameter1", "Parameter2", ...); > } > > the 'plugin' object is a scriptable object which represents a remote > server, which is not known when developing the Java ScriptableObjects, > so implementing the 'jsFunction_bar' is not an possible opinion. > > Anybody has the same problem? Any hints are greatly appreciated. But how are you going to call server functions? Do you want to effectively translate all the calls plugin.("Parameter1", "Parameter2", ...); into callRemoteServer(idForPluginObjectOnserver, "", "Parameter1", "Parameter2", ...) ? Or do you want on the first access to plugin properties resolve plugin object and populate it with available name? In any case, you will need either to implement Scriptable interface directly, see http://lxr.mozilla.org/mozilla/source/js/rhino/examples/Matrix.java for example , or at least subclass ScriptableObject to override get and has methods. Also note that since JS does not distinguish between methods and other properties you will have to decided in your Scriptable.get method if a particular property is callable (represents function) or not (represents a primitive value or object). Regards, Igor .