Subj : Re: Implementation Questions To : Michael Grundvig From : Igor Bukanov Date : Fri May 09 2003 07:01 pm Michael Grundvig wrote: > Hi all! First off, I want to thank everyone who has worked on Rhino, it's > great! We have been able to use it with great success. > > The purpose of this email is to ask about how to implement Rhino effectivly. > We have a server that supports the concept of plugins. A plugin is > registered by a user and it contains a name, script on the file system and > some initilization parameters. An object called ScriptPlugin is used for all > this. > > When the server is restarted, it will load in all the plugins and init them. > Then calls can be made to the plugins on demand. All plugins run within the > same thread. All calls to the plugin are made through a JavaScript function > called "pluginRequest". Because of this, we create a Function object that > points to that pluginRequest function. Then we store this function object on > the ScriptPlugin object along with the scope for this plugin. Whenever a > request is made, we get a new context (Context.enter();), call pluginRequest > (passing in the required parameters), and then exit the context. > > My question: is there a better way to do this? But how do you evaluate the scripts itself? Do you precompile them during plugin initialization? > Performance has been a little > dissappointing and we wonder if we shouldn't be using the Function object? You can try to profile your application to see what takes most of the time. > Or if we should store the context permamently? No, the pattern cx = Context.enter(); try { ... } finally { Context.exit(); } should always be followed. Context.enter just create an object and put it inside ThreadLocal while Context.exit set that ThreadLocal to null. Evaluation of any script will take longer time. Regards, Igor .