ScriptingEngine interface got an additonal init() method.
FesiEvaluator was renamed to FesiEngine. Some naming cleanups.
This commit is contained in:
parent
039ab180be
commit
ffbed8751e
15 changed files with 116 additions and 121 deletions
|
@ -261,10 +261,10 @@ public abstract class ESLoader extends ESObject {
|
|||
} else if (obj.getClass().isArray()) {
|
||||
return new ESArrayWrapper(obj, evaluator);
|
||||
} // 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 evaluator.reval.getObjectWrapper (obj);
|
||||
return evaluator.engine.getObjectWrapper (obj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,7 @@ public class Evaluator {
|
|||
// used to stop thread, 06.12.99 Hannes Wallnoefer
|
||||
public volatile Thread thread;
|
||||
// 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");
|
||||
|
||||
|
|
|
@ -12,9 +12,17 @@ import java.io.File;
|
|||
/**
|
||||
* This is the interface that must be implemented to make a scripting environment
|
||||
* 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 {
|
||||
|
||||
/**
|
||||
* 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
|
||||
* evaluation is entered to let the Engine know it should update
|
||||
|
|
|
@ -18,26 +18,26 @@ import FESI.Data.ESWrapper;
|
|||
|
||||
public class ESBeanWrapper extends ESWrapper {
|
||||
|
||||
FesiEvaluator eval;
|
||||
FesiEngine engine;
|
||||
|
||||
public ESBeanWrapper (Object object, FesiEvaluator eval) {
|
||||
super (object, eval.getEvaluator(),true);
|
||||
this.eval = eval;
|
||||
}
|
||||
public ESBeanWrapper (Object object, FesiEngine engine) {
|
||||
super (object, engine.getEvaluator(),true);
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap getProperty, return ESNode if INode would be returned,
|
||||
* ESMapWrapper if Map would be returned.
|
||||
*/
|
||||
/**
|
||||
* Wrap getProperty, return ESNode if INode would be returned,
|
||||
* ESMapWrapper if Map would be returned.
|
||||
*/
|
||||
public ESValue getProperty(String propertyName, int hash) throws EcmaScriptException {
|
||||
try {
|
||||
ESValue val = super.getProperty (propertyName, hash);
|
||||
if (val instanceof ESWrapper) {
|
||||
Object theObject = ((ESWrapper)val).getJavaObject ();
|
||||
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) {
|
||||
ESMapWrapper wrapper = new ESMapWrapper(eval, (Map) theObject);
|
||||
ESMapWrapper wrapper = new ESMapWrapper(engine, (Map) theObject);
|
||||
if (theObject instanceof SystemProperties && super.getJavaObject () instanceof ApplicationBean)
|
||||
wrapper.setReadonly(true);
|
||||
return wrapper;
|
||||
|
@ -57,7 +57,7 @@ public class ESBeanWrapper extends ESWrapper {
|
|||
throw new EcmaScriptException("can't set property " + propertyName +
|
||||
" to this value on " + getJavaObject().toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,17 +20,17 @@ import java.util.*;
|
|||
public class ESMapWrapper extends ESWrapper {
|
||||
|
||||
private Map data;
|
||||
private FesiEvaluator fesi;
|
||||
private FesiEngine engine;
|
||||
private boolean readonly = false;
|
||||
|
||||
public ESMapWrapper (FesiEvaluator fesi) {
|
||||
super (new Object(), fesi.getEvaluator ());
|
||||
this.fesi = fesi;
|
||||
public ESMapWrapper (FesiEngine engine) {
|
||||
super (new Object(), engine.getEvaluator ());
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
public ESMapWrapper (FesiEvaluator fesi, Map data) {
|
||||
super (new Object(), fesi.getEvaluator ());
|
||||
this.fesi = fesi;
|
||||
public ESMapWrapper (FesiEngine engine, Map data) {
|
||||
super (new Object(), engine.getEvaluator ());
|
||||
this.engine = engine;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
@ -76,9 +76,9 @@ public class ESMapWrapper extends ESWrapper {
|
|||
if (val instanceof String)
|
||||
return new ESString ((String) val);
|
||||
else if (val instanceof INode)
|
||||
return fesi.getNodeWrapper ((INode) val);
|
||||
return engine.getNodeWrapper ((INode) val);
|
||||
else if (val instanceof Map)
|
||||
return new ESMapWrapper (fesi, (Map)val);
|
||||
return new ESMapWrapper (engine, (Map)val);
|
||||
else if (val instanceof ESValue)
|
||||
return (ESValue) val;
|
||||
return ESLoader.normalizeValue(val, evaluator);
|
||||
|
|
|
@ -35,14 +35,14 @@ public class ESNode extends ObjectPrototype {
|
|||
NodeHandle handle;
|
||||
DbMapping dbmap;
|
||||
Throwable lastError = null;
|
||||
FesiEvaluator eval;
|
||||
FesiEngine engine;
|
||||
|
||||
/**
|
||||
* Constructor used to create transient cache nodes
|
||||
*/
|
||||
public ESNode (INode node, FesiEvaluator eval) {
|
||||
super (eval.getPrototype("hopobject"), eval.getEvaluator());
|
||||
this.eval = eval;
|
||||
public ESNode (INode node, FesiEngine engine) {
|
||||
super (engine.getPrototype("hopobject"), engine.getEvaluator());
|
||||
this.engine = engine;
|
||||
this.node = node;
|
||||
cache = null;
|
||||
cacheWrapper = null;
|
||||
|
@ -51,10 +51,10 @@ public class ESNode extends ObjectPrototype {
|
|||
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);
|
||||
// eval.app.logEvent ("in ESNode constructor: "+o.getClass ());
|
||||
this.eval = eval;
|
||||
this.engine = engine;
|
||||
if (obj == null)
|
||||
node = new TransientNode (null);
|
||||
else if (obj instanceof ESWrapper)
|
||||
|
@ -80,7 +80,7 @@ public class ESNode extends ObjectPrototype {
|
|||
*/
|
||||
protected void checkNode () {
|
||||
if (node.getState () == INode.INVALID) try {
|
||||
node = handle.getNode (eval.app.getWrappedNodeManager ());
|
||||
node = handle.getNode (engine.app.getWrappedNodeManager ());
|
||||
} catch (Exception nx) {}
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class ESNode extends ObjectPrototype {
|
|||
if (e != null) {
|
||||
theArray.setSize(l);
|
||||
for (int i = 0; i<l; i++) {
|
||||
theArray.setElementAt (eval.getNodeWrapper ((INode) e.nextElement ()), i);
|
||||
theArray.setElementAt (engine.getNodeWrapper ((INode) e.nextElement ()), i);
|
||||
}
|
||||
} else {
|
||||
theArray.setSize (0);
|
||||
|
@ -275,7 +275,7 @@ public class ESNode extends ObjectPrototype {
|
|||
|
||||
public void putProperty(String propertyName, ESValue propertyValue, int hash) throws EcmaScriptException {
|
||||
checkNode ();
|
||||
// eval.app.logEvent ("put property called: "+propertyName+", "+propertyValue.getClass());
|
||||
// engine.app.logEvent ("put property called: "+propertyName+", "+propertyValue.getClass());
|
||||
if ("cache".equalsIgnoreCase (propertyName))
|
||||
throw new EcmaScriptException ("Can't modify read-only property \""+propertyName+"\".");
|
||||
|
||||
|
@ -306,9 +306,9 @@ public class ESNode extends ObjectPrototype {
|
|||
// long now = System.currentTimeMillis ();
|
||||
ESNode esn = (ESNode) propertyValue;
|
||||
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 {
|
||||
// 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
|
||||
// throw new EcmaScriptException ("Can't set a JavaScript Object or Array as property of "+node);
|
||||
node.setJavaObject (propertyName, propertyValue.toJavaObject ());
|
||||
|
@ -317,7 +317,7 @@ public class ESNode extends ObjectPrototype {
|
|||
|
||||
public boolean deleteProperty(String propertyName, int hash) throws EcmaScriptException {
|
||||
checkNode ();
|
||||
// eval.app.logEvent ("delete property called: "+propertyName);
|
||||
// engine.app.logEvent ("delete property called: "+propertyName);
|
||||
if (node.get (propertyName, false) != null) {
|
||||
node.unset (propertyName);
|
||||
return true;
|
||||
|
@ -330,7 +330,7 @@ public class ESNode extends ObjectPrototype {
|
|||
INode n = node.getSubnodeAt (i);
|
||||
if (n == null)
|
||||
return ESNull.theNull;
|
||||
return eval.getNodeWrapper (n);
|
||||
return engine.getNodeWrapper (n);
|
||||
}
|
||||
|
||||
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 {
|
||||
checkNode ();
|
||||
// eval.app.logEvent ("get property called: "+propertyName);
|
||||
// engine.app.logEvent ("get property called: "+propertyName);
|
||||
ESValue retval = super.getProperty (propertyName, hash);
|
||||
if (! (retval instanceof ESUndefined))
|
||||
return retval;
|
||||
|
@ -374,7 +374,7 @@ public class ESNode extends ObjectPrototype {
|
|||
if ("cache".equalsIgnoreCase (propertyName) && node instanceof Node) {
|
||||
cache = node.getCacheNode ();
|
||||
if (cacheWrapper == null)
|
||||
cacheWrapper = new ESNode (cache, eval);
|
||||
cacheWrapper = new ESNode (cache, engine);
|
||||
else
|
||||
cacheWrapper.node = cache;
|
||||
return cacheWrapper;
|
||||
|
@ -411,7 +411,7 @@ public class ESNode extends ObjectPrototype {
|
|||
if (nd == null)
|
||||
return ESNull.theNull;
|
||||
else
|
||||
return eval.getNodeWrapper (nd);
|
||||
return engine.getNodeWrapper (nd);
|
||||
}
|
||||
if (p.getType () == IProperty.JAVAOBJECT)
|
||||
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
|
||||
INode anon = node.getSubnode (propertyName);
|
||||
if (anon != null)
|
||||
return eval.getNodeWrapper (anon);
|
||||
return engine.getNodeWrapper (anon);
|
||||
|
||||
return ESNull.theNull;
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ public class ESNode extends ObjectPrototype {
|
|||
if (n == null)
|
||||
return ESNull.theNull;
|
||||
else
|
||||
return eval.getNodeWrapper (n);
|
||||
return engine.getNodeWrapper (n);
|
||||
}
|
||||
// some more internal properties
|
||||
if ("__name__".equals (propertyName))
|
||||
|
|
|
@ -31,7 +31,7 @@ public class FesiActionAdapter {
|
|||
Application app;
|
||||
String functionName;
|
||||
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;
|
||||
|
||||
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)
|
||||
pfunc.updateEvaluator (fesi);
|
||||
pfunc.updateEvaluator (engine);
|
||||
if (pfuncAsString != null)
|
||||
pfuncAsString.updateEvaluator (fesi);
|
||||
pfuncAsString.updateEvaluator (engine);
|
||||
}
|
||||
|
||||
protected TypeUpdater parseFunction (String funcName, String params, Reader body, String sourceName) throws EcmaScriptException {
|
||||
|
@ -148,15 +148,15 @@ public class FesiActionAdapter {
|
|||
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);
|
||||
|
||||
FunctionPrototype fp = ConstructedFunctionObject.makeNewConstructedFunction (
|
||||
fesi.evaluator, functionName, fes,
|
||||
engine.evaluator, functionName, fes,
|
||||
fullFunctionText, fpl.getArguments(), vnames, sl);
|
||||
op.putHiddenProperty (functionName, fp);
|
||||
}
|
||||
|
@ -172,12 +172,12 @@ public class FesiActionAdapter {
|
|||
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 func = new ThrowException (functionName, fesi.evaluator, fp, errorMessage);
|
||||
FunctionPrototype fp = (FunctionPrototype) engine.evaluator.getFunctionPrototype ();
|
||||
FunctionPrototype func = new ThrowException (functionName, engine.evaluator, fp, errorMessage);
|
||||
op.putHiddenProperty (functionName, func);
|
||||
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public class FesiActionAdapter {
|
|||
}
|
||||
|
||||
interface TypeUpdater {
|
||||
public void updateEvaluator (FesiEvaluator fesi) throws EcmaScriptException;
|
||||
public void updateEvaluator (FesiEngine engine) throws EcmaScriptException;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,16 +24,16 @@ import FESI.Exceptions.*;
|
|||
/**
|
||||
* 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
|
||||
public final Application app;
|
||||
Application app;
|
||||
|
||||
// The FESI evaluator
|
||||
final Evaluator evaluator;
|
||||
Evaluator evaluator;
|
||||
|
||||
// the global object
|
||||
final GlobalObject global;
|
||||
GlobalObject global;
|
||||
|
||||
// caching table for JavaScript object wrappers
|
||||
CacheMap wrappercache;
|
||||
|
@ -42,10 +42,10 @@ public final class FesiEvaluator implements ScriptingEngine {
|
|||
Hashtable prototypes;
|
||||
|
||||
// the request evaluator instance owning this fesi evaluator
|
||||
final RequestEvaluator reval;
|
||||
RequestEvaluator reval;
|
||||
|
||||
// extensions loaded by this evaluator
|
||||
static String[] extensions = new String[] {
|
||||
static final String[] extensions = new String[] {
|
||||
"FESI.Extensions.BasicIO",
|
||||
"FESI.Extensions.FileIO",
|
||||
"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.reval = reval;
|
||||
wrappercache = new CacheMap (200, .75f);
|
||||
prototypes = new Hashtable ();
|
||||
try {
|
||||
evaluator = new Evaluator();
|
||||
evaluator.reval = this;
|
||||
evaluator.engine = this;
|
||||
global = evaluator.getGlobalObject();
|
||||
for (int i=0; i<extensions.length; i++)
|
||||
evaluator.addExtension (extensions[i]);
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -30,7 +30,7 @@ import org.xml.sax.InputSource;
|
|||
public final class HopExtension {
|
||||
|
||||
protected Application app;
|
||||
protected FesiEvaluator fesi;
|
||||
protected FesiEngine engine;
|
||||
|
||||
public HopExtension (Application app) {
|
||||
this.app = app;
|
||||
|
@ -40,9 +40,9 @@ public final class HopExtension {
|
|||
/**
|
||||
* Called by the evaluator after the extension is loaded.
|
||||
*/
|
||||
public void initializeExtension (FesiEvaluator fesi) throws EcmaScriptException {
|
||||
this.fesi = fesi;
|
||||
Evaluator evaluator = fesi.getEvaluator ();
|
||||
public void initializeExtension (FesiEngine engine) throws EcmaScriptException {
|
||||
this.engine = engine;
|
||||
Evaluator evaluator = engine.getEvaluator ();
|
||||
GlobalObject go = evaluator.getGlobalObject();
|
||||
FunctionPrototype fp = (FunctionPrototype) evaluator.getFunctionPrototype();
|
||||
|
||||
|
@ -68,7 +68,7 @@ public final class HopExtension {
|
|||
// the Session prototype
|
||||
ObjectPrototype esSessionPrototype = new ObjectPrototype (esNodePrototype, evaluator);
|
||||
// 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
|
||||
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.deleteProperty("exit", "exit".hashCode());
|
||||
|
||||
// register object prototypes with FesiEvaluator
|
||||
fesi.putPrototype ("global", go);
|
||||
fesi.putPrototype ("hopobject", esNodePrototype);
|
||||
fesi.putPrototype ("__javaobject__", esObjectPrototype);
|
||||
// fesi.putPrototype ("session", esSessionPrototype);
|
||||
// register object prototypes with FesiEngine
|
||||
engine.putPrototype ("global", go);
|
||||
engine.putPrototype ("hopobject", esNodePrototype);
|
||||
engine.putPrototype ("__javaobject__", esObjectPrototype);
|
||||
// engine.putPrototype ("session", esSessionPrototype);
|
||||
}
|
||||
|
||||
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
|
||||
// (strings for directory names and INodes for internal, db-stored skinsets)
|
||||
ResponseTrans res = fesi.getResponse();
|
||||
ResponseTrans res = engine.getResponse();
|
||||
Object[] skinpath = res.getSkinpath ();
|
||||
|
||||
// ready... retrieve the skin and render it.
|
||||
|
@ -512,7 +512,7 @@ public final class HopExtension {
|
|||
if (asString)
|
||||
res.pushStringBuffer ();
|
||||
if (skin != null)
|
||||
skin.render (fesi.getRequestEvaluator(), javaObject, params);
|
||||
skin.render (engine.getRequestEvaluator(), javaObject, params);
|
||||
else
|
||||
res.write ("[Skin not found: "+arguments[0]+"]");
|
||||
if (asString)
|
||||
|
@ -768,7 +768,7 @@ public final class HopExtension {
|
|||
// first, look in the object href was called on.
|
||||
Object skinElem = elem;
|
||||
Skin skin = null;
|
||||
// ResponseTrans res = fesi.getResponse();
|
||||
// ResponseTrans res = engine.getResponse();
|
||||
// Object[] skinpath = res.getSkinpath ();
|
||||
while (skin == null && skinElem != null) {
|
||||
Prototype proto = app.getPrototype (skinElem);
|
||||
|
@ -792,11 +792,11 @@ public final class HopExtension {
|
|||
return new ESString (basicHref);
|
||||
}
|
||||
private ESString renderSkin (Skin skin, String path, Object skinElem) throws EcmaScriptException {
|
||||
fesi.getResponse().pushStringBuffer ();
|
||||
engine.getResponse().pushStringBuffer ();
|
||||
HashMap param = new HashMap ();
|
||||
param.put ("path", path);
|
||||
skin.render (fesi.getRequestEvaluator(), skinElem, param);
|
||||
return new ESString (fesi.getResponse().popStringBuffer ().trim ());
|
||||
skin.render (engine.getRequestEvaluator(), skinElem, param);
|
||||
return new ESString (engine.getResponse().popStringBuffer ().trim ());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ import FESI.Interpreter.*;
|
|||
|
||||
public class NodeConstructor extends BuiltinFunctionObject {
|
||||
|
||||
FesiEvaluator fesi;
|
||||
FesiEngine engine;
|
||||
String typename;
|
||||
|
||||
public NodeConstructor (String name, FunctionPrototype fp, FesiEvaluator fesi) {
|
||||
super(fp, fesi.getEvaluator (), name, 1);
|
||||
public NodeConstructor (String name, FunctionPrototype fp, FesiEngine engine) {
|
||||
super(fp, engine.getEvaluator (), name, 1);
|
||||
typename = name;
|
||||
this.fesi = fesi;
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
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 {
|
||||
ESNode node = null;
|
||||
Application app = fesi.getApplication ();
|
||||
Application app = engine.getApplication ();
|
||||
if ("Node".equals (typename) || "hopobject".equalsIgnoreCase (typename)) {
|
||||
String nodeName = null;
|
||||
if (arguments.length > 0 && arguments[0] != null)
|
||||
nodeName = arguments[0].toString();
|
||||
Node n = new Node (nodeName, (String) null, app.getWrappedNodeManager ());
|
||||
node = new ESNode (fesi.getPrototype ("hopobject"), this.evaluator, n, fesi);
|
||||
fesi.putNodeWrapper (node.getNode (), node);
|
||||
node = new ESNode (engine.getPrototype ("hopobject"), this.evaluator, n, engine);
|
||||
engine.putNodeWrapper (node.getNode (), node);
|
||||
} else {
|
||||
// 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
|
||||
// is that we want to be able to use the specail features like subnode relations even for
|
||||
// transient nodes.
|
||||
ObjectPrototype op = fesi.getPrototype (typename);
|
||||
ObjectPrototype op = engine.getPrototype (typename);
|
||||
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.getNode ().setDbMapping (app.getDbMapping (typename));
|
||||
try {
|
||||
|
@ -55,9 +55,9 @@ public class NodeConstructor extends BuiltinFunctionObject {
|
|||
// HACK: There is an incompatibility problem here, because the property
|
||||
// constructor is defined as the constructor of the object by EcmaScript.
|
||||
if (op.getProperty ("constructor", "constructor".hashCode()) instanceof ConstructedFunctionObject)
|
||||
node.doIndirectCall (fesi.getEvaluator(), node, "constructor", arguments);
|
||||
node.doIndirectCall (engine.getEvaluator(), node, "constructor", arguments);
|
||||
else
|
||||
node.doIndirectCall (fesi.getEvaluator(), node, typename, arguments);
|
||||
node.doIndirectCall (engine.getEvaluator(), node, typename, arguments);
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
return node;
|
||||
|
@ -69,7 +69,7 @@ public class NodeConstructor extends BuiltinFunctionObject {
|
|||
|
||||
public ESValue getProperty(String propertyName, int hash) throws EcmaScriptException {
|
||||
if ("prototype".equals (propertyName))
|
||||
return fesi.getPrototype (typename);
|
||||
return engine.getPrototype (typename);
|
||||
return super.getProperty(propertyName, hash);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class DomExtension extends Extension {
|
|||
writer.close();
|
||||
File finalFile = new File(arguments[1].toString());
|
||||
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) {
|
||||
throw new EcmaScriptException (io.toString());
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public class DomExtension extends Extension {
|
|||
node = ((ESNode)arguments[1]).getNode();
|
||||
} catch ( Exception e ) { //classcast, arrayindex etc
|
||||
// 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 {
|
||||
XmlReader reader = new XmlReader ();
|
||||
|
@ -141,7 +141,7 @@ public class DomExtension extends Extension {
|
|||
result = reader.read (new StringReader (arguments[0].toString()),node);
|
||||
else
|
||||
result = reader.read (new File(arguments[0].toString()),node);
|
||||
return this.evaluator.reval.getNodeWrapper (result);
|
||||
return this.evaluator.engine.getNodeWrapper (result);
|
||||
} catch ( NoClassDefFoundError e ) {
|
||||
throw new EcmaScriptException ("Can't load XML parser:"+e);
|
||||
} catch ( Exception f ) {
|
||||
|
@ -164,9 +164,9 @@ public class DomExtension extends Extension {
|
|||
} else {
|
||||
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);
|
||||
return this.evaluator.reval.getNodeWrapper(result);
|
||||
return this.evaluator.engine.getNodeWrapper(result);
|
||||
} catch ( NoClassDefFoundError e ) {
|
||||
throw new EcmaScriptException("Can't load dom-capable xml parser.");
|
||||
} catch ( RuntimeException f ) {
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ESMail extends ESObject implements Serializable {
|
|||
Session session = Session.getDefaultInstance(props, null);
|
||||
message = new MimeMessage (session);
|
||||
} catch (Throwable t) {
|
||||
this.evaluator.reval.app.logEvent ("Error in mail constructor: "+t);
|
||||
this.evaluator.engine.getApplication().logEvent ("Error in mail constructor: "+t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ public class MailExtension extends Extension {
|
|||
try {
|
||||
mail.send ();
|
||||
} catch (Exception x) {
|
||||
this.evaluator.reval.app.logEvent ("Error sending mail: "+x);
|
||||
evaluator.engine.getApplication().logEvent ("Error sending mail: "+x);
|
||||
mail.setStatus (ESMail.SEND);
|
||||
return ESBoolean.makeBoolean(false);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ package helma.scripting.fesi.extensions;
|
|||
|
||||
import org.apache.xmlrpc.*;
|
||||
|
||||
import helma.scripting.fesi.FesiEvaluator;
|
||||
import helma.scripting.fesi.FesiEngine;
|
||||
|
||||
import FESI.Interpreter.*;
|
||||
import FESI.Exceptions.*;
|
||||
|
@ -100,14 +100,14 @@ public class XmlRpcExtension extends Extension {
|
|||
|
||||
public ESValue doIndirectCall(Evaluator evaluator, ESObject target, String functionName, ESValue arguments[])
|
||||
throws EcmaScriptException, NoSuchMethodException {
|
||||
// System.out.println ("doIndirectCall called with "+functionName);
|
||||
// System.out.println ("doIndirectCall called with "+remoteObject+"."+functionName);
|
||||
XmlRpcClient client = new XmlRpcClient (url);
|
||||
// long now = System.currentTimeMillis ();
|
||||
Object retval = null;
|
||||
int l = arguments.length;
|
||||
Vector v = new Vector ();
|
||||
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 ());
|
||||
v.addElement (arg);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class XmlRpcExtension extends Extension {
|
|||
String method = remoteObject == null ? functionName : remoteObject+"."+functionName;
|
||||
retval = client.execute (method, v);
|
||||
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) {
|
||||
String msg = x.getMessage();
|
||||
if (msg == null || msg.length() == 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue