ScriptingEngine interface got an additonal init() method.

FesiEvaluator was renamed to FesiEngine.
Some naming cleanups.
This commit is contained in:
hns 2002-11-21 15:57:35 +00:00
parent 039ab180be
commit ffbed8751e
15 changed files with 116 additions and 121 deletions

View file

@ -261,10 +261,10 @@ public abstract class ESLoader extends ESObject {
} else if (obj.getClass().isArray()) { } else if (obj.getClass().isArray()) {
return new ESArrayWrapper(obj, evaluator); return new ESArrayWrapper(obj, evaluator);
} // else if (obj instanceof helma.framework.IPathElement) { // Hannes Wallnoefer, 13. Aug 2001 } // else if (obj instanceof helma.framework.IPathElement) { // Hannes Wallnoefer, 13. Aug 2001
// return evaluator.reval.getElementWrapper ((helma.framework.IPathElement) obj); // return evaluator.engine.getElementWrapper ((helma.framework.IPathElement) obj);
// } // }
// return new ESWrapper(obj, evaluator); // return new ESWrapper(obj, evaluator);
return evaluator.reval.getObjectWrapper (obj); return evaluator.engine.getObjectWrapper (obj);
} }
/** /**

View file

@ -45,7 +45,7 @@ public class Evaluator {
// used to stop thread, 06.12.99 Hannes Wallnoefer // used to stop thread, 06.12.99 Hannes Wallnoefer
public volatile Thread thread; public volatile Thread thread;
// used to retrieve wrappers with correct Prototype for path elements in ESLoader // used to retrieve wrappers with correct Prototype for path elements in ESLoader
public helma.scripting.fesi.FesiEvaluator reval; public helma.scripting.fesi.FesiEngine engine;
private static String eol = System.getProperty("line.separator", "\n"); private static String eol = System.getProperty("line.separator", "\n");

View file

@ -12,9 +12,17 @@ import java.io.File;
/** /**
* This is the interface that must be implemented to make a scripting environment * This is the interface that must be implemented to make a scripting environment
* usable by the Helma application server. * usable by the Helma application server.
*
* Implementations of this interface must have a public zero-argument constructor
* to be usable by the Helma framework.
*/ */
public interface ScriptingEngine { public interface ScriptingEngine {
/**
* Init the scripting engine with an application and a request evaluator
*/
public void init (Application app, RequestEvaluator reval);
/** /**
* This method is called before an execution context for a request * This method is called before an execution context for a request
* evaluation is entered to let the Engine know it should update * evaluation is entered to let the Engine know it should update

View file

@ -18,11 +18,11 @@ import FESI.Data.ESWrapper;
public class ESBeanWrapper extends ESWrapper { public class ESBeanWrapper extends ESWrapper {
FesiEvaluator eval; FesiEngine engine;
public ESBeanWrapper (Object object, FesiEvaluator eval) { public ESBeanWrapper (Object object, FesiEngine engine) {
super (object, eval.getEvaluator(),true); super (object, engine.getEvaluator(),true);
this.eval = eval; this.engine = engine;
} }
/** /**
@ -35,9 +35,9 @@ public class ESBeanWrapper extends ESWrapper {
if (val instanceof ESWrapper) { if (val instanceof ESWrapper) {
Object theObject = ((ESWrapper)val).getJavaObject (); Object theObject = ((ESWrapper)val).getJavaObject ();
if (val instanceof ESWrapper && theObject instanceof INode) { if (val instanceof ESWrapper && theObject instanceof INode) {
return eval.getNodeWrapper ((INode) theObject); return engine.getNodeWrapper ((INode) theObject);
} else if (val instanceof ESWrapper && theObject instanceof Map) { } else if (val instanceof ESWrapper && theObject instanceof Map) {
ESMapWrapper wrapper = new ESMapWrapper(eval, (Map) theObject); ESMapWrapper wrapper = new ESMapWrapper(engine, (Map) theObject);
if (theObject instanceof SystemProperties && super.getJavaObject () instanceof ApplicationBean) if (theObject instanceof SystemProperties && super.getJavaObject () instanceof ApplicationBean)
wrapper.setReadonly(true); wrapper.setReadonly(true);
return wrapper; return wrapper;

View file

@ -20,17 +20,17 @@ import java.util.*;
public class ESMapWrapper extends ESWrapper { public class ESMapWrapper extends ESWrapper {
private Map data; private Map data;
private FesiEvaluator fesi; private FesiEngine engine;
private boolean readonly = false; private boolean readonly = false;
public ESMapWrapper (FesiEvaluator fesi) { public ESMapWrapper (FesiEngine engine) {
super (new Object(), fesi.getEvaluator ()); super (new Object(), engine.getEvaluator ());
this.fesi = fesi; this.engine = engine;
} }
public ESMapWrapper (FesiEvaluator fesi, Map data) { public ESMapWrapper (FesiEngine engine, Map data) {
super (new Object(), fesi.getEvaluator ()); super (new Object(), engine.getEvaluator ());
this.fesi = fesi; this.engine = engine;
this.data = data; this.data = data;
} }
@ -76,9 +76,9 @@ public class ESMapWrapper extends ESWrapper {
if (val instanceof String) if (val instanceof String)
return new ESString ((String) val); return new ESString ((String) val);
else if (val instanceof INode) else if (val instanceof INode)
return fesi.getNodeWrapper ((INode) val); return engine.getNodeWrapper ((INode) val);
else if (val instanceof Map) else if (val instanceof Map)
return new ESMapWrapper (fesi, (Map)val); return new ESMapWrapper (engine, (Map)val);
else if (val instanceof ESValue) else if (val instanceof ESValue)
return (ESValue) val; return (ESValue) val;
return ESLoader.normalizeValue(val, evaluator); return ESLoader.normalizeValue(val, evaluator);

View file

@ -35,14 +35,14 @@ public class ESNode extends ObjectPrototype {
NodeHandle handle; NodeHandle handle;
DbMapping dbmap; DbMapping dbmap;
Throwable lastError = null; Throwable lastError = null;
FesiEvaluator eval; FesiEngine engine;
/** /**
* Constructor used to create transient cache nodes * Constructor used to create transient cache nodes
*/ */
public ESNode (INode node, FesiEvaluator eval) { public ESNode (INode node, FesiEngine engine) {
super (eval.getPrototype("hopobject"), eval.getEvaluator()); super (engine.getPrototype("hopobject"), engine.getEvaluator());
this.eval = eval; this.engine = engine;
this.node = node; this.node = node;
cache = null; cache = null;
cacheWrapper = null; cacheWrapper = null;
@ -51,10 +51,10 @@ public class ESNode extends ObjectPrototype {
handle = null; handle = null;
} }
public ESNode (ESObject prototype, Evaluator evaluator, Object obj, FesiEvaluator eval) { public ESNode (ESObject prototype, Evaluator evaluator, Object obj, FesiEngine engine) {
super (prototype, evaluator); super (prototype, evaluator);
// eval.app.logEvent ("in ESNode constructor: "+o.getClass ()); // eval.app.logEvent ("in ESNode constructor: "+o.getClass ());
this.eval = eval; this.engine = engine;
if (obj == null) if (obj == null)
node = new TransientNode (null); node = new TransientNode (null);
else if (obj instanceof ESWrapper) else if (obj instanceof ESWrapper)
@ -80,7 +80,7 @@ public class ESNode extends ObjectPrototype {
*/ */
protected void checkNode () { protected void checkNode () {
if (node.getState () == INode.INVALID) try { if (node.getState () == INode.INVALID) try {
node = handle.getNode (eval.app.getWrappedNodeManager ()); node = handle.getNode (engine.app.getWrappedNodeManager ());
} catch (Exception nx) {} } catch (Exception nx) {}
} }
@ -137,7 +137,7 @@ public class ESNode extends ObjectPrototype {
if (e != null) { if (e != null) {
theArray.setSize(l); theArray.setSize(l);
for (int i = 0; i<l; i++) { for (int i = 0; i<l; i++) {
theArray.setElementAt (eval.getNodeWrapper ((INode) e.nextElement ()), i); theArray.setElementAt (engine.getNodeWrapper ((INode) e.nextElement ()), i);
} }
} else { } else {
theArray.setSize (0); theArray.setSize (0);
@ -275,7 +275,7 @@ public class ESNode extends ObjectPrototype {
public void putProperty(String propertyName, ESValue propertyValue, int hash) throws EcmaScriptException { public void putProperty(String propertyName, ESValue propertyValue, int hash) throws EcmaScriptException {
checkNode (); checkNode ();
// eval.app.logEvent ("put property called: "+propertyName+", "+propertyValue.getClass()); // engine.app.logEvent ("put property called: "+propertyName+", "+propertyValue.getClass());
if ("cache".equalsIgnoreCase (propertyName)) if ("cache".equalsIgnoreCase (propertyName))
throw new EcmaScriptException ("Can't modify read-only property \""+propertyName+"\"."); throw new EcmaScriptException ("Can't modify read-only property \""+propertyName+"\".");
@ -306,9 +306,9 @@ public class ESNode extends ObjectPrototype {
// long now = System.currentTimeMillis (); // long now = System.currentTimeMillis ();
ESNode esn = (ESNode) propertyValue; ESNode esn = (ESNode) propertyValue;
node.setNode (propertyName, esn.getNode ()); node.setNode (propertyName, esn.getNode ());
// eval.app.logEvent ("*** spent "+(System.currentTimeMillis () - now)+" ms to set property "+propertyName); // engine.app.logEvent ("*** spent "+(System.currentTimeMillis () - now)+" ms to set property "+propertyName);
} else { } else {
// eval.app.logEvent ("got "+propertyValue.getClass ()); // engine.app.logEvent ("got "+propertyValue.getClass ());
// A persistent node can't store anything other than the types above, so throw an exception // A persistent node can't store anything other than the types above, so throw an exception
// throw new EcmaScriptException ("Can't set a JavaScript Object or Array as property of "+node); // throw new EcmaScriptException ("Can't set a JavaScript Object or Array as property of "+node);
node.setJavaObject (propertyName, propertyValue.toJavaObject ()); node.setJavaObject (propertyName, propertyValue.toJavaObject ());
@ -317,7 +317,7 @@ public class ESNode extends ObjectPrototype {
public boolean deleteProperty(String propertyName, int hash) throws EcmaScriptException { public boolean deleteProperty(String propertyName, int hash) throws EcmaScriptException {
checkNode (); checkNode ();
// eval.app.logEvent ("delete property called: "+propertyName); // engine.app.logEvent ("delete property called: "+propertyName);
if (node.get (propertyName, false) != null) { if (node.get (propertyName, false) != null) {
node.unset (propertyName); node.unset (propertyName);
return true; return true;
@ -330,7 +330,7 @@ public class ESNode extends ObjectPrototype {
INode n = node.getSubnodeAt (i); INode n = node.getSubnodeAt (i);
if (n == null) if (n == null)
return ESNull.theNull; return ESNull.theNull;
return eval.getNodeWrapper (n); return engine.getNodeWrapper (n);
} }
public void putProperty(int index, ESValue propertyValue) throws EcmaScriptException { public void putProperty(int index, ESValue propertyValue) throws EcmaScriptException {
@ -353,7 +353,7 @@ public class ESNode extends ObjectPrototype {
*/ */
public ESValue getProperty(String propertyName, int hash) throws EcmaScriptException { public ESValue getProperty(String propertyName, int hash) throws EcmaScriptException {
checkNode (); checkNode ();
// eval.app.logEvent ("get property called: "+propertyName); // engine.app.logEvent ("get property called: "+propertyName);
ESValue retval = super.getProperty (propertyName, hash); ESValue retval = super.getProperty (propertyName, hash);
if (! (retval instanceof ESUndefined)) if (! (retval instanceof ESUndefined))
return retval; return retval;
@ -374,7 +374,7 @@ public class ESNode extends ObjectPrototype {
if ("cache".equalsIgnoreCase (propertyName) && node instanceof Node) { if ("cache".equalsIgnoreCase (propertyName) && node instanceof Node) {
cache = node.getCacheNode (); cache = node.getCacheNode ();
if (cacheWrapper == null) if (cacheWrapper == null)
cacheWrapper = new ESNode (cache, eval); cacheWrapper = new ESNode (cache, engine);
else else
cacheWrapper.node = cache; cacheWrapper.node = cache;
return cacheWrapper; return cacheWrapper;
@ -411,7 +411,7 @@ public class ESNode extends ObjectPrototype {
if (nd == null) if (nd == null)
return ESNull.theNull; return ESNull.theNull;
else else
return eval.getNodeWrapper (nd); return engine.getNodeWrapper (nd);
} }
if (p.getType () == IProperty.JAVAOBJECT) if (p.getType () == IProperty.JAVAOBJECT)
return ESLoader.normalizeObject (p.getJavaObjectValue (), evaluator); return ESLoader.normalizeObject (p.getJavaObjectValue (), evaluator);
@ -420,7 +420,7 @@ public class ESNode extends ObjectPrototype {
// as last resort, try to get property as anonymous subnode // as last resort, try to get property as anonymous subnode
INode anon = node.getSubnode (propertyName); INode anon = node.getSubnode (propertyName);
if (anon != null) if (anon != null)
return eval.getNodeWrapper (anon); return engine.getNodeWrapper (anon);
return ESNull.theNull; return ESNull.theNull;
} }
@ -445,7 +445,7 @@ public class ESNode extends ObjectPrototype {
if (n == null) if (n == null)
return ESNull.theNull; return ESNull.theNull;
else else
return eval.getNodeWrapper (n); return engine.getNodeWrapper (n);
} }
// some more internal properties // some more internal properties
if ("__name__".equals (propertyName)) if ("__name__".equals (propertyName))

View file

@ -31,7 +31,7 @@ public class FesiActionAdapter {
Application app; Application app;
String functionName; String functionName;
String sourceName; String sourceName;
// this is the parsed function which can be easily applied to FesiEvaluator objects // this is the parsed function which can be easily applied to FesiEngine objects
TypeUpdater pfunc, pfuncAsString; TypeUpdater pfunc, pfuncAsString;
public FesiActionAdapter (ActionFile action) { public FesiActionAdapter (ActionFile action) {
@ -74,11 +74,11 @@ public class FesiActionAdapter {
} }
public synchronized void updateEvaluator (FesiEvaluator fesi) throws EcmaScriptException { public synchronized void updateEvaluator (FesiEngine engine) throws EcmaScriptException {
if (pfunc != null) if (pfunc != null)
pfunc.updateEvaluator (fesi); pfunc.updateEvaluator (engine);
if (pfuncAsString != null) if (pfuncAsString != null)
pfuncAsString.updateEvaluator (fesi); pfuncAsString.updateEvaluator (engine);
} }
protected TypeUpdater parseFunction (String funcName, String params, Reader body, String sourceName) throws EcmaScriptException { protected TypeUpdater parseFunction (String funcName, String params, Reader body, String sourceName) throws EcmaScriptException {
@ -148,15 +148,15 @@ public class FesiActionAdapter {
this.functionName = functionName; this.functionName = functionName;
} }
public void updateEvaluator (FesiEvaluator fesi) throws EcmaScriptException { public void updateEvaluator (FesiEngine engine) throws EcmaScriptException {
ObjectPrototype op = fesi.getPrototype (prototype.getName()); ObjectPrototype op = engine.getPrototype (prototype.getName());
EcmaScriptVariableVisitor vdvisitor = fesi.evaluator.getVarDeclarationVisitor(); EcmaScriptVariableVisitor vdvisitor = engine.evaluator.getVarDeclarationVisitor();
Vector vnames = vdvisitor.processVariableDeclarations(sl, fes); Vector vnames = vdvisitor.processVariableDeclarations(sl, fes);
FunctionPrototype fp = ConstructedFunctionObject.makeNewConstructedFunction ( FunctionPrototype fp = ConstructedFunctionObject.makeNewConstructedFunction (
fesi.evaluator, functionName, fes, engine.evaluator, functionName, fes,
fullFunctionText, fpl.getArguments(), vnames, sl); fullFunctionText, fpl.getArguments(), vnames, sl);
op.putHiddenProperty (functionName, fp); op.putHiddenProperty (functionName, fp);
} }
@ -172,12 +172,12 @@ public class FesiActionAdapter {
errorMessage = msg; errorMessage = msg;
} }
public void updateEvaluator (FesiEvaluator fesi) throws EcmaScriptException { public void updateEvaluator (FesiEngine engine) throws EcmaScriptException {
ObjectPrototype op = fesi.getPrototype (prototype.getName ()); ObjectPrototype op = engine.getPrototype (prototype.getName ());
FunctionPrototype fp = (FunctionPrototype) fesi.evaluator.getFunctionPrototype (); FunctionPrototype fp = (FunctionPrototype) engine.evaluator.getFunctionPrototype ();
FunctionPrototype func = new ThrowException (functionName, fesi.evaluator, fp, errorMessage); FunctionPrototype func = new ThrowException (functionName, engine.evaluator, fp, errorMessage);
op.putHiddenProperty (functionName, func); op.putHiddenProperty (functionName, func);
} }
@ -198,7 +198,7 @@ public class FesiActionAdapter {
} }
interface TypeUpdater { interface TypeUpdater {
public void updateEvaluator (FesiEvaluator fesi) throws EcmaScriptException; public void updateEvaluator (FesiEngine engine) throws EcmaScriptException;
} }
} }

View file

@ -24,16 +24,16 @@ import FESI.Exceptions.*;
/** /**
* This is the implementation of ScriptingEnvironment for the FESI EcmaScript interpreter. * This is the implementation of ScriptingEnvironment for the FESI EcmaScript interpreter.
*/ */
public final class FesiEvaluator implements ScriptingEngine { public final class FesiEngine implements ScriptingEngine {
// the application we're running in // the application we're running in
public final Application app; Application app;
// The FESI evaluator // The FESI evaluator
final Evaluator evaluator; Evaluator evaluator;
// the global object // the global object
final GlobalObject global; GlobalObject global;
// caching table for JavaScript object wrappers // caching table for JavaScript object wrappers
CacheMap wrappercache; CacheMap wrappercache;
@ -42,10 +42,10 @@ public final class FesiEvaluator implements ScriptingEngine {
Hashtable prototypes; Hashtable prototypes;
// the request evaluator instance owning this fesi evaluator // the request evaluator instance owning this fesi evaluator
final RequestEvaluator reval; RequestEvaluator reval;
// extensions loaded by this evaluator // extensions loaded by this evaluator
static String[] extensions = new String[] { static final String[] extensions = new String[] {
"FESI.Extensions.BasicIO", "FESI.Extensions.BasicIO",
"FESI.Extensions.FileIO", "FESI.Extensions.FileIO",
"helma.scripting.fesi.extensions.XmlRpcExtension", "helma.scripting.fesi.extensions.XmlRpcExtension",
@ -64,16 +64,21 @@ public final class FesiEvaluator implements ScriptingEngine {
/** /**
* Create a FESI evaluator for the given application and request evaluator. * Zero argument constructor.
*/ */
public FesiEvaluator (Application app, RequestEvaluator reval) { public FesiEngine () {}
/**
* Initialize a FESI evaluator for the given application and request evaluator.
*/
public void init (Application app, RequestEvaluator reval) {
this.app = app; this.app = app;
this.reval = reval; this.reval = reval;
wrappercache = new CacheMap (200, .75f); wrappercache = new CacheMap (200, .75f);
prototypes = new Hashtable (); prototypes = new Hashtable ();
try { try {
evaluator = new Evaluator(); evaluator = new Evaluator();
evaluator.reval = this; evaluator.engine = this;
global = evaluator.getGlobalObject(); global = evaluator.getGlobalObject();
for (int i=0; i<extensions.length; i++) for (int i=0; i<extensions.length; i++)
evaluator.addExtension (extensions[i]); evaluator.addExtension (extensions[i]);

View file

@ -1,18 +0,0 @@
// FesiEngineFactory.java
// Copyright (c) Hannes Wallnöfer 2002
package helma.scripting.fesi;
import helma.scripting.*;
import helma.framework.core.*;
/**
* Factory class for FESI evalator engines.
*/
public final class FesiEngineFactory {
public static ScriptingEngine getEngine (Application app, RequestEvaluator reval) {
return new FesiEvaluator (app, reval);
}
}

View file

@ -30,7 +30,7 @@ import org.xml.sax.InputSource;
public final class HopExtension { public final class HopExtension {
protected Application app; protected Application app;
protected FesiEvaluator fesi; protected FesiEngine engine;
public HopExtension (Application app) { public HopExtension (Application app) {
this.app = app; this.app = app;
@ -40,9 +40,9 @@ public final class HopExtension {
/** /**
* Called by the evaluator after the extension is loaded. * Called by the evaluator after the extension is loaded.
*/ */
public void initializeExtension (FesiEvaluator fesi) throws EcmaScriptException { public void initializeExtension (FesiEngine engine) throws EcmaScriptException {
this.fesi = fesi; this.engine = engine;
Evaluator evaluator = fesi.getEvaluator (); Evaluator evaluator = engine.getEvaluator ();
GlobalObject go = evaluator.getGlobalObject(); GlobalObject go = evaluator.getGlobalObject();
FunctionPrototype fp = (FunctionPrototype) evaluator.getFunctionPrototype(); FunctionPrototype fp = (FunctionPrototype) evaluator.getFunctionPrototype();
@ -68,7 +68,7 @@ public final class HopExtension {
// the Session prototype // the Session prototype
ObjectPrototype esSessionPrototype = new ObjectPrototype (esNodePrototype, evaluator); ObjectPrototype esSessionPrototype = new ObjectPrototype (esNodePrototype, evaluator);
// the Node constructor // the Node constructor
ESObject node = new NodeConstructor ("Node", fp, fesi); ESObject node = new NodeConstructor ("Node", fp, engine);
// register the default methods of Node objects in the Node prototype // register the default methods of Node objects in the Node prototype
esNodePrototype.putHiddenProperty ("add", new NodeAdd ("add", evaluator, fp)); esNodePrototype.putHiddenProperty ("add", new NodeAdd ("add", evaluator, fp));
@ -119,11 +119,11 @@ public final class HopExtension {
go.putHiddenProperty("authenticate", new GlobalAuthenticate ("authenticate", evaluator, fp)); go.putHiddenProperty("authenticate", new GlobalAuthenticate ("authenticate", evaluator, fp));
go.deleteProperty("exit", "exit".hashCode()); go.deleteProperty("exit", "exit".hashCode());
// register object prototypes with FesiEvaluator // register object prototypes with FesiEngine
fesi.putPrototype ("global", go); engine.putPrototype ("global", go);
fesi.putPrototype ("hopobject", esNodePrototype); engine.putPrototype ("hopobject", esNodePrototype);
fesi.putPrototype ("__javaobject__", esObjectPrototype); engine.putPrototype ("__javaobject__", esObjectPrototype);
// fesi.putPrototype ("session", esSessionPrototype); // engine.putPrototype ("session", esSessionPrototype);
} }
class NodeAdd extends BuiltinFunctionObject { class NodeAdd extends BuiltinFunctionObject {
@ -496,7 +496,7 @@ public final class HopExtension {
// retrieve res.skinpath, an array of objects that tell us where to look for skins // retrieve res.skinpath, an array of objects that tell us where to look for skins
// (strings for directory names and INodes for internal, db-stored skinsets) // (strings for directory names and INodes for internal, db-stored skinsets)
ResponseTrans res = fesi.getResponse(); ResponseTrans res = engine.getResponse();
Object[] skinpath = res.getSkinpath (); Object[] skinpath = res.getSkinpath ();
// ready... retrieve the skin and render it. // ready... retrieve the skin and render it.
@ -512,7 +512,7 @@ public final class HopExtension {
if (asString) if (asString)
res.pushStringBuffer (); res.pushStringBuffer ();
if (skin != null) if (skin != null)
skin.render (fesi.getRequestEvaluator(), javaObject, params); skin.render (engine.getRequestEvaluator(), javaObject, params);
else else
res.write ("[Skin not found: "+arguments[0]+"]"); res.write ("[Skin not found: "+arguments[0]+"]");
if (asString) if (asString)
@ -768,7 +768,7 @@ public final class HopExtension {
// first, look in the object href was called on. // first, look in the object href was called on.
Object skinElem = elem; Object skinElem = elem;
Skin skin = null; Skin skin = null;
// ResponseTrans res = fesi.getResponse(); // ResponseTrans res = engine.getResponse();
// Object[] skinpath = res.getSkinpath (); // Object[] skinpath = res.getSkinpath ();
while (skin == null && skinElem != null) { while (skin == null && skinElem != null) {
Prototype proto = app.getPrototype (skinElem); Prototype proto = app.getPrototype (skinElem);
@ -792,11 +792,11 @@ public final class HopExtension {
return new ESString (basicHref); return new ESString (basicHref);
} }
private ESString renderSkin (Skin skin, String path, Object skinElem) throws EcmaScriptException { private ESString renderSkin (Skin skin, String path, Object skinElem) throws EcmaScriptException {
fesi.getResponse().pushStringBuffer (); engine.getResponse().pushStringBuffer ();
HashMap param = new HashMap (); HashMap param = new HashMap ();
param.put ("path", path); param.put ("path", path);
skin.render (fesi.getRequestEvaluator(), skinElem, param); skin.render (engine.getRequestEvaluator(), skinElem, param);
return new ESString (fesi.getResponse().popStringBuffer ().trim ()); return new ESString (engine.getResponse().popStringBuffer ().trim ());
} }
} }

View file

@ -16,13 +16,13 @@ import FESI.Interpreter.*;
public class NodeConstructor extends BuiltinFunctionObject { public class NodeConstructor extends BuiltinFunctionObject {
FesiEvaluator fesi; FesiEngine engine;
String typename; String typename;
public NodeConstructor (String name, FunctionPrototype fp, FesiEvaluator fesi) { public NodeConstructor (String name, FunctionPrototype fp, FesiEngine engine) {
super(fp, fesi.getEvaluator (), name, 1); super(fp, engine.getEvaluator (), name, 1);
typename = name; typename = name;
this.fesi = fesi; this.engine = engine;
} }
public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException { public ESValue callFunction(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
@ -31,22 +31,22 @@ public class NodeConstructor extends BuiltinFunctionObject {
public ESObject doConstruct(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException { public ESObject doConstruct(ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
ESNode node = null; ESNode node = null;
Application app = fesi.getApplication (); Application app = engine.getApplication ();
if ("Node".equals (typename) || "hopobject".equalsIgnoreCase (typename)) { if ("Node".equals (typename) || "hopobject".equalsIgnoreCase (typename)) {
String nodeName = null; String nodeName = null;
if (arguments.length > 0 && arguments[0] != null) if (arguments.length > 0 && arguments[0] != null)
nodeName = arguments[0].toString(); nodeName = arguments[0].toString();
Node n = new Node (nodeName, (String) null, app.getWrappedNodeManager ()); Node n = new Node (nodeName, (String) null, app.getWrappedNodeManager ());
node = new ESNode (fesi.getPrototype ("hopobject"), this.evaluator, n, fesi); node = new ESNode (engine.getPrototype ("hopobject"), this.evaluator, n, engine);
fesi.putNodeWrapper (node.getNode (), node); engine.putNodeWrapper (node.getNode (), node);
} else { } else {
// Typed nodes are instantiated as helma.objectmodel.db.Node from the beginning // Typed nodes are instantiated as helma.objectmodel.db.Node from the beginning
// even if we don't know yet if they are going to be stored in a database. The reason // even if we don't know yet if they are going to be stored in a database. The reason
// is that we want to be able to use the specail features like subnode relations even for // is that we want to be able to use the specail features like subnode relations even for
// transient nodes. // transient nodes.
ObjectPrototype op = fesi.getPrototype (typename); ObjectPrototype op = engine.getPrototype (typename);
Node n = new Node (typename, typename, app.getWrappedNodeManager ()); Node n = new Node (typename, typename, app.getWrappedNodeManager ());
node = new ESNode (op, fesi.getEvaluator (), n, fesi); node = new ESNode (op, engine.getEvaluator (), n, engine);
node.setPrototype (typename); node.setPrototype (typename);
node.getNode ().setDbMapping (app.getDbMapping (typename)); node.getNode ().setDbMapping (app.getDbMapping (typename));
try { try {
@ -55,9 +55,9 @@ public class NodeConstructor extends BuiltinFunctionObject {
// HACK: There is an incompatibility problem here, because the property // HACK: There is an incompatibility problem here, because the property
// constructor is defined as the constructor of the object by EcmaScript. // constructor is defined as the constructor of the object by EcmaScript.
if (op.getProperty ("constructor", "constructor".hashCode()) instanceof ConstructedFunctionObject) if (op.getProperty ("constructor", "constructor".hashCode()) instanceof ConstructedFunctionObject)
node.doIndirectCall (fesi.getEvaluator(), node, "constructor", arguments); node.doIndirectCall (engine.getEvaluator(), node, "constructor", arguments);
else else
node.doIndirectCall (fesi.getEvaluator(), node, typename, arguments); node.doIndirectCall (engine.getEvaluator(), node, typename, arguments);
} catch (Exception ignore) {} } catch (Exception ignore) {}
} }
return node; return node;
@ -69,7 +69,7 @@ public class NodeConstructor extends BuiltinFunctionObject {
public ESValue getProperty(String propertyName, int hash) throws EcmaScriptException { public ESValue getProperty(String propertyName, int hash) throws EcmaScriptException {
if ("prototype".equals (propertyName)) if ("prototype".equals (propertyName))
return fesi.getPrototype (typename); return engine.getPrototype (typename);
return super.getProperty(propertyName, hash); return super.getProperty(propertyName, hash);
} }

View file

@ -76,7 +76,7 @@ public class DomExtension extends Extension {
writer.close(); writer.close();
File finalFile = new File(arguments[1].toString()); File finalFile = new File(arguments[1].toString());
tmpFile.renameTo (finalFile); tmpFile.renameTo (finalFile);
this.evaluator.reval.app.logEvent("wrote xml to " + finalFile.getAbsolutePath() ); this.evaluator.engine.getApplication().logEvent("wrote xml to " + finalFile.getAbsolutePath() );
} catch (IOException io) { } catch (IOException io) {
throw new EcmaScriptException (io.toString()); throw new EcmaScriptException (io.toString());
} }
@ -132,7 +132,7 @@ public class DomExtension extends Extension {
node = ((ESNode)arguments[1]).getNode(); node = ((ESNode)arguments[1]).getNode();
} catch ( Exception e ) { //classcast, arrayindex etc } catch ( Exception e ) { //classcast, arrayindex etc
// make sure we have a node, even if 2nd arg doesn't exist or is not a node // make sure we have a node, even if 2nd arg doesn't exist or is not a node
node = new Node ( (String)null, (String)null, this.evaluator.reval.app.getWrappedNodeManager() ); node = new Node ( (String)null, (String)null, this.evaluator.engine.getApplication().getWrappedNodeManager() );
} }
try { try {
XmlReader reader = new XmlReader (); XmlReader reader = new XmlReader ();
@ -141,7 +141,7 @@ public class DomExtension extends Extension {
result = reader.read (new StringReader (arguments[0].toString()),node); result = reader.read (new StringReader (arguments[0].toString()),node);
else else
result = reader.read (new File(arguments[0].toString()),node); result = reader.read (new File(arguments[0].toString()),node);
return this.evaluator.reval.getNodeWrapper (result); return this.evaluator.engine.getNodeWrapper (result);
} catch ( NoClassDefFoundError e ) { } catch ( NoClassDefFoundError e ) {
throw new EcmaScriptException ("Can't load XML parser:"+e); throw new EcmaScriptException ("Can't load XML parser:"+e);
} catch ( Exception f ) { } catch ( Exception f ) {
@ -164,9 +164,9 @@ public class DomExtension extends Extension {
} else { } else {
converter = new XmlConverter (); converter = new XmlConverter ();
} }
INode node = new helma.objectmodel.db.Node ( (String)null, (String)null, this.evaluator.reval.app.getWrappedNodeManager() ); INode node = new helma.objectmodel.db.Node ( (String)null, (String)null, this.evaluator.engine.getApplication().getWrappedNodeManager() );
INode result = converter.convert (arguments[0].toString(),node); INode result = converter.convert (arguments[0].toString(),node);
return this.evaluator.reval.getNodeWrapper(result); return this.evaluator.engine.getNodeWrapper(result);
} catch ( NoClassDefFoundError e ) { } catch ( NoClassDefFoundError e ) {
throw new EcmaScriptException("Can't load dom-capable xml parser."); throw new EcmaScriptException("Can't load dom-capable xml parser.");
} catch ( RuntimeException f ) { } catch ( RuntimeException f ) {

View file

@ -63,7 +63,7 @@ public class ESMail extends ESObject implements Serializable {
Session session = Session.getDefaultInstance(props, null); Session session = Session.getDefaultInstance(props, null);
message = new MimeMessage (session); message = new MimeMessage (session);
} catch (Throwable t) { } catch (Throwable t) {
this.evaluator.reval.app.logEvent ("Error in mail constructor: "+t); this.evaluator.engine.getApplication().logEvent ("Error in mail constructor: "+t);
} }
} }

View file

@ -242,7 +242,7 @@ public class MailExtension extends Extension {
try { try {
mail.send (); mail.send ();
} catch (Exception x) { } catch (Exception x) {
this.evaluator.reval.app.logEvent ("Error sending mail: "+x); evaluator.engine.getApplication().logEvent ("Error sending mail: "+x);
mail.setStatus (ESMail.SEND); mail.setStatus (ESMail.SEND);
return ESBoolean.makeBoolean(false); return ESBoolean.makeBoolean(false);
} }

View file

@ -5,7 +5,7 @@ package helma.scripting.fesi.extensions;
import org.apache.xmlrpc.*; import org.apache.xmlrpc.*;
import helma.scripting.fesi.FesiEvaluator; import helma.scripting.fesi.FesiEngine;
import FESI.Interpreter.*; import FESI.Interpreter.*;
import FESI.Exceptions.*; import FESI.Exceptions.*;
@ -100,14 +100,14 @@ public class XmlRpcExtension extends Extension {
public ESValue doIndirectCall(Evaluator evaluator, ESObject target, String functionName, ESValue arguments[]) public ESValue doIndirectCall(Evaluator evaluator, ESObject target, String functionName, ESValue arguments[])
throws EcmaScriptException, NoSuchMethodException { throws EcmaScriptException, NoSuchMethodException {
// System.out.println ("doIndirectCall called with "+functionName); // System.out.println ("doIndirectCall called with "+remoteObject+"."+functionName);
XmlRpcClient client = new XmlRpcClient (url); XmlRpcClient client = new XmlRpcClient (url);
// long now = System.currentTimeMillis (); // long now = System.currentTimeMillis ();
Object retval = null; Object retval = null;
int l = arguments.length; int l = arguments.length;
Vector v = new Vector (); Vector v = new Vector ();
for (int i=0; i<l; i++) { for (int i=0; i<l; i++) {
Object arg = FesiEvaluator.processXmlRpcResponse (arguments[i]); Object arg = FesiEngine.processXmlRpcResponse (arguments[i]);
// System.out.println ("converted to J: "+arg.getClass ()); // System.out.println ("converted to J: "+arg.getClass ());
v.addElement (arg); v.addElement (arg);
} }
@ -117,7 +117,7 @@ public class XmlRpcExtension extends Extension {
String method = remoteObject == null ? functionName : remoteObject+"."+functionName; String method = remoteObject == null ? functionName : remoteObject+"."+functionName;
retval = client.execute (method, v); retval = client.execute (method, v);
esretval.putProperty ("error", ESNull.theNull, "error".hashCode()); esretval.putProperty ("error", ESNull.theNull, "error".hashCode());
esretval.putProperty ("result", FesiEvaluator.processXmlRpcArgument (retval, evaluator), "result".hashCode()); esretval.putProperty ("result", FesiEngine.processXmlRpcArgument (retval, evaluator), "result".hashCode());
} catch (Exception x) { } catch (Exception x) {
String msg = x.getMessage(); String msg = x.getMessage();
if (msg == null || msg.length() == 0) if (msg == null || msg.length() == 0)