KONTAKT  
PorträtAngebotReferenzenDokumentation
  
     
 
 
Magnolia Jackrabbit OCM Integration

What is it?
Jackrabbit OCM is an object/JCR persistence (and query) service. This tools lets you to persist Java objects (POJOs) into a JCR compliant repository - including association, inheritance, polymorphism, composition, and the Java Collections framework.

Why do we need POJOs in the first place?
Often the Content objects you get when reading data form the repository is not enough:

  • It seems one cannot store Content objects in the servlet container session for use in multiple request-response cycles (maybe this could be solved with a deeper understanding of JCR sessions).
  • In many cases you need additional business logic, e.g. the shopping cart that calculates the grand total, tax, discount, shipping costs on all its cart items.
  • Often POJOs offer more comfort, security, flexibility with specific accessor methods etc.


Why don't we simply use Content2Bean?
The Content2Bean features in Magnolia do a great job of easy conversion of simple Content objects to beans. However you quickly hit a limit with it.

  • Content2Bean only does the conversion from a Content object to a bean well.
  • It only supports the conversion of a certain node to one specific bean type - if you want to use the same data in different contexts as different bean representation, you are out of luck. It seems though as if OCM would have the same limitation.
  • It does not handle data types very intelligently when pushing the values back to the node.
  • There is no support for storing the node at a certain parent path or generating node names etc. Again, there is no native support for this in OCM either.
     
   
Where can I get it? And what are the requirements?

You can find Jackrabbit OCM here:
http://svn.apache.org/repos/asf/jackrabbit/commons/ocm/trunk/
or you can download the binaries of Jackrabbit OCM which also include a bugfix.
Be aware that you will also to add a few dependencies to your Magnolia instance (asm-3.3.jar, cglib-2.2.jar)

As for the Magnolia module, it can be downloaded here (versions of 2010-07-15):
JAR (binaries)
Source from the Magnolia Forge


The additional requirements are:

  • Magnolia 4.2.3 or newer
  • Data Module 1.4.2 or newer

 

   
How to install and use it

Simply drop the jars in your Magnolia's WEB-INF/lib folder and reboot. The module will

  • create a "ocm" module node in the config tree with sample class descriptor configurations and a page to test the "Press Release" CRUD scenario,
  • register a "ocmSamplePressRelease" node type including the usual data module stuff (node type configuration, dialog, tree, menu item)
  • and will add a "OCM Test" menu item to the Tools menu

Under this menu item you will find a test page where you can do a CRUD test for the press release objects.

 

   
Notes
  • As usual this comes AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
  • If you have been using OCM for a while please note that the package names have changed.
  • So far only the CRUD actions used for the press release scenario have been tested. This just scratches the surface of OCM. Feel free to take it to a next level!
  • OCM itself is poorly documented. If you wonder about the class descriptors used to map nodes to classes and vice-versa have a look at the sample config files in the unit tests of OCM.
  • All additions were made outside of OCM so that the OCM distribution stays unmodified. In some cases this has not lead to pretty code. We will try to submit some these things to OCM as patch, hoping they will get included.
   
 
 
fastforward websolutions
Kramgasse 16
3011 Bern
Telefon 031 348 54 44
Fax 031 348 54 55
info contact
©2011 fastforward websolutions