diff src/org/prevayler/implementation/NullPrevayler.java @ 0:3dc0c5604566

Initial checkin of blitz 2.0 fcs - no installer yet.
author Dan Creswell <dan.creswell@gmail.com>
date Sat, 21 Mar 2009 11:00:06 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/prevayler/implementation/NullPrevayler.java	Sat Mar 21 11:00:06 2009 +0000
@@ -0,0 +1,48 @@
+package org.prevayler.implementation;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.prevayler.Command;
+import org.prevayler.PrevalentSystem;
+
+/**
+   Prevayler which logs nothing but dispatches all commands.
+ */
+public class NullPrevayler implements SnapshotPrevayler {
+
+    private PrevalentSystem theSystem;
+
+    private Snapshotter theNullSnapshotter = new NullSnapshotter();
+
+    public NullPrevayler(PrevalentSystem aSystem) {
+        theSystem = aSystem;
+        theSystem.clock(new SystemClock());
+    }
+
+    public PrevalentSystem system() {
+        return theSystem;
+    }
+
+    public Serializable executeCommand(Command command) throws Exception {
+        return command.execute(theSystem);
+    }
+
+    public Serializable executeCommand(Command command, boolean sync)
+        throws Exception {
+        return command.execute(theSystem);
+    }
+
+    public synchronized Snapshotter takeSnapshot() throws IOException {
+        return theNullSnapshotter;
+    }
+
+    private static class NullSnapshotter implements Snapshotter {
+        NullSnapshotter() {
+        }
+
+        public void save() throws IOException {
+            // Do nothing
+        }
+    }
+}