git-afsantos/undo4j — pull request #13 by git-afsantos (2014-01-22 13:51:20+00:00)
Title: New implementation

As mentioned a few months ago, I had an idea for a new approach on the implementation. I think it is *stable* enough, now, to share it.

It takes a completely new approach on resources, which were one of the major limitations in the previous implementation. But with this new *programmer freedom* come some responsabilities as well. However, I think the benefits outweigh the drawbacks.

The idea is that **a resource can be whatever you want, as long as you provide `ReadOperation`s and `WriteOperation`s for the manager to work on them**. For instance, a list can have an `AddOperation`, a `SetOperation` and a `RemoveOperation` (which are all `WriteOperation`, they modify the list), and a `GetOperation` (which is a `ReadOperation`).

The general procedure is the same. Define transactions (`ClientRunnable`/`ClientCallable`), create a (`Concurrent`)`TransactionManager`, `register` resources on the manager, `execute` and `submit` transactions, and finally `shutdown` the manager.

The major difference, is that **it is now the responsability of the programmer to provide `undo` methods for every `WriteOperation` he defines**.
Also, **every operation has to declare the resources it uses, with the `resources` method**. This is how locks are acquired (and, later on, how statistics will be registered, and **deadlocks detected** - not implemented yet).