With the preview 3 release of Envers, you can easily associate additional data with revisions. This could be, for example, the name of the user making the change. You simply need to annotate an entity with @RevisionEntity
: an instance of this entity will be persisted with each new revision. To provide a way to fill the entity with custom data, you need to implement an interface, and pass it as a parameter to the annotation.buy inflatable aviva water sports
For example, to store the name of the currently logged in user in a JBoss Seam application, the implementation of the listener would look as follows:
public class ExampleListener
implements RevisionListener {
public void newRevision(Object revisionEntity) {
ExampleRevEntity exampleRevEntity =
(ExampleRevEntity) revisionEntity;
Identity identity =
(Identity) Component.getInstance(
"org.jboss.seam.security.identity");
exampleRevEntity.setUsername(
identity.getUsername());
}
}
For more details see here.
There is also a demo Envers+Seam application: a very simple wiki. It allows users to create and edit pages, view their history and see which users made the changes.
And, as always, waiting for your comments on the forums! Thanks to the current forum members for the bug reports and ideas!
Adam
comments powered by Disqus