New smart classloading

This commit is contained in:
hns 2002-11-29 17:58:28 +00:00
parent 719959353e
commit 62c54ce820
5 changed files with 38 additions and 8 deletions

View file

@ -929,6 +929,14 @@ public final class Application implements IPathElement, Runnable {
}
return null;
}
/**
* Return the application's classloader
*/
public ClassLoader getClassLoader () {
return typemgr.loader;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
/// The following methods mimic the IPathElement interface. This allows us

View file

@ -72,9 +72,9 @@ public final class RequestEvaluator implements Runnable {
if (scriptingEngine == null) {
String engineClassName = app.getProperty (
"scriptingEngine",
"helma.scripting.fesi.FesiEngine");
"helma.scripting.fesi.PhantomEngine");
try {
Class clazz = app.typemgr.loader.loadClass (engineClassName);
Class clazz = app.getClassLoader().loadClass (engineClassName);
scriptingEngine = (ScriptingEngine) clazz.newInstance ();
scriptingEngine.init (app, this);
} catch (Exception x) {
@ -666,6 +666,7 @@ public final class RequestEvaluator implements Runnable {
if (rtx == null || !rtx.isAlive()) {
// app.logEvent ("Starting Thread");
rtx = new Transactor (this, app.threadgroup, app.nmgr);
rtx.setContextClassLoader (app.getClassLoader ());
rtx.start ();
} else {
notifyAll ();

View file

@ -29,9 +29,7 @@ public class FilteredClassLoader extends URLClassLoader {
* Mask classes that implement the scripting engine(s) contained in helma.jar
*/
protected Class findClass (String name) throws ClassNotFoundException {
if (name != null && (name.startsWith ("helma.scripting.fesi") ||
name.startsWith ("helma.doc") ||
name.startsWith ("FESI")))
if (name != null && "helma.scripting.fesi.PhantomEngine".equals (name))
throw new ClassNotFoundException (name);
return super.findClass (name);
}

View file

@ -25,7 +25,7 @@ import FESI.Exceptions.*;
/**
* This is the implementation of ScriptingEnvironment for the FESI EcmaScript interpreter.
*/
public final class FesiEngine implements ScriptingEngine {
public class FesiEngine implements ScriptingEngine {
// the application we're running in
Application app;
@ -80,8 +80,7 @@ public final class FesiEngine implements ScriptingEngine {
wrappercache = new CacheMap (200, .75f);
prototypes = new Hashtable ();
try {
evaluator = new Evaluator();
evaluator.engine = this;
evaluator = new Evaluator(this);
global = evaluator.getGlobalObject();
for (int i=0; i<extensions.length; i++)
evaluator.addExtension (extensions[i]);
@ -753,6 +752,13 @@ public final class FesiEngine implements ScriptingEngine {
wrappercache.put (n, esn);
}
/**
* Return the application's classloader
*/
public ClassLoader getClassLoader () {
return app.getClassLoader ();
}
/**
* Return the RequestEvaluator owning and driving this FESI evaluator.
*/

View file

@ -0,0 +1,17 @@
// PhantomEngine.java
// Copyright (c) Hannes Wallnöfer 2002
package helma.scripting.fesi;
import helma.scripting.ScriptingException;
public final class PhantomEngine extends FesiEngine {
/**
*
*/
public Object invoke (Object thisObject, String functionName, Object[] args, boolean xmlrpc) throws ScriptingException {
return super.invoke (thisObject, functionName, args, xmlrpc);
}
}