
Prevayler is an object persistence library for Java. It is an implementation of the System Prevalence architectural style, in which data is kept hot in Memory with changes journaled for system recovery.
Prevayler ' s architecture is illustrated in the diagram shown here. Prevayler [1] serves as a transactional barrier for the business objects [2] of your application, held in Memory. You encapsulate all modifications of your business objects into instances of the Transaction interface [3], much like a " command " pattern (though different from a command in some details of the pattern). Whenever you ask Prevayler to execute a transaction on your business objects [4], Prevayler first writes the transaction object to a journal [5] so that data is not lost if your system crashes. Prevayler can also write a snapshot of your entire business object graph [6] as often as you wish. Prevayler uses the latest snapshot together with the journals to automatically recover your business objects from disk [7] on application startup by restoring the snapshot and then re-executing every transaction that was originally executed after that snapshot was taken.
Well, here are a few of the reasons why we use Prevayler:
1. It ' s extremely simple. There ' s no separate database server to run.
2. It lets us program with real objects. We can choose whatever object models, data structures, and algorithms are appropriate to our particular application domain. Prevayler doesn ' t require our business objects to extend any base class or implement any interface in order to be persistent.
3. It ' s test-friendly. Since we ' re programming with real objects, we can properly encapsulate logic together with the data it uses, making unit tests cleaner, easier to write, and faster to run. The restrictions that Prevayler does impose on us - - keeping our code deterministic, for example - - are consistent with the disciplines that test-driven development teaches us anyway.
4. It makes threadsafety easy. Prevayler makes transactions run sequentially, so we don ' t have to worry about typical multithreading issues like locking and consistency (unless we really want to get tricky, and Prevayler lets us do that, too).
5. It ' s extremely fast. Everything runs in Memory, so the only disk access is streaming transactions to the journal, which we ' ve optimized to a peak rate of up to a thousand transactions per second on desktop hardware. And read-only queries don ' t even have that overhead, so they run instantaneously, hundreds of thousands per second.
Prevayler is extremely simple, and imposes very few restrictions on your object model. The only restrictions are to make sure that transaction execution is deterministic and repeatable, so that the exact state of your business objects can be recovered from the transaction journal.
1. All modifications to your business objects must be encapsulated in transaction objects.
2. All your transactions must be completely deterministic. For example, don ' t call System.currentTimeMillis () from within a transaction (or within any business object code called indirectly by a transaction), because it will give a different answer every time the transaction is run. (If you do want to know the time, Prevayler provides an " official " timestamp, assigned when the transaction is first written to the journal. See the Transaction interface.)
Note that any hardware input or output is inherently nondeterministic, and therefore violates this rule. Do all I / O outside of Prevayler transactions.
3. All your transactions and business objects must be serializable, so that they can be written to the journal and snapshot. (You can also configure your own serialization mechanisms if you don ' t want to use Java serialization.)
4. Transactions can ' t carry direct object references (pointers) to business objects. This has become known as the baptism problem because it ' s a common beginner pitfall. Direct object references don ' t work because once a transaction has been serialized to the journal and then deserialized for execution its object references no longer refer to the intended objects - - any objects they may have referred to at first will have been copied by the serialization process! Therefore, a transaction must carry some kind of string or numeric identifiers for any objects it wants to refer to, and it must look up the objects when it is executed.
Download Prevayler 2.3, containing code, documentation and demos.
You can also join the Prevayler mailing lists.
If you have any questions or problems using Prevayler, please post on the prevayler-discussion mailing list, not the comments section here - - you'll get a much quicker response.
See: Links, Prevalent Hypothesis, Baptism Problem, Memory Technology, Prevayler Examples
[[This new wiki is still under construction. An earlier draft of this front page is here.]]
http://www.polepos.org / may be interesting for advertise Prevayler.
Kind Regards
Richard Gomes
See the links section for tutorials:
http://prevayler.org/wiki/Links
Luckily for Klaus, he is using quotation marks, and not apostrophes.
I ' m so glad that Prevayler is still active. I used version 1 on a project. Working with it was the best part of the job. I can ' t wait to wrap my head around 2.3, thank you.
Hoi, I ' m trying to use Prevayler.
But your wiki and codehause.org have a lot of broken links.
I looked at a example i found but the use of CRUD methods is very inefficient. One command for each CRUD-method. (http://www-128.ibm.com/developerworks/web/library/wa-objprev/index.html)
Adn when i signed up on this page, I even couldn ' t see the frontpage.
Do you have some good piece of documentation for me
How does one clean up old journal files after snapshots. What policy do users normally use?
Thanks
Rakesh
- - Rakesh
I'm curious too.. how do you clean up old journal files?
[Open email to Klaus (since my email to klauswuestefeld at yahoo.com bounced)]
Thank you for Prevayler!
We are using an object persistence library for Java similar to Prevayler.
Basically, we took the main ideas from Prevayler / System Prevalence, but
made some changes.
The reason we did not use Prevayler as it is, is that we must have
real-time replication of the database and could not afford to have
double data in memory or afford to wait without running transactions
while the whole data object is being copied.
The system we created is called LinoDB. The advantage is that it
can do real-time replication to a remote location without the double-memory
or the wait-to-copy-whole-data-object. The concept is based on
what I call State Streams. The disadvantage with LinoDB compared to
Prevayler is that the data model that must be followed is a bit more
complicated than that of Prevayler.
LinoDB has been used for a while in a Swedish payment system
called Betala.se. I you are interested, I would be happy to send you
more information. Just thought I would share my ideas, they may be of
interest to you.
Sincerely, Frans Lundberg
Frans Lundberg, CEO SkyCash
email: frans.lundberg at skycash.com, mobile: + 48 791496163
- - Frans Lundberg
Is linoDB available as open source?
- - Neil Murphy
I discovered prevayler two years after I started JOAFIP developement!
This is because I did not found on web with keyword " java object persistence in file "....
Joafip project seems near to prevayler, but one big difference is that is not need to maintains all objects in memory, this make able to manage so huge collections that can be fully stored in memory.
Link below explains how it is reached
http://joafip.sourceforge.net/howitworks/howitworks.html
- - luc peuvrier
Neil, LinoDB has not been published as open source yet, but I would be willing to do so if you feel like trying it out.
- - Frans Lundberg
I'm completely new to Prevayler, JOAFIP and the like and I'm wondering if this is a technology that one would completely replace their RDBMS with? What happens if the system goes down and the app needs to be restarted? How long does it take to get back up and running? Does it depend on the number of transactions that have happened since the last backup?
- - Tom
wow this looks bloody awesome!! I went in # java on irc.freebode.net and they scoffed at me saying this won't work. I don't see why not. Good job!! Now if only I knew java... Any opinions on best way to learn java?
- - g
Do you think that it is possible to implement JPA provider on top of Prevayler?
Don't know if it is possible for Prevalyer to execute JPQL queries? Or at least some kind of them.
Is it possible to have indexes by fields of class for example?
The idea is to use the Prevayler technology with a minimal need to enhance ones knowledge - just using the JPA abstraction on top.
- - bodrin
Copyright © 2007 Prevayler | All Rights Reserved
Powered by Priki and design G. Wolfgang