X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fxt%2FPrevalence.java;fp=src%2Forg%2Fibex%2Fxt%2FPrevalence.java;h=0000000000000000000000000000000000000000;hb=539b657bcea9488a467bccd6d43ede5e869cede2;hp=b237619514ba0fd9bed80f8d50e3e618faf16575;hpb=ceef03aad63c852ca44925dad0d417db07fd166e;p=org.ibex.xt-crawshaw.git diff --git a/src/org/ibex/xt/Prevalence.java b/src/org/ibex/xt/Prevalence.java deleted file mode 100644 index b237619..0000000 --- a/src/org/ibex/xt/Prevalence.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.ibex.xt; -import org.ibex.js.*; -import org.ibex.util.*; -import org.ibex.io.*; -import java.io.*; -import java.net.*; -import java.util.*; -import javax.servlet.*; -import javax.servlet.http.*; -import com.thoughtworks.xstream.*; -import org.prevayler.*; -import org.prevayler.implementation.snapshot.*; - -public class Prevalence { - - static final Hashtable prevaylers = new Hashtable(); - - public static void destroy(ServletContext cx, Prevayler prevayler) { try { - prevaylers.remove(cx); - prevayler.takeSnapshot(); - prevayler.close(); - } catch (Exception e) { e.printStackTrace(); } } - - private static class SnapshotThread extends Thread { - ServletContext cx; - public SnapshotThread(ServletContext cx) { this.cx = cx; } - public void run() { - try { - Thread.sleep(10000); - Prevayler privatePrevayler = (Prevayler)prevaylers.get(cx); - if (privatePrevayler == null) return; - privatePrevayler.takeSnapshot(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - public static Prevayler getPrevayler(ServletContext cx) { - try { - Prevayler prevayler; - synchronized(cx) { - prevayler = (Prevayler)prevaylers.get(cx); - if (prevayler == null) { - PrevaylerFactory pf = new PrevaylerFactory(); - String base = cx.getRealPath("/") + "WEB-INF" + File.separatorChar + "prevalent"; - System.err.println("prevayling to " + base); - pf.configurePrevalenceBase(base); - XStreamSnapshotManager manager = new XStreamSnapshotManager(new JS(), base, null) { - protected XStream createXStream() { - XStream xstream = new XStream(); - xstream.alias("js", JS.class); - xstream.alias("jsdate", JSDate.class); - return xstream; - } - }; - System.err.println("configuring with " + manager); - pf.configureSnapshotManager(manager); - //pf.configureSnapshotManager(new SnapshotManager(new JS(), base)); - //pf.configureClassLoader(JSTransaction.class.getClassLoader()); - prevayler = pf.create(); - prevaylers.put(cx, prevayler); - new SnapshotThread(cx).start(); - } - } - return prevayler; - } catch (Exception e) { throw new RuntimeException(e); } } - - public static class JSTransaction implements Transaction { - public static final long serialVersionUid = 0xfb2aa281; - private JS js; - JSScope newscope; - Vec v; - public JSTransaction(JS js) throws JSExn { - newscope = new JSScope(null); - this.js = JS.cloneWithNewParentScope(js, newscope); - v = JS.getFormalArgs(this.js); - for(int i=0; i