Permalink
Browse files

Merge pull request #6 from Navigateur/master

Removed the Serializable requirement from createPrevayler methods, and added to their Javadoc
  • Loading branch information...
2 parents 20bb7db + 87fc6ac commit abc3eaf9177b86b72f334a482bd9e60767d1f907 @klauswuestefeld klauswuestefeld committed Nov 29, 2011
@@ -8,7 +8,7 @@
import java.util.Date;
/** Represents a query that can be executed on a Prevalent System.
- * @param <P> The type or a supertype of the Prevalent System you intend to perform the query upon. <br>
+ * @param <P> The type or any supertype of the Prevalent System you intend to perform the query upon. <br>
* @param <R> The type of object which should be returned. <br>
* @see Prevayler#execute(Query)
*/
@@ -7,7 +7,7 @@
import java.util.Date;
/** The same as TransactionWithQuery except it does not throw Exception when executed.
- * @param <P> The type or a supertype of the Prevalent System you intend to perform the transaction and query upon. <br>
+ * @param <P> The type or any supertype of the Prevalent System you intend to perform the transaction and query upon. <br>
* @param <R> The type of object which should be returned. <br>
* @see TransactionWithQuery
*/
@@ -9,11 +9,11 @@
/** An atomic transaction to be executed on a Prevalent System.
* <br>
- * <br>To be recoverable, <b>any changes to the observable state of a Prevalent System must be encapsulated in Transactions and performed via the given</b> <code>prevalentSystem</code> <b>in each Transaction</b>.
+ * <br>To be recoverable, any changes to the observable state of a Prevalent System must be encapsulated in Transactions and performed via the given <code>prevalentSystem</code> in each Transaction.
* <br>
* <br>Upon recovery execution, anything outside <code>prevalentSystem</code> will be a freshly deserialized copy, so cannot reference anything in the Prevalent System.
* <br>
- * @param <P> The type or a supertype of the Prevalent System you intend to perform the transaction on. <br>
+ * @param <P> The type or any supertype of the Prevalent System you intend to perform the transaction upon. <br>
*/
public interface Transaction<P> extends Serializable{
@@ -8,7 +8,7 @@
import java.util.Date;
/** A Transaction that also returns a result or throws an Exception after executing. <br><br>A "PersonCreation" Transaction, for example, may return the Person it created. Without this, to retrieve the newly created Person, the caller would have to issue a Query like: "What was the last Person I created?". <br><br>Looking at the Prevayler demos is by far the best way to learn how to use this class.
- * @param <P> The type or a supertype of the Prevalent System you intend to perform the transaction and query upon. <br>
+ * @param <P> The type or any supertype of the Prevalent System you intend to perform the transaction and query upon. <br>
* @param <R> The type of object which should be returned. <br>
* @see Transaction
*/
@@ -6,7 +6,6 @@
package org.prevayler;
import java.io.IOException;
-import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -74,7 +73,7 @@
*/
public PrevaylerFactory(){}
- /** Creates a Prevayler that will use the given prevalenceBase directory to read and write its .snapshot and .journal files.
+ /** Creates a Prevayler that will use the given prevalenceBase directory to read and write its .snapshot and .journal files, using standard Java serialization. This requires that the Prevalent System and all Transaction implementations used by the Prevayler are Java-Serializable.
* <br>
* <br><i>Example:</i>
* <br><code>
@@ -86,27 +85,27 @@ public PrevaylerFactory(){}
* @param newPrevalentSystem The newly started, "empty" prevalent system that will be used as a starting point for every system startup, until the first snapshot is taken.
* @param prevalenceBase The directory where the .snapshot files and .journal files will be read and written.
*/
- public static <P extends Serializable> Prevayler<P> createPrevayler(P newPrevalentSystem, String prevalenceBase) throws Exception {
+ public static <P> Prevayler<P> createPrevayler(P newPrevalentSystem, String prevalenceBase) throws Exception {
PrevaylerFactory<P> factory = new PrevaylerFactory<P>();
factory.configurePrevalentSystem(newPrevalentSystem);
factory.configurePrevalenceDirectory(prevalenceBase);
return factory.create();
}
- /** Creates a Prevayler that will use a directory called "PrevalenceBase" under the current directory to read and write its .snapshot and .journal files.
+ /** Creates a Prevayler that will use a directory called "PrevalenceBase" under the current directory to read and write its .snapshot and .journal files, using standard Java serialization. This requires that the Prevalent System and all Transaction implementations used by the Prevayler are Java-Serializable.
* @param newPrevalentSystem The newly started, "empty" prevalent system that will be used as a starting point for every system startup, until the first snapshot is taken.
- * @see #createPrevayler(Serializable, String)
+ * @see #createPrevayler(Object, String)
*/
- public static <P extends Serializable> Prevayler<P> createPrevayler(P newPrevalentSystem) throws Exception {
+ public static <P> Prevayler<P> createPrevayler(P newPrevalentSystem) throws Exception {
return createPrevayler(newPrevalentSystem, "PrevalenceBase");
}
- /** Creates a Prevayler that will execute Transactions WITHOUT writing them to disk. Snapshots will work as "checkpoints" for the system, therefore. This is useful for stand-alone applications that have a "Save" button, for example.
+ /** Creates a Prevayler that will execute Transactions WITHOUT writing them to disk. Snapshots will work as "checkpoints" for the system, therefore. This is useful for stand-alone applications that have a "Save" button, for example. The Prevayler will use standard Java serialization for reading and writing its .snapshot files, which requires that the Prevalent System is Java-Serializable.
* @param newPrevalentSystem The newly started, "empty" prevalent system that will be used as a starting point for every system startup, until the first snapshot is taken.
* @param snapshotDirectory The directory where the .snapshot files will be read and written.
- * @see #createPrevayler(Serializable, String)
+ * @see #createPrevayler(Object, String)
*/
- public static <P extends Serializable> Prevayler<P> createCheckpointPrevayler(P newPrevalentSystem, String snapshotDirectory) {
+ public static <P> Prevayler<P> createCheckpointPrevayler(P newPrevalentSystem, String snapshotDirectory) {
PrevaylerFactory<P> factory = new PrevaylerFactory<P>();
factory.configurePrevalentSystem(newPrevalentSystem);
factory.configurePrevalenceDirectory(snapshotDirectory);
@@ -123,7 +122,7 @@ public PrevaylerFactory(){}
*
* Attempts to take snapshots on this transient Prevayler will throw an IOException.
* @param newPrevalentSystem The newly started, "empty" prevalent system.
- * @see #createCheckpointPrevayler(Serializable, String)
+ * @see #createCheckpointPrevayler(Object, String)
*/
public static <P> Prevayler<P> createTransientPrevayler(P newPrevalentSystem) {
PrevaylerFactory<P> factory = new PrevaylerFactory<P>();
@@ -141,7 +140,7 @@ public PrevaylerFactory(){}
/** @deprecated Use createCheckpointPrevayler() instead of this method. Deprecated since Prevayler2.00.001.
*/
- public static <P extends Serializable> Prevayler<P> createTransientPrevayler(P newPrevalentSystem, String snapshotDirectory) {
+ public static <P> Prevayler<P> createTransientPrevayler(P newPrevalentSystem, String snapshotDirectory) {
return createCheckpointPrevayler(newPrevalentSystem, snapshotDirectory);
}

0 comments on commit abc3eaf

Please sign in to comment.