Moved Evaluator init code from typemanager to prototype.
Fixed evaluator not being initialized by new prototypes
This commit is contained in:
parent
7376855af9
commit
4552af0cda
3 changed files with 35 additions and 39 deletions
|
@ -7,6 +7,7 @@ import java.util.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import helma.framework.*;
|
import helma.framework.*;
|
||||||
import helma.objectmodel.*;
|
import helma.objectmodel.*;
|
||||||
|
import FESI.Data.*;
|
||||||
import FESI.Exceptions.EcmaScriptException;
|
import FESI.Exceptions.EcmaScriptException;
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,6 +122,30 @@ public class Prototype {
|
||||||
|
|
||||||
|
|
||||||
public void initRequestEvaluator (RequestEvaluator reval) {
|
public void initRequestEvaluator (RequestEvaluator reval) {
|
||||||
|
ObjectPrototype op = null;
|
||||||
|
if ("user".equalsIgnoreCase (name))
|
||||||
|
op = reval.esUserPrototype;
|
||||||
|
else if ("global".equalsIgnoreCase (name))
|
||||||
|
op = reval.global;
|
||||||
|
else if ("hopobject".equalsIgnoreCase (name))
|
||||||
|
op = reval.esNodePrototype;
|
||||||
|
else {
|
||||||
|
op = new ObjectPrototype (reval.esNodePrototype, reval.evaluator);
|
||||||
|
try {
|
||||||
|
op.putProperty ("prototypename", new ESString (name), "prototypename".hashCode ());
|
||||||
|
} catch (EcmaScriptException ignore) {}
|
||||||
|
}
|
||||||
|
reval.putPrototype (name, op);
|
||||||
|
|
||||||
|
// Register a constructor for all types except global.
|
||||||
|
// This will first create a node and then call the actual (scripted) constructor on it.
|
||||||
|
if (!"global".equalsIgnoreCase (name)) {
|
||||||
|
try {
|
||||||
|
FunctionPrototype fp = (FunctionPrototype) reval.evaluator.getFunctionPrototype();
|
||||||
|
reval.global.putHiddenProperty (name, new NodeConstructor (name, fp, reval));
|
||||||
|
} catch (EcmaScriptException ignore) {}
|
||||||
|
}
|
||||||
|
|
||||||
for (Enumeration en = functions.elements(); en.hasMoreElements(); ) {
|
for (Enumeration en = functions.elements(); en.hasMoreElements(); ) {
|
||||||
FunctionFile ff = (FunctionFile) en.nextElement ();
|
FunctionFile ff = (FunctionFile) en.nextElement ();
|
||||||
ff.updateRequestEvaluator (reval);
|
ff.updateRequestEvaluator (reval);
|
||||||
|
|
|
@ -195,16 +195,11 @@ public class TypeManager implements Runnable {
|
||||||
proto.functions = nfunc;
|
proto.functions = nfunc;
|
||||||
proto.actions = nact;
|
proto.actions = nact;
|
||||||
|
|
||||||
// register constructor for evaluators that are already initialized.
|
// init prototype on evaluators that are already initialized.
|
||||||
if (!"global".equalsIgnoreCase (name)) {
|
Iterator evals = getRegisteredRequestEvaluators ();
|
||||||
Iterator evals = getRegisteredRequestEvaluators ();
|
while (evals.hasNext ()) {
|
||||||
while (evals.hasNext ()) {
|
RequestEvaluator reval = (RequestEvaluator) evals.next ();
|
||||||
try {
|
proto.initRequestEvaluator (reval);
|
||||||
RequestEvaluator reval = (RequestEvaluator) evals.next ();
|
|
||||||
FunctionPrototype fp = (FunctionPrototype) reval.evaluator.getFunctionPrototype();
|
|
||||||
reval.global.putHiddenProperty (name, new NodeConstructor (name, fp, reval));
|
|
||||||
} catch (Exception ignore) {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -294,31 +289,6 @@ public class TypeManager implements Runnable {
|
||||||
registeredEvaluators.add (reval);
|
registeredEvaluators.add (reval);
|
||||||
for (Enumeration en = prototypes.elements(); en.hasMoreElements(); ) {
|
for (Enumeration en = prototypes.elements(); en.hasMoreElements(); ) {
|
||||||
Prototype p = (Prototype) en.nextElement ();
|
Prototype p = (Prototype) en.nextElement ();
|
||||||
String name = p.getName ();
|
|
||||||
ObjectPrototype op = null;
|
|
||||||
if ("user".equalsIgnoreCase (name))
|
|
||||||
op = reval.esUserPrototype;
|
|
||||||
else if ("global".equalsIgnoreCase (name))
|
|
||||||
op = reval.global;
|
|
||||||
else if ("hopobject".equalsIgnoreCase (name))
|
|
||||||
op = reval.esNodePrototype;
|
|
||||||
else {
|
|
||||||
op = new ObjectPrototype (reval.esNodePrototype, reval.evaluator);
|
|
||||||
try {
|
|
||||||
op.putProperty ("prototypename", new ESString (name), "prototypename".hashCode ());
|
|
||||||
} catch (EcmaScriptException ignore) {}
|
|
||||||
}
|
|
||||||
reval.putPrototype (name, op);
|
|
||||||
|
|
||||||
// Register a constructor for all types except global.
|
|
||||||
// This will first create a node and then call the actual (scripted) constructor on it.
|
|
||||||
if (!"global".equalsIgnoreCase (name)) {
|
|
||||||
try {
|
|
||||||
FunctionPrototype fp = (FunctionPrototype) reval.evaluator.getFunctionPrototype();
|
|
||||||
reval.global.putHiddenProperty (name, new NodeConstructor (name, fp, reval));
|
|
||||||
} catch (EcmaScriptException ignore) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
p.initRequestEvaluator (reval);
|
p.initRequestEvaluator (reval);
|
||||||
}
|
}
|
||||||
reval.initialized = true;
|
reval.initialized = true;
|
||||||
|
|
|
@ -19,14 +19,17 @@ public class XmlRpcClient implements XmlRpcHandler {
|
||||||
|
|
||||||
URL url;
|
URL url;
|
||||||
String auth;
|
String auth;
|
||||||
int maxThreads = 50;
|
int maxThreads = 100;
|
||||||
|
|
||||||
|
// pool of worker instances
|
||||||
Stack pool = new Stack ();
|
Stack pool = new Stack ();
|
||||||
int workers = 0;
|
int workers = 0;
|
||||||
|
|
||||||
long calls = 0;
|
// average roundtrip of this method call. This is used to decide if
|
||||||
|
// additional threads are needed or not in async mode
|
||||||
int roundtrip = 1000;
|
int roundtrip = 1000;
|
||||||
|
|
||||||
|
// a queue of calls to be handled asynchronously
|
||||||
CallData first, last;
|
CallData first, last;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +87,6 @@ public class XmlRpcClient implements XmlRpcHandler {
|
||||||
try {
|
try {
|
||||||
Object retval = worker.execute (method, params);
|
Object retval = worker.execute (method, params);
|
||||||
long end = System.currentTimeMillis ();
|
long end = System.currentTimeMillis ();
|
||||||
calls++;
|
|
||||||
roundtrip = (int) ((roundtrip*4)+(end-start))/5;
|
roundtrip = (int) ((roundtrip*4)+(end-start))/5;
|
||||||
return retval;
|
return retval;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -204,7 +206,6 @@ public class XmlRpcClient implements XmlRpcHandler {
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.handleError (x, url, method);
|
callback.handleError (x, url, method);
|
||||||
}
|
}
|
||||||
calls++;
|
|
||||||
long end = System.currentTimeMillis ();
|
long end = System.currentTimeMillis ();
|
||||||
roundtrip = (int) ((roundtrip*4)+(end-start))/5;
|
roundtrip = (int) ((roundtrip*4)+(end-start))/5;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue