Details
Description
The BeanShellContainerBuilder (or maybe all ScriptedContainerBuilder, I don't know) can't be used more than once. The problem is when calling 'buildContainer' more than one time to the same instance that means we are reading from the same instance of 'Reader' of the script, which is impossible in my opinion (unless the 'Reader' support reset and the reset method repositions the reader to starting point).
The problem like this occurs when we try to use BeanShellContainerBuilder with nanowar, where in nanowar we create an instance of ContainerBuilder and then put it in the ServletContext, and then reuse the builder for each container to be created.
So I add a new method to the test case of BeanShellContainerBuilder and I put it in attachement.
Activity
peter royal
made changes -
peter royal
made changes -
Mauro Talevi
made changes -
Status | Open [ 1 ] | Resolved [ 5 ] |
Resolution | Won't Fix [ 2 ] |
The problem is not with the Reader, rather with the bsh Interpreter, being instantiated at method level and not at instance level. We could modify the BeanShellContainerBuilder to support multiple creation, but trying to create two containers with the same builder would cause you problems because the LifecycleContainerBuilder does an autostart of the container created and hence would fails the second time around, due to the container already started.
You can instantiate the ContainerBuilder as many times as you need - and this preserves the one-to-one mapping between resource script and container.