Javascript files can be compiled to Java bytecode. Have a look here:

https://developer.mozilla.org/en/Rhino_JavaScript_Compiler

HTH,
Raphael

On Aug 30, 12:35 pm, DVD <[email protected]> wrote:
> Thanks.  I have many threads come and go instead of a fixed pool so the
> overhead is big.
> I hope rhino to have a mode that would allow a preloaded/compiled JS
> (template) to be executed repeatedly
> with different scope (essentially a template engine ) to produce an
> output string.
> the template would run in only single thread before producing the output.
> Equivalent of Freemarker engine.  Would it be possible?  Or because of
> this issue,
> Rhino has not been widely used as template engine for Java, compared to
> others like
> velocity/freemarker.
>
> Thanks
>
> David Parks wrote:
> > How many worker threads do you have? Context.enter() isn't an expensive
> > operation assuming you have the context set up already for each thread. I've
> > executed upwards of 10,000 Context.enter/exit() operations a second
> > (including executing a small amount of JS and resuming+suspending the JS
> > execution) on a single processor (numbers are off the top of my head it was
> > a while ago that I profiled it, but in any case it was a large number). If
> > it's really a big problem for you (perhaps your threads are being destroyed
> > rather than recycled??), you might consider setting up a smaller Work Queue
> > (an executor service) of threads that process javascript and submitting
> > requests to process javascript to that smaller set of threads.
>
> > If this is a conceptual concern I suggest profiling the scenario to find out
> > what really happens in your situation.
>
> > Dave
>
> > -----Original Message-----
> > From:
> > dev-tech-js-engine-rhino-bounces+davidparks21=yahoo....@lists.mozilla.org
> > [mailto:dev-tech-js-engine-rhino-bounces+davidparks21=yahoo....@lists.mozill
> > a.org] On Behalf Of DVD
> > Sent: Sunday, August 30, 2009 12:51 AM
> > To: [email protected]
> > Subject: Use Rhino in HTTPServlet, poor performance
>
> > Hello:
>
> > I intend to use Rhino in my HTTPServlet methods to execute a javascript
> > everytime user request a url. But according to doc, for every method call,
> > I have to first use Context.enter()/Scrope/ before eval  the same static
> > script
> > again and again. This is to meet the requirement that Context must be
> > created
> > for each thread and due to servlet model, this incurs huge overhead for
> > performance,
> > particularly when many users hits the url at the same time.  Is there a way
> > to have a precompiled form of the Javascript file created only once and
> > used
> > for multple thread? The script file itself can be assumed static and no
> > need for
> > implementing dynamic reload, which would make it easier.
>
> > Thanks very much
> > _______________________________________________
> > dev-tech-js-engine-rhino mailing list
> > [email protected]
> >https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>
> > _______________________________________________
> > dev-tech-js-engine-rhino mailing list
> > [email protected]
> >https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino
>
>

_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to