Redstone Prevalent Storage is a minimalistic prevalence layer for Java SE 5.0 that
may replace JDBC and RDBMS for small or mid-sized applications. It is comprised
of an intentionally small set of concise interfaces and classes for immediate use or
Credit goes go to Klaus Wuestefeld and the Prevayler team from which this
library is heavily influenced
For those new to the concept, prevalent systems are normally characterized by
the following properties:
- The domain model is represented by an object graph that is fully stored in memory
when the application is running.
- All modifications to the model are made exclusively by transaction objects written
in Java. All transactions are executed in isolation from other transactions and queries (see
below). Transaction objects are stored permanently (in files on disk, most likely)
in transaction logs to support recovery.
- All non-mutating access to the model is made in query objects that may run
in parallel with other query objects.
- At regular intervals (or at select points like before application shutdown) the model is permanently
stored in a snapshot (again, likely in a file on disk depending on the implementation used).
When the application starts again, the snapshot is loaded and all transactions in the log that were made
after the snapshot was made are executed again on the model to recover it to its
When is it useful?
Using a prevalence layer instead of a relational database and an O/R mapping
facility or JDBC, can be advantageous in a couple of scenarios;
- There is no need for O/R mapping, everything is done in Java within the JVM,
directly on the domain model. This can make some applications faster to develop
especially if the developer knows little of databases.
- Access to the model is done in Java code against a regular object graph that is
entirely stored in memory. This makes accessing the model extremely fast which
not only can lead to good performance but may also help developers to use
coarser forms of thread synchronization which will help keep the complexity of
the source code to a minimum, and result in simpler design in general.
- Several other benefits that tend to be a matter of taste according to various
discussions for and against
Object Prevalence (Google)
The library is comprised of a series of interfaces that are accompanied by default
implementations. The fundamental interfaces are;
- represents some modification to a domain model.
- represents some query against the domain model.
- represents a persistent log (or journal) of transactions made to the model.
- represents a complete and persistent snapshot of the domain model.
- represents the complete storage that can execute transactions and queries.
The following classes implements the interfaces above and represent the default
implementation. Each of the classes may be replaced or extended by an application.
- uses a Serializer to store transactions using some kind of serialization mechanism.
- also uses a Serializer to store the snapshot using some kind of serialization.
- an interface representing some form of serialization, used by SnapshotImpl and LogImpl
- default serializer using Java serialization.
- default implementation using any Log and Snapshot to fulfil its responsibilities.
The CVS repository does not contain any examples yet. A complete application using the
prevalence layer is expected to be added in a separate CVS module within a near future.
For reference, the Redstone Prevalence Layer is very similar to
which also contains a few examples. Although not compatible with this
library, the idea should get through.
More to come
The source code and the pre-built JAR is kindly hosted by SourceForge