This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Multiple Environments in embedded Kawa
- From: Per Bothner <per at bothner dot com>
- To: holubar at arsystel dot com, kawa at sourceware dot org
- Date: Wed, 15 Oct 2014 10:29:07 -0700
- Subject: Re: Multiple Environments in embedded Kawa
- Authentication-results: sourceware.org; auth=none
- References: <59406 dot 88 dot 217 dot 192 dot 178 dot 1413366384 dot squirrel at mail dot arsystel dot com>
On 10/15/2014 02:46 AM, holubar@arsystel.com wrote:
Hello,
I hope this is the right forum for this question.
I'm evaluating the use of Kawa as an embedded scripting engine in a Java
application. I would need to use multiple independent environments (one
per user, for example).
Is this (easily) possible? I could not find any documentation for that and
looking at the source it is not evident how to do that.
This page may be helpful:
http://www.gnu.org/software/kawa/Evaluating-Scheme-expressions-from-Java.html
Note that I strongly recommend having a separate thread for each "user".
There are a number of places Kawa uses thread-local variables to find
the "current whatever" - for example Environment.getCurrent().
This is an area of Kawa I haven't pushed on very hard, so there may be pitfalls.
For example, currently there is a global ModuleManager instance. You might need
to have it be per-user - depending on what your goals are.
You have to be careful about the security implications. If users can (directly
or indirectly) type in Scheme expressions, and multiple users can use the same
JVM at the same time, then you have to be extremely careful. Even if you trust
your users to not be malicious, they might be tricked into doing something bad,
and you don't want that to compromise your entire system.
--
--Per Bothner
per@bothner.com http://per.bothner.com/