Grouped all logging activity around Application, and made Application less
dependent on helma.objectmodel.db.Server.
This commit is contained in:
parent
15cdc42eab
commit
9e05814d90
10 changed files with 118 additions and 75 deletions
|
@ -61,7 +61,7 @@ public class Action {
|
||||||
String content = new String (cbuf);
|
String content = new String (cbuf);
|
||||||
update (content);
|
update (content);
|
||||||
} catch (Exception filex) {
|
} catch (Exception filex) {
|
||||||
IServer.getLogger().log ("*** Error reading action file "+file+": "+filex);
|
app.logEvent ("*** Error reading action file "+file+": "+filex);
|
||||||
}
|
}
|
||||||
lastmod = fmod;
|
lastmod = fmod;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class Action {
|
||||||
|
|
||||||
|
|
||||||
public void update (String content) throws Exception {
|
public void update (String content) throws Exception {
|
||||||
// IServer.getLogger().log ("Reading text template " + name);
|
// app.logEvent ("Reading text template " + name);
|
||||||
|
|
||||||
functionName = name+"_hop_action";
|
functionName = name+"_hop_action";
|
||||||
|
|
||||||
|
@ -145,10 +145,10 @@ public class Action {
|
||||||
sl = (ASTStatementList) parser.StatementList();
|
sl = (ASTStatementList) parser.StatementList();
|
||||||
is.close();
|
is.close();
|
||||||
} catch (ParseException x) {
|
} catch (ParseException x) {
|
||||||
IServer.getLogger().log ("Error parsing file "+app.getName()+":"+prototype.getName()+"/"+file.getName()+": "+x);
|
app.logEvent ("Error parsing file "+app.getName()+":"+prototype.getName()+"/"+file.getName()+": "+x);
|
||||||
throw new EcmaScriptParseException (x, new StringEvaluationSource(fulltext, null));
|
throw new EcmaScriptParseException (x, new StringEvaluationSource(fulltext, null));
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
IServer.getLogger().log ("Error parsing file "+app.getName()+":"+prototype.getName()+"/"+file.getName()+": "+x);
|
app.logEvent ("Error parsing file "+app.getName()+":"+prototype.getName()+"/"+file.getName()+": "+x);
|
||||||
throw new RuntimeException (x.getMessage ());
|
throw new RuntimeException (x.getMessage ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import helma.objectmodel.*;
|
||||||
import helma.objectmodel.db.NodeManager;
|
import helma.objectmodel.db.NodeManager;
|
||||||
import helma.objectmodel.db.WrappedNodeManager;
|
import helma.objectmodel.db.WrappedNodeManager;
|
||||||
import helma.xmlrpc.*;
|
import helma.xmlrpc.*;
|
||||||
import helma.util.CacheMap;
|
import helma.util.*;
|
||||||
import FESI.Data.*;
|
import FESI.Data.*;
|
||||||
import FESI.Interpreter.*;
|
import FESI.Interpreter.*;
|
||||||
import com.sleepycat.db.DbException;
|
import com.sleepycat.db.DbException;
|
||||||
|
@ -28,7 +28,7 @@ import com.sleepycat.db.DbException;
|
||||||
public class Application extends UnicastRemoteObject implements IRemoteApp, Runnable {
|
public class Application extends UnicastRemoteObject implements IRemoteApp, Runnable {
|
||||||
|
|
||||||
SystemProperties props;
|
SystemProperties props;
|
||||||
File appDir, dbDir;
|
File home, appDir, dbDir;
|
||||||
private String name;
|
private String name;
|
||||||
protected NodeManager nmgr;
|
protected NodeManager nmgr;
|
||||||
protected static WebServer xmlrpc;
|
protected static WebServer xmlrpc;
|
||||||
|
@ -56,6 +56,9 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
|
|
||||||
// Map of requesttrans -> active requestevaluators
|
// Map of requesttrans -> active requestevaluators
|
||||||
Hashtable activeRequests;
|
Hashtable activeRequests;
|
||||||
|
|
||||||
|
// Two logs for each application: events and accesses
|
||||||
|
Logger eventLog, accessLog;
|
||||||
|
|
||||||
protected String templateExtension, scriptExtension, actionExtension, skinExtension;
|
protected String templateExtension, scriptExtension, actionExtension, skinExtension;
|
||||||
|
|
||||||
|
@ -74,21 +77,27 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
super ();
|
super ();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Application (String name, File dbHome, File appHome) throws RemoteException, DbException {
|
public Application (String name, SystemProperties sysProps, File home) throws RemoteException, DbException, IllegalArgumentException {
|
||||||
|
|
||||||
|
if (name == null || name.trim().length() == 0)
|
||||||
|
throw new IllegalArgumentException ("Invalid application name: "+name);
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.home = home;
|
||||||
|
|
||||||
threadgroup = new ThreadGroup ("TX-"+name);
|
threadgroup = new ThreadGroup ("TX-"+name);
|
||||||
|
|
||||||
appDir = new File (appHome, name);
|
appDir = new File (home, "apps");
|
||||||
|
appDir = new File (appDir, name);
|
||||||
if (!appDir.exists())
|
if (!appDir.exists())
|
||||||
appDir.mkdirs ();
|
appDir.mkdirs ();
|
||||||
dbDir = new File (dbHome, name);
|
dbDir = new File (home, "db");
|
||||||
|
dbDir = new File (dbDir, name);
|
||||||
if (!dbDir.exists())
|
if (!dbDir.exists())
|
||||||
dbDir.mkdirs ();
|
dbDir.mkdirs ();
|
||||||
|
|
||||||
File propfile = new File (appDir, "app.properties");
|
File propfile = new File (appDir, "app.properties");
|
||||||
props = new SystemProperties (propfile.getAbsolutePath (), IServer.sysProps);
|
props = new SystemProperties (propfile.getAbsolutePath (), sysProps);
|
||||||
|
|
||||||
nmgr = new NodeManager (this, dbDir.getAbsolutePath (), props);
|
nmgr = new NodeManager (this, dbDir.getAbsolutePath (), props);
|
||||||
|
|
||||||
|
@ -114,7 +123,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
public void start () {
|
public void start () {
|
||||||
|
|
||||||
eval = new RequestEvaluator (this);
|
eval = new RequestEvaluator (this);
|
||||||
IServer.getLogger().log ("Starting evaluators for "+name);
|
logEvent ("Starting evaluators for "+name);
|
||||||
int maxThreads = 12;
|
int maxThreads = 12;
|
||||||
try {
|
try {
|
||||||
maxThreads = Integer.parseInt (props.getProperty ("maxThreads"));
|
maxThreads = Integer.parseInt (props.getProperty ("maxThreads"));
|
||||||
|
@ -131,7 +140,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
|
|
||||||
typemgr = new TypeManager (this);
|
typemgr = new TypeManager (this);
|
||||||
typemgr.check ();
|
typemgr.check ();
|
||||||
IServer.getLogger().log ("Started type manager for "+name);
|
logEvent ("Started type manager for "+name);
|
||||||
|
|
||||||
rootMapping = getDbMapping ("root");
|
rootMapping = getDbMapping ("root");
|
||||||
userMapping = getDbMapping ("user");
|
userMapping = getDbMapping ("user");
|
||||||
|
@ -146,7 +155,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
worker = new Thread (this, "Worker-"+name);
|
worker = new Thread (this, "Worker-"+name);
|
||||||
worker.setPriority (Thread.NORM_PRIORITY+2);
|
worker.setPriority (Thread.NORM_PRIORITY+2);
|
||||||
worker.start ();
|
worker.start ();
|
||||||
IServer.getLogger().log ("session cleanup and scheduler thread started");
|
logEvent ("session cleanup and scheduler thread started");
|
||||||
|
|
||||||
xmlrpc.addHandler (this.name, new XmlRpcInvoker (this));
|
xmlrpc.addHandler (this.name, new XmlRpcInvoker (this));
|
||||||
|
|
||||||
|
@ -364,7 +373,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
users.setNode (uname, unode);
|
users.setNode (uname, unode);
|
||||||
return users.getNode (uname, false);
|
return users.getNode (uname, false);
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
IServer.getLogger().log ("Error registering User: "+x);
|
logEvent ("Error registering User: "+x);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -438,11 +447,42 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
this.baseURI = uri;
|
this.baseURI = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void logEvent (String msg) {
|
||||||
|
if (eventLog == null)
|
||||||
|
eventLog = getLogger (name+"_event");
|
||||||
|
eventLog.log (msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logAccess (String msg) {
|
||||||
|
if (accessLog == null)
|
||||||
|
accessLog = getLogger (name+"_access");
|
||||||
|
accessLog.log (msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Logger getLogger (String logname) {
|
||||||
|
Logger log = null;
|
||||||
|
String logDir = props.getProperty ("logdir");
|
||||||
|
if (logDir == null)
|
||||||
|
logDir = "log";
|
||||||
|
try {
|
||||||
|
File helper = new File (logDir);
|
||||||
|
if (home != null && !helper.isAbsolute ())
|
||||||
|
helper = new File (home, logDir);
|
||||||
|
logDir = helper.getAbsolutePath ();
|
||||||
|
log = new Logger (logDir, logname);
|
||||||
|
} catch (IOException iox) {
|
||||||
|
System.err.println ("Could not create log "+logname+" for application "+name+": "+iox);
|
||||||
|
// fallback to System.out
|
||||||
|
log = new Logger (System.out);
|
||||||
|
}
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
|
||||||
public void run () {
|
public void run () {
|
||||||
long cleanupSleep = 60000; // thread sleep interval (fixed)
|
long cleanupSleep = 60000; // thread sleep interval (fixed)
|
||||||
long scheduleSleep = 60000; // interval for scheduler invocation
|
long scheduleSleep = 60000; // interval for scheduler invocation
|
||||||
long lastScheduler = 0;
|
long lastScheduler = 0;
|
||||||
IServer.getLogger().log ("Starting scheduler for "+name);
|
logEvent ("Starting scheduler for "+name);
|
||||||
// as first thing, invoke function onStart in the root object
|
// as first thing, invoke function onStart in the root object
|
||||||
try {
|
try {
|
||||||
eval.invokeFunction ((INode) null, "onStart", new ESValue[0]);
|
eval.invokeFunction ((INode) null, "onStart", new ESValue[0]);
|
||||||
|
@ -458,12 +498,12 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
try {
|
try {
|
||||||
worker.sleep (cleanupSleep);
|
worker.sleep (cleanupSleep);
|
||||||
} catch (InterruptedException x) {
|
} catch (InterruptedException x) {
|
||||||
IServer.getLogger().log ("Scheduler for "+name+" interrupted");
|
logEvent ("Scheduler for "+name+" interrupted");
|
||||||
worker = null;
|
worker = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
IServer.getLogger().log ("Cleaning up "+name+": " + sessions.size () + " sessions active");
|
logEvent ("Cleaning up "+name+": " + sessions.size () + " sessions active");
|
||||||
long now = System.currentTimeMillis ();
|
long now = System.currentTimeMillis ();
|
||||||
Hashtable cloned = (Hashtable) sessions.clone ();
|
Hashtable cloned = (Hashtable) sessions.clone ();
|
||||||
for (Enumeration e = cloned.elements (); e.hasMoreElements (); ) {
|
for (Enumeration e = cloned.elements (); e.hasMoreElements (); ) {
|
||||||
|
@ -482,9 +522,9 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IServer.getLogger().log ("Cleaned up "+name+": " + sessions.size () + " sessions remaining");
|
logEvent ("Cleaned up "+name+": " + sessions.size () + " sessions remaining");
|
||||||
} catch (Exception cx) {
|
} catch (Exception cx) {
|
||||||
IServer.getLogger().log ("Error cleaning up sessions: "+cx);
|
logEvent ("Error cleaning up sessions: "+cx);
|
||||||
cx.printStackTrace ();
|
cx.printStackTrace ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,10 +542,10 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
else
|
else
|
||||||
scheduleSleep = ret;
|
scheduleSleep = ret;
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignore) {}
|
||||||
IServer.getLogger().log ("Called scheduler for "+name+", will sleep for "+scheduleSleep+" millis");
|
logEvent ("Called scheduler for "+name+", will sleep for "+scheduleSleep+" millis");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
IServer.getLogger().log ("Scheduler for "+name+" exiting");
|
logEvent ("Scheduler for "+name+" exiting");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rewireDbMappings () {
|
public void rewireDbMappings () {
|
||||||
|
@ -514,7 +554,7 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
DbMapping m = (DbMapping) e.nextElement ();
|
DbMapping m = (DbMapping) e.nextElement ();
|
||||||
m.rewire ();
|
m.rewire ();
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
IServer.getLogger().log ("Error rewiring DbMappings: "+x);
|
logEvent ("Error rewiring DbMappings: "+x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -535,12 +575,12 @@ public class Application extends UnicastRemoteObject implements IRemoteApp, Runn
|
||||||
* Periodically called to log thread stats for this application
|
* Periodically called to log thread stats for this application
|
||||||
*/
|
*/
|
||||||
public void printThreadStats () {
|
public void printThreadStats () {
|
||||||
IServer.getLogger().log ("Thread Stats for "+name+": "+threadgroup.activeCount()+" active");
|
logEvent ("Thread Stats for "+name+": "+threadgroup.activeCount()+" active");
|
||||||
Runtime rt = Runtime.getRuntime ();
|
Runtime rt = Runtime.getRuntime ();
|
||||||
long free = rt.freeMemory ();
|
long free = rt.freeMemory ();
|
||||||
long total = rt.totalMemory ();
|
long total = rt.totalMemory ();
|
||||||
IServer.getLogger().log ("Free memory: "+(free/1024)+" kB");
|
logEvent ("Free memory: "+(free/1024)+" kB");
|
||||||
IServer.getLogger().log ("Total memory: "+(total/1024)+" kB");
|
logEvent ("Total memory: "+(total/1024)+" kB");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class ESNode extends ObjectPrototype {
|
||||||
|
|
||||||
public ESNode (ESObject prototype, Evaluator evaluator, Object obj, RequestEvaluator eval) {
|
public ESNode (ESObject prototype, Evaluator evaluator, Object obj, RequestEvaluator eval) {
|
||||||
super (prototype, evaluator);
|
super (prototype, evaluator);
|
||||||
// IServer.getLogger().log ("in ESNode constructor: "+o.getClass ());
|
// eval.app.logEvent ("in ESNode constructor: "+o.getClass ());
|
||||||
this.eval = eval;
|
this.eval = eval;
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
node = new Node ();
|
node = new Node ();
|
||||||
|
@ -135,7 +135,7 @@ public class ESNode extends ObjectPrototype {
|
||||||
node.setContent (p.getContent (), p.getContentType ());
|
node.setContent (p.getContent (), p.getContentType ());
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
IServer.getLogger().log ("error in ESNode.setContent: "+x);
|
eval.app.logEvent ("error in ESNode.setContent: "+x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public class ESNode extends ObjectPrototype {
|
||||||
node.setContent (i.getContent (), i.getContentType ());
|
node.setContent (i.getContent (), i.getContentType ());
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
IServer.getLogger().log ("error in ESNode.setContent: "+x);
|
eval.app.logEvent ("error in ESNode.setContent: "+x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,12 +215,12 @@ public class ESNode extends ObjectPrototype {
|
||||||
* when they go from transient to persistent state.
|
* when they go from transient to persistent state.
|
||||||
*/
|
*/
|
||||||
protected void rewrap (INode newnode) {
|
protected void rewrap (INode newnode) {
|
||||||
// IServer.getLogger().log ("rewrapping "+this+" from "+node+" to "+newnode);
|
// eval.app.logEvent ("rewrapping "+this+" from "+node+" to "+newnode);
|
||||||
if (newnode == null)
|
if (newnode == null)
|
||||||
throw new RuntimeException ("Non-consistent check-in detected in rewrap ()");
|
throw new RuntimeException ("Non-consistent check-in detected in rewrap ()");
|
||||||
INode oldnode = node;
|
INode oldnode = node;
|
||||||
if (oldnode == newnode) {
|
if (oldnode == newnode) {
|
||||||
// IServer.getLogger().log ("loop detected or new peers unchanged in rewrap");
|
// eval.app.logEvent ("loop detected or new peers unchanged in rewrap");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// set node and nodeID to new node
|
// set node and nodeID to new node
|
||||||
|
@ -232,7 +232,7 @@ public class ESNode extends ObjectPrototype {
|
||||||
for (int i=0; i<l; i++) {
|
for (int i=0; i<l; i++) {
|
||||||
INode next = oldnode.getSubnodeAt (i);
|
INode next = oldnode.getSubnodeAt (i);
|
||||||
ESNode esn = eval.getNodeWrapperFromCache (next);
|
ESNode esn = eval.getNodeWrapperFromCache (next);
|
||||||
// IServer.getLogger().log ("rewrapping node: "+next+" -> "+esn);
|
// eval.app.logEvent ("rewrapping node: "+next+" -> "+esn);
|
||||||
if (esn != null) {
|
if (esn != null) {
|
||||||
esn.rewrap (newnode.getSubnodeAt (i));
|
esn.rewrap (newnode.getSubnodeAt (i));
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,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 ();
|
||||||
// IServer.getLogger().log ("put property called: "+propertyName+", "+propertyValue.getClass());
|
// eval.app.logEvent ("put property called: "+propertyName+", "+propertyValue.getClass());
|
||||||
if ("lastmodified".equalsIgnoreCase (propertyName) || "created".equalsIgnoreCase (propertyName) ||
|
if ("lastmodified".equalsIgnoreCase (propertyName) || "created".equalsIgnoreCase (propertyName) ||
|
||||||
"contentlength".equalsIgnoreCase (propertyName) || "cache".equalsIgnoreCase (propertyName))
|
"contentlength".equalsIgnoreCase (propertyName) || "cache".equalsIgnoreCase (propertyName))
|
||||||
throw new EcmaScriptException ("Can't modify read-only property \""+propertyName+"\".");
|
throw new EcmaScriptException ("Can't modify read-only property \""+propertyName+"\".");
|
||||||
|
@ -347,9 +347,9 @@ public class ESNode extends ObjectPrototype {
|
||||||
INode newnode = node.getNode (propertyName, false);
|
INode newnode = node.getNode (propertyName, false);
|
||||||
esn.rewrap (newnode);
|
esn.rewrap (newnode);
|
||||||
}
|
}
|
||||||
// IServer.getLogger().log ("*** spent "+(System.currentTimeMillis () - now)+" ms to set property "+propertyName);
|
// eval.app.logEvent ("*** spent "+(System.currentTimeMillis () - now)+" ms to set property "+propertyName);
|
||||||
} else {
|
} else {
|
||||||
// IServer.getLogger().log ("got "+propertyValue.getClass ());
|
// eval.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 ());
|
||||||
|
@ -358,7 +358,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 ();
|
||||||
// IServer.getLogger().log ("delete property called: "+propertyName);
|
// eval.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;
|
||||||
|
@ -386,7 +386,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 ();
|
||||||
// IServer.getLogger().log ("get property called: "+propertyName);
|
// eval.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;
|
||||||
|
|
|
@ -64,9 +64,9 @@ public class FunctionFile {
|
||||||
ObjectPrototype op = reval.getPrototype (prototype.getName());
|
ObjectPrototype op = reval.getPrototype (prototype.getName());
|
||||||
reval.evaluator.evaluate(fr, op, es, false);
|
reval.evaluator.evaluate(fr, op, es, false);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
IServer.getLogger().log ("Error parsing function file "+app.getName()+":"+prototype.getName()+"/"+file.getName()+": "+e);
|
app.logEvent ("Error parsing function file "+app.getName()+":"+prototype.getName()+"/"+file.getName()+": "+e);
|
||||||
} catch (EcmaScriptException e) {
|
} catch (EcmaScriptException e) {
|
||||||
IServer.getLogger().log ("Error parsing function file "+app.getName()+":"+prototype.getName()+"/"+file.getName()+": "+e);
|
app.logEvent ("Error parsing function file "+app.getName()+":"+prototype.getName()+"/"+file.getName()+": "+e);
|
||||||
} finally {
|
} finally {
|
||||||
if (fr!=null) {
|
if (fr!=null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -567,7 +567,7 @@ public class HopExtension {
|
||||||
String str = arguments[0].toString ();
|
String str = arguments[0].toString ();
|
||||||
Skin skin = (Skin) app.skincache.get (str);
|
Skin skin = (Skin) app.skincache.get (str);
|
||||||
if (skin == null) {
|
if (skin == null) {
|
||||||
skin = new Skin (str);
|
skin = new Skin (str, app);
|
||||||
app.skincache.put (str, skin);
|
app.skincache.put (str, skin);
|
||||||
}
|
}
|
||||||
return new ESWrapper (skin, evaluator);
|
return new ESWrapper (skin, evaluator);
|
||||||
|
@ -584,7 +584,7 @@ public class HopExtension {
|
||||||
public ESValue callFunction (ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
|
public ESValue callFunction (ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
|
||||||
if (arguments.length != 1 || ESNull.theNull.equals (arguments[0]))
|
if (arguments.length != 1 || ESNull.theNull.equals (arguments[0]))
|
||||||
throw new EcmaScriptException ("createSkin must be called with one String argument!");
|
throw new EcmaScriptException ("createSkin must be called with one String argument!");
|
||||||
return new ESWrapper (new Skin (arguments[0].toString()), evaluator);
|
return new ESWrapper (new Skin (arguments[0].toString(), app), evaluator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,7 +782,7 @@ public class HopExtension {
|
||||||
return new ESString (age.toString ());
|
return new ESString (age.toString ());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
IServer.getLogger().log ("Error formatting date: "+e);
|
app.logEvent ("Error formatting date: "+e);
|
||||||
e.printStackTrace ();
|
e.printStackTrace ();
|
||||||
return new ESString ("");
|
return new ESString ("");
|
||||||
}
|
}
|
||||||
|
@ -889,7 +889,7 @@ public class HopExtension {
|
||||||
parser.parse (new InputSource ((Reader) p));
|
parser.parse (new InputSource ((Reader) p));
|
||||||
return ESLoader.normalizeObject (parser.getDocument(), evaluator);
|
return ESLoader.normalizeObject (parser.getDocument(), evaluator);
|
||||||
} catch (Exception noluck) {
|
} catch (Exception noluck) {
|
||||||
IServer.getLogger().log ("Error creating XML document: "+noluck);
|
app.logEvent ("Error creating XML document: "+noluck);
|
||||||
}
|
}
|
||||||
return ESNull.theNull;
|
return ESNull.theNull;
|
||||||
}
|
}
|
||||||
|
@ -918,7 +918,7 @@ public class HopExtension {
|
||||||
parser.parse (new InputSource ((Reader) p));
|
parser.parse (new InputSource ((Reader) p));
|
||||||
return ESLoader.normalizeObject (parser.getDocument(), evaluator);
|
return ESLoader.normalizeObject (parser.getDocument(), evaluator);
|
||||||
} catch (Exception noluck) {
|
} catch (Exception noluck) {
|
||||||
IServer.getLogger().log ("Error creating HTML document: "+noluck);
|
app.logEvent ("Error creating HTML document: "+noluck);
|
||||||
}
|
}
|
||||||
return ESNull.theNull;
|
return ESNull.theNull;
|
||||||
}
|
}
|
||||||
|
@ -936,7 +936,7 @@ public class HopExtension {
|
||||||
org.jdom.input.DOMBuilder builder = new org.jdom.input.DOMBuilder ();
|
org.jdom.input.DOMBuilder builder = new org.jdom.input.DOMBuilder ();
|
||||||
return ESLoader.normalizeObject (builder.build (doc), evaluator);
|
return ESLoader.normalizeObject (builder.build (doc), evaluator);
|
||||||
} catch (Exception noluck) {
|
} catch (Exception noluck) {
|
||||||
IServer.getLogger().log ("Error wrapping JDOM document: "+noluck);
|
app.logEvent ("Error wrapping JDOM document: "+noluck);
|
||||||
}
|
}
|
||||||
return ESNull.theNull;
|
return ESNull.theNull;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class Prototype {
|
||||||
|
|
||||||
public Prototype (File codeDir, Application app) {
|
public Prototype (File codeDir, Application app) {
|
||||||
|
|
||||||
IServer.getLogger().log ("Constructing Prototype "+app.getName()+"/"+codeDir.getName ());
|
app.logEvent ("Constructing Prototype "+app.getName()+"/"+codeDir.getName ());
|
||||||
|
|
||||||
this.codeDir = codeDir;
|
this.codeDir = codeDir;
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
@ -117,7 +117,7 @@ public class Prototype {
|
||||||
app.typemgr.updatePrototype (this.name, codeDir, this);
|
app.typemgr.updatePrototype (this.name, codeDir, this);
|
||||||
// TypeManager.broadcaster.broadcast ("Finished update for prototype "+name+" @ "+new Date ()+"<br><hr>");
|
// TypeManager.broadcaster.broadcast ("Finished update for prototype "+name+" @ "+new Date ()+"<br><hr>");
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
IServer.getLogger().log ("Error building function protos in prototype: "+x);
|
app.logEvent ("Error building function protos in prototype: "+x);
|
||||||
// TypeManager.broadcaster.broadcast ("Error updating prototype "+name+" in application "+app.getName()+":<br>"+x.getMessage ()+"<br><hr>");
|
// TypeManager.broadcaster.broadcast ("Error updating prototype "+name+" in application "+app.getName()+":<br>"+x.getMessage ()+"<br><hr>");
|
||||||
}
|
}
|
||||||
retval = true;
|
retval = true;
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class RequestEvaluator implements Runnable {
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
|
|
||||||
// IServer.getLogger().log ("got request "+reqtype);
|
// app.logEvent ("got request "+reqtype);
|
||||||
|
|
||||||
switch (reqtype) {
|
switch (reqtype) {
|
||||||
case HTTP:
|
case HTTP:
|
||||||
|
@ -339,7 +339,7 @@ public class RequestEvaluator implements Runnable {
|
||||||
|
|
||||||
abortTransaction (false);
|
abortTransaction (false);
|
||||||
|
|
||||||
IServer.getLogger().log ("### Exception in "+app.getName()+"/"+req.path+": "+x);
|
app.logEvent ("### Exception in "+app.getName()+"/"+req.path+": "+x);
|
||||||
// Dump the profiling data to System.err
|
// Dump the profiling data to System.err
|
||||||
if (app.debug) {
|
if (app.debug) {
|
||||||
((Transactor) Thread.currentThread ()).timer.dump (System.err);
|
((Transactor) Thread.currentThread ()).timer.dump (System.err);
|
||||||
|
@ -465,7 +465,7 @@ public class RequestEvaluator implements Runnable {
|
||||||
String msg = wrong.getMessage ();
|
String msg = wrong.getMessage ();
|
||||||
if (msg == null || msg.length () == 0)
|
if (msg == null || msg.length () == 0)
|
||||||
msg = wrong.toString ();
|
msg = wrong.toString ();
|
||||||
IServer.getLogger().log ("Error executing "+funcdesc+": "+msg);
|
app.logEvent ("Error executing "+funcdesc+": "+msg);
|
||||||
this.exception = new Exception (msg);
|
this.exception = new Exception (msg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -538,7 +538,7 @@ public class RequestEvaluator implements Runnable {
|
||||||
checkThread ();
|
checkThread ();
|
||||||
wait (app.requestTimeout);
|
wait (app.requestTimeout);
|
||||||
if (reqtype != NONE) {
|
if (reqtype != NONE) {
|
||||||
IServer.getLogger().log ("Stopping Thread for Request "+app.getName()+"/"+req.path);
|
app.logEvent ("Stopping Thread for Request "+app.getName()+"/"+req.path);
|
||||||
stopThread ();
|
stopThread ();
|
||||||
res.reset ();
|
res.reset ();
|
||||||
res.write ("<b>Error in application '"+app.getName()+"':</b> <br><br><pre>Request timed out.</pre>");
|
res.write ("<b>Error in application '"+app.getName()+"':</b> <br><br><pre>Request timed out.</pre>");
|
||||||
|
@ -641,7 +641,7 @@ public class RequestEvaluator implements Runnable {
|
||||||
* notify.
|
* notify.
|
||||||
*/
|
*/
|
||||||
public synchronized void stopThread () {
|
public synchronized void stopThread () {
|
||||||
IServer.getLogger().log ("Stopping Thread "+rtx);
|
app.logEvent ("Stopping Thread "+rtx);
|
||||||
Transactor t = rtx;
|
Transactor t = rtx;
|
||||||
evaluator.thread = null;
|
evaluator.thread = null;
|
||||||
rtx = null;
|
rtx = null;
|
||||||
|
@ -665,7 +665,7 @@ public class RequestEvaluator implements Runnable {
|
||||||
throw new ApplicationStoppedException ();
|
throw new ApplicationStoppedException ();
|
||||||
|
|
||||||
if (rtx == null || !rtx.isAlive()) {
|
if (rtx == null || !rtx.isAlive()) {
|
||||||
// IServer.getLogger().log ("Starting Thread");
|
// app.logEvent ("Starting Thread");
|
||||||
rtx = new Transactor (this, app.threadgroup, app.nmgr);
|
rtx = new Transactor (this, app.threadgroup, app.nmgr);
|
||||||
evaluator.thread = rtx;
|
evaluator.thread = rtx;
|
||||||
rtx.start ();
|
rtx.start ();
|
||||||
|
@ -737,7 +737,7 @@ public class RequestEvaluator implements Runnable {
|
||||||
esn = new ESNode (op, evaluator, n, this);
|
esn = new ESNode (op, evaluator, n, this);
|
||||||
|
|
||||||
objectcache.put (n, esn);
|
objectcache.put (n, esn);
|
||||||
// IServer.getLogger().log ("Wrapper for "+n+" created");
|
// app.logEvent ("Wrapper for "+n+" created");
|
||||||
}
|
}
|
||||||
|
|
||||||
return esn;
|
return esn;
|
||||||
|
|
|
@ -20,8 +20,10 @@ import helma.objectmodel.IServer;
|
||||||
public class Skin {
|
public class Skin {
|
||||||
|
|
||||||
Object[] parts;
|
Object[] parts;
|
||||||
|
Application app;
|
||||||
|
|
||||||
public Skin (String content) {
|
public Skin (String content, Application app) {
|
||||||
|
this.app = app;
|
||||||
parse (content);
|
parse (content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,12 +234,12 @@ public class Skin {
|
||||||
} else {
|
} else {
|
||||||
String msg = "[HopMacro unhandled: "+handler+"."+name+"]";
|
String msg = "[HopMacro unhandled: "+handler+"."+name+"]";
|
||||||
reval.res.write (" "+msg+" ");
|
reval.res.write (" "+msg+" ");
|
||||||
IServer.getLogger().log (msg);
|
app.logEvent (msg);
|
||||||
}
|
}
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
String msg = "[HopMacro error: "+x+"]";
|
String msg = "[HopMacro error: "+x+"]";
|
||||||
reval.res.write (" "+msg+" ");
|
reval.res.write (" "+msg+" ");
|
||||||
IServer.getLogger().log (msg);
|
app.logEvent (msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,9 +49,9 @@ public class SkinFile {
|
||||||
char c[] = new char[(int) file.length()];
|
char c[] = new char[(int) file.length()];
|
||||||
reader.read (c);
|
reader.read (c);
|
||||||
reader.close();
|
reader.close();
|
||||||
skin = new Skin (new String (c));
|
skin = new Skin (new String (c), app);
|
||||||
} catch (IOException x) {
|
} catch (IOException x) {
|
||||||
IServer.getLogger().log ("Error reading Skin "+file+": "+x);
|
app.logEvent ("Error reading Skin "+file+": "+x);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastmod = file.lastModified ();
|
lastmod = file.lastModified ();
|
||||||
|
|
|
@ -5,8 +5,6 @@ package helma.framework.core;
|
||||||
|
|
||||||
import helma.objectmodel.*;
|
import helma.objectmodel.*;
|
||||||
import helma.util.*;
|
import helma.util.*;
|
||||||
import FESI.Exceptions.*;
|
|
||||||
import FESI.Data.*;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
|
@ -50,6 +48,9 @@ public class TypeManager implements Runnable {
|
||||||
if (!f.exists())
|
if (!f.exists())
|
||||||
f.mkdir ();
|
f.mkdir ();
|
||||||
f = new File (appDir, "global");
|
f = new File (appDir, "global");
|
||||||
|
if (!f.exists())
|
||||||
|
f.mkdir ();
|
||||||
|
f = new File (appDir, "hopobject");
|
||||||
if (!f.exists())
|
if (!f.exists())
|
||||||
f.mkdir ();
|
f.mkdir ();
|
||||||
prototypes = new Hashtable ();
|
prototypes = new Hashtable ();
|
||||||
|
@ -70,7 +71,7 @@ public class TypeManager implements Runnable {
|
||||||
Prototype proto = getPrototype (list[i]);
|
Prototype proto = getPrototype (list[i]);
|
||||||
if (proto != null) {
|
if (proto != null) {
|
||||||
// check if existing prototype needs update
|
// check if existing prototype needs update
|
||||||
// IServer.getLogger().log (protoDir.lastModified ());
|
// app.logEvent (protoDir.lastModified ());
|
||||||
updatePrototype (list[i], protoDir, proto);
|
updatePrototype (list[i], protoDir, proto);
|
||||||
} else {
|
} else {
|
||||||
// create new prototype
|
// create new prototype
|
||||||
|
@ -86,7 +87,7 @@ public class TypeManager implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
IServer.getLogger().log (this+": "+ignore);
|
app.logEvent (this+": "+ignore);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rewire) {
|
if (rewire) {
|
||||||
|
@ -94,7 +95,7 @@ public class TypeManager implements Runnable {
|
||||||
app.rewireDbMappings ();
|
app.rewireDbMappings ();
|
||||||
rewire = false;
|
rewire = false;
|
||||||
}
|
}
|
||||||
// IServer.getLogger().log (" ...done @ "+ (System.currentTimeMillis () - now)+ "--- "+idleSeconds);
|
// app.logEvent (" ...done @ "+ (System.currentTimeMillis () - now)+ "--- "+idleSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,7 +140,7 @@ public class TypeManager implements Runnable {
|
||||||
long sleeptime = 1500 + Math.min (idleSeconds*30, 3500);
|
long sleeptime = 1500 + Math.min (idleSeconds*30, 3500);
|
||||||
typechecker.sleep (sleeptime);
|
typechecker.sleep (sleeptime);
|
||||||
} catch (InterruptedException x) {
|
} catch (InterruptedException x) {
|
||||||
// IServer.getLogger().log ("Typechecker interrupted");
|
// app.logEvent ("Typechecker interrupted");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
check ();
|
check ();
|
||||||
|
@ -148,7 +149,7 @@ public class TypeManager implements Runnable {
|
||||||
|
|
||||||
|
|
||||||
public void registerPrototype (String name, File dir, Prototype proto) {
|
public void registerPrototype (String name, File dir, Prototype proto) {
|
||||||
// IServer.getLogger().log ("registering prototype "+name);
|
// app.logEvent ("registering prototype "+name);
|
||||||
|
|
||||||
// show the type checker thread that there has been type activity
|
// show the type checker thread that there has been type activity
|
||||||
idleSeconds = 0;
|
idleSeconds = 0;
|
||||||
|
@ -173,7 +174,7 @@ public class TypeManager implements Runnable {
|
||||||
Template t = new Template (tmpfile, tmpname, proto);
|
Template t = new Template (tmpfile, tmpname, proto);
|
||||||
ntemp.put (tmpname, t);
|
ntemp.put (tmpname, t);
|
||||||
} catch (Throwable x) {
|
} catch (Throwable x) {
|
||||||
IServer.getLogger().log ("Error creating prototype: "+x);
|
app.logEvent ("Error creating prototype: "+x);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (list[i].endsWith (app.scriptExtension) && tmpfile.length () > 0) {
|
} else if (list[i].endsWith (app.scriptExtension) && tmpfile.length () > 0) {
|
||||||
|
@ -181,7 +182,7 @@ public class TypeManager implements Runnable {
|
||||||
FunctionFile ff = new FunctionFile (tmpfile, tmpname, proto);
|
FunctionFile ff = new FunctionFile (tmpfile, tmpname, proto);
|
||||||
nfunc.put (tmpname, ff);
|
nfunc.put (tmpname, ff);
|
||||||
} catch (Throwable x) {
|
} catch (Throwable x) {
|
||||||
IServer.getLogger().log ("Error creating prototype: "+x);
|
app.logEvent ("Error creating prototype: "+x);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (list[i].endsWith (app.actionExtension) && tmpfile.length () > 0) {
|
} else if (list[i].endsWith (app.actionExtension) && tmpfile.length () > 0) {
|
||||||
|
@ -189,14 +190,14 @@ public class TypeManager implements Runnable {
|
||||||
Action af = new Action (tmpfile, tmpname, proto);
|
Action af = new Action (tmpfile, tmpname, proto);
|
||||||
nact.put (tmpname, af);
|
nact.put (tmpname, af);
|
||||||
} catch (Throwable x) {
|
} catch (Throwable x) {
|
||||||
IServer.getLogger().log ("Error creating prototype: "+x);
|
app.logEvent ("Error creating prototype: "+x);
|
||||||
}
|
}
|
||||||
} else if (list[i].endsWith (app.skinExtension)) {
|
} else if (list[i].endsWith (app.skinExtension)) {
|
||||||
try {
|
try {
|
||||||
SkinFile sf = new SkinFile (tmpfile, tmpname, proto);
|
SkinFile sf = new SkinFile (tmpfile, tmpname, proto);
|
||||||
nskins.put (tmpname, sf);
|
nskins.put (tmpname, sf);
|
||||||
} catch (Throwable x) {
|
} catch (Throwable x) {
|
||||||
IServer.getLogger().log ("Error creating prototype: "+x);
|
app.logEvent ("Error creating prototype: "+x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +217,7 @@ public class TypeManager implements Runnable {
|
||||||
|
|
||||||
|
|
||||||
public void updatePrototype (String name, File dir, Prototype proto) {
|
public void updatePrototype (String name, File dir, Prototype proto) {
|
||||||
// IServer.getLogger().log ("updating prototype "+name);
|
// app.logEvent ("updating prototype "+name);
|
||||||
|
|
||||||
String list[] = dir.list();
|
String list[] = dir.list();
|
||||||
Hashtable ntemp = new Hashtable ();
|
Hashtable ntemp = new Hashtable ();
|
||||||
|
@ -243,7 +244,7 @@ public class TypeManager implements Runnable {
|
||||||
idleSeconds = 0;
|
idleSeconds = 0;
|
||||||
}
|
}
|
||||||
} catch (Throwable x) {
|
} catch (Throwable x) {
|
||||||
IServer.getLogger().log ("Error updating prototype: "+x);
|
app.logEvent ("Error updating prototype: "+x);
|
||||||
}
|
}
|
||||||
ntemp.put (tmpname, t);
|
ntemp.put (tmpname, t);
|
||||||
|
|
||||||
|
@ -258,7 +259,7 @@ public class TypeManager implements Runnable {
|
||||||
idleSeconds = 0;
|
idleSeconds = 0;
|
||||||
}
|
}
|
||||||
} catch (Throwable x) {
|
} catch (Throwable x) {
|
||||||
IServer.getLogger().log ("Error updating prototype: "+x);
|
app.logEvent ("Error updating prototype: "+x);
|
||||||
}
|
}
|
||||||
nfunc.put (tmpname, ff);
|
nfunc.put (tmpname, ff);
|
||||||
|
|
||||||
|
@ -273,7 +274,7 @@ public class TypeManager implements Runnable {
|
||||||
idleSeconds = 0;
|
idleSeconds = 0;
|
||||||
}
|
}
|
||||||
} catch (Throwable x) {
|
} catch (Throwable x) {
|
||||||
IServer.getLogger().log ("Error updating prototype: "+x);
|
app.logEvent ("Error updating prototype: "+x);
|
||||||
}
|
}
|
||||||
nact.put (tmpname, af);
|
nact.put (tmpname, af);
|
||||||
|
|
||||||
|
@ -288,7 +289,7 @@ public class TypeManager implements Runnable {
|
||||||
idleSeconds = 0;
|
idleSeconds = 0;
|
||||||
}
|
}
|
||||||
} catch (Throwable x) {
|
} catch (Throwable x) {
|
||||||
IServer.getLogger().log ("Error updating prototype: "+x);
|
app.logEvent ("Error updating prototype: "+x);
|
||||||
}
|
}
|
||||||
nskins.put (tmpname, sf);
|
nskins.put (tmpname, sf);
|
||||||
|
|
||||||
|
@ -299,7 +300,7 @@ public class TypeManager implements Runnable {
|
||||||
rewire = true;
|
rewire = true;
|
||||||
}
|
}
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
IServer.getLogger().log ("Error updating db mapping for type "+name+": "+ignore);
|
app.logEvent ("Error updating db mapping for type "+name+": "+ignore);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue