jakarta-bsf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rony G. Flatscher" <Rony.Flatsc...@wu-wien.ac.at>
Subject Re: Questions about BSF in Server Side Scripting
Date Mon, 01 Mar 2004 21:46:59 GMT

attempting a few answers (if you look at the sources, you probably can 
answer most of your answers yourself) ...

>1)  Is BSFManager thread safe?  Are there any rules
>the BSFEngines have to adhere to with regards to the
>thread model?  Do seperate threads get seperate stack
>frames or seperate global variable declarations?
A BSFManager allows the invocation of multiple engines, whereby it 
caches each engine.

You can create multiple BSFManagers which would have their own cached 
engine instances.

You can create BSFEngine-instances individually.

>3)  What happens if two threads run the following code at the same time?
>   String language = manager.getLangFromFilename(
>scriptFile.getName() );
>   manager.declareBean( "request", request,
>request.getClass() );
>   manager.declareBean( "response", response,
>response.getClass() );
>   manager.exec( language, scriptFile.getPath(), 0, 0,
>script );
>Will calling declareBean() result in two different
>instance variables, or will they overwrite each other?
If working with the same instance of BSFManager they would overwrite 
each other.

>4)  Calling exec() twice retains state from the
>previous run.  
>   BSFManager.exec( "jython", "", 0, 0, "i = 3" );
>   BSFManager.exec( "jython", "", 0, 0, "print i" );
>That will print out 3.  In a server application you
>don't really want retention of state since it could
>result in unpredictable behavior.  Are exec() and
>eval() the same?  The exec() method I expect to simply
>fire off a script and not retain state between calls
>or threads, but eval() I expect should retain state. 
>Sort of like interactive programs would use eval(),
>but users who want to run a script and retain no state
>could use exec().
Have you tried different instances of BSFManagers or BSFEngine for that matter?

Hope that helps a little,


To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-dev-help@jakarta.apache.org

View raw message