From: Toby A. <tob...@pe...> - 2004-03-09 20:52:40
|
I'm wanting to use JScheme as a way to script a J2EE application. I want to be able to run a scheme program that can send a closure to the J2EE application and have it executed by an EJB. The serialization support I submitted is one part of this. The next big hurdle is that I don't want the results of executing a closure in the EJB to taint future executions, and I want to support multiple threads executing independently. Because everything is static, the only way that I can see to have independent interpreters is to play games with class loaders, i.e. to create a new class loader to load the JScheme classes for each interpreter instance. This approach is unsatisfactory to me because I intend to run in a J2EE environment and messing with class loaders is explicitly forbidden by the specification. The performance impact of creating a class loader and loading the classes also troubles me. I propose to make all per-interpreter state (e.g. the dynamic environments, input/output ports) non-static and introduce a per-thread "current interpreter". I see two alternative implementation strategies: 1) Introduce a new class, jsint.Interpreter, that is essentially a de-static-ed version of jsint.Scheme. Then, replace the contents of each static method in jsint.Scheme with delegation to the corresponding method of the current jsint.Interpreter instance. 2) De-static-ify jsint.Scheme and change every static call to Scheme.<something> to Scheme.currentInterpreter().<something>. My questions are: Does anyone see a better or easier way to achieve what I want? Which of the two proposed options would be preferred? Toby. P.S. Yes, I am volunteering to make these changes. |