use of com.ramussoft.common.cached.CachedEngine in project ramus by Vitaliy-Yakovchuk.
the class ClientServiceImpl method replaceElements.
@Override
public byte[] replaceElements(Element[] oldElements, Element newElement) {
Journal journal;
Engine engine = server.getEngine();
if (engine instanceof JournaledEngine) {
journal = ((JournaledEngine) engine).getJournal();
} else {
journal = ((JournaledEngine) ((CachedEngine) engine).getSource()).getJournal();
}
synchronized (server) {
try {
journal.startUserTransaction();
server.getEngine().replaceElements(oldElements, newElement);
journal.commitUserTransaction();
byte[] remove = server.getCalls().remove(Thread.currentThread());
journal.undoUserTransaction();
return remove;
} catch (Exception e) {
server.getCalls().remove(Thread.currentThread());
journal.rollbackUserTransaction();
throw new RuntimeException(e);
}
}
}
use of com.ramussoft.common.cached.CachedEngine in project ramus by Vitaliy-Yakovchuk.
the class StartCommand method main.
/**
* @param args
*/
public static void main(String[] args) {
try {
System.setProperty("catalina.base", args[0]);
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
Properties ps = EngineFactory.getPropeties();
String command = args[1];
String fileName = (String) ps.get(command);
EngineFactory engineFactory = new EngineFactory();
engineFactory.createJournaledEngine(new DirectoryJournalFactory(null));
final Engine engine1 = (Engine) SuperEngineFactory.createTransactionalEngine(engineFactory.journaledEngine, ((JournaledEngine) ((CachedEngine) engineFactory.journaledEngine).getSource()).getJournal());
engine.getContext().setAttribute("engine", engine1, ScriptContext.ENGINE_SCOPE);
engine.eval(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));
System.exit(0);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (ScriptException e) {
e.printStackTrace();
}
System.exit(1);
}
Aggregations