No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


The OMF contribs is a collection of add-on libraries to the excellent Object Manager written by ilikeorangutans.


  • DAO. A Generic DAO implementation. The generic DAO implementation also includes:
  • HTTP. A simple implementation of the Open-Session-In-View pattern for Object Manager DAO
  • jcr2pojo. A simple command-line application which can read a JCR and produce appropriate DAO and POJO objects from it to be used with OM DAO.
  • jcrcache. A simple wrapper around an arbitrary PersistenceDelegate which caches values. It is intended to be used in the situation that the JCR is being accessed over RMI, which is very slow.


The generic DAO includes:


OMF is licensed under the Apache 2.0 license

How to use the DAO

Define your POJO

    public class MyPojo {
    	private String id;
    	private double rate;
    	private int count;
    	public int getCount() {
    		return count;
    	public String getId() {
    		return id;
    	public double getRate() {
    		return rate;
    	public void setCount(int count) {
    		this.count = count;
    	public void setId(String id) { = id;
    	public void setRate(double rate) {
    		this.rate = rate;

Define your DAO

    public class MyPojoDAO extends GenericDAOImpl<MyPojo> implements GenericDAO<MyPojo> {
    	 * ctor
    	public MyPojoDAO() {

Use your DAO

    MyPojoDAO dao = new MyPojoDAO();
     * make an object
    final MyPojo myPojo = new MyPojo();
     * save the object
     * get the object back
    MyPojo retrievedPojo = dao.get(myPojo.getId());

Defining Transactions over DAOs

To combine multiple DAO operations into a transaction, simply annotate the method of the service that uses the DAOs. All of the DAO operations in the method will run inside a JCR transaction and the transaction will be rolled back if the annotated method throws an exception.

    public class MyServiceImpl implements MyService {
    	private MyPojoDAO mypojodao1;
      private MyPojoDAO mypojodao2;
    	public void doStuff() {;;


OMF Open-Session-In-View

The HTTP module of omf-contribs includes a simple HTTP filter that implements the Open-Session-In-View pattern. To use the filter, simply include it in your web.xml.


The OMF session will be available as the HTTP session variable "ObjectManagerSession". There is a working example of using this filter with Struts, here

Generating DAO objects from an existing JCR

In cases where OM is being used to map an existing JCR, jcr2pojo can be used to generate fully annotated POJOs which map the existing JCR structure. An alternative is to use objectmanager-maven-plugin, a maven mojo which wraps jcr2pojo. An example configuration looks like this:


This configuration will read the repository structure of the JCR at "http://localhost:8080/rmi" and produce POJOs to "/target/om".