A while ago I tried to run Google’s V8 Javascript engine on top of XPages, and today I found the reason why my server crashed after the first click: I have tried to load the engine only once (statically), and that killed Domino completly.
Today I moved the code back into the processAction method, and now it works without problems.
package ch.hasselba.xpages.jav8;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
public class JAV8Test implements javax.faces.event.ActionListener {
public void processAction(ActionEvent actionEvent)
throws AbortProcessingException {
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("jav8");
try {
System.out.println(engine.getClass().getCanonicalName());
engine.eval("var i=1+1;");
System.out.println("i = " + engine.get("i"));
} catch (ScriptException ex) {
ex.printStackTrace();
}
}
}
What’s the performance like??
Some simple tests gave a performance boost of factor 175.