Hello, I'm using Rhino to compile and execute javascript functions. In order to constrain the execution time of scripts, I created a custom ContextFactory where am able to set the max cpu time allowed and the number of instructions before calling observeInstructionCount, similarly to the example described in ContextFactory. The following code is a sample of the method I use to compile and execute the functions.
Every thing works as excepted, the scripts that exceed the maximum allowed cpu time throw an Error. My problem is that I want to have two instances of my custom factory under the same JVM, one that will allow the scripts to run for a little longer than the other. But because of the call ContextFactory.initGlobal(factory) every Context will inherit the same ContextFactory. Even if I create a new custom factory with a different allowed cpu time, when I call factory.enterContext() the context will inherit the factory that was passed to initGlobal. Is there any way to have two instances of ContextFactory (with different properties) under the same JVM? Regards, Pedro Chaves |