Integrating Java Content Repository and Spring


News: Integrating Java Content Repository and Spring

  1. InfoQ has published "Integrating Java Content Repository and Spring," by Costin Leau, which discusses the use of Spring Modules' JCR helpers to allow users to follow Spring's useful (and common) callback pattern with JCR as well.
    Part of Spring Modules, JCR module's main objective is to simplify development with the JSR-170 API in a similar manner to that of the ORM package from the main Spring distribution. Features include:
    • JcrTemplate which allows execution of JcrCallback and exception handling (transforming checked JCR exceptions into unchecked Spring DAO exceptions). The template implements most of the methods from the JCR Session and can be easily used as a replacement. Moreover the template is aware of thread-bound sessions which can be used across several methods, functionality very useful when using a transactional repository.
    • RepositoryFactoryBean which configures, starts and stops the repository instances. As the JSR-170 doesn't address the way the repository should be configured, implementations vary in this regard. The support contains predefined FactoryBeans for Jackrabbit and Jeceira and an abstract base class which can easily support other repositories.
    • SessionFactory which unifies the Repository,Credentials and Workspace interfaces and allows automatic registration of listeners and custom namespaces.
    • Spring declarative transactional support for repositories that implement the (optional) transactional feature.
    • OpenSessionInView interceptor and filter which allow the usage of the same session per thread across different components. Along with JcrTemplate, the retrieval, closure and management of the JCR session is externalized and totally transparent to the caller.
    For this article, the reference implementation (Jackrabbit) will be used however, since the JCR module is using the javax.jcr interfaces changing the implementation is just a matter of configuration. Let's see step by step how to use Java Content Repository on top of Jackrabbit and how Spring Modules can help.
    Spring Modules' JCR submodule makes use of JCR fit the standard set by Spring for other data storage mechanisms, such as JDBC - and this article does a better job of discussing the submodule than the official documentation does.
  2. Spring Modules maven2 pom.xml[ Go to top ]

    Sure would be nice if the dependencies used in the pom for the jcr spring-module were correct. I can understand the jsr170 one, but there are plenty of others that don't.
  3. Since this article references the transaction management built into the JCR API, supported in Apache JackRabbit implementation, and integrated with Spring JTA like wrappers I thought it should mentioned that this is an area that is (in my opinion) relatively immature especially in the context of enterprise deployments that require clustering and have a mixed workload (CRUD) with high levels of concurrency. My recent blogs entries on transaction analysis shed more light on the implementation of transaction support in an actual JCR implementation. Transaction Integrity Inspections More Transaction Integrity Inspections Concurrent Transactional Access Inspections If you wish to find out more about transaction integrity testing then you might be interested to know that I will be holding a BOF: Java EE Transaction Models at the TheServerSide Java Symposium conference in Las Vegas next week. During a co-operation period at HP OpenView I actively promoted JCR (level 1 = read-only) as a adapter layer for repository integration in a federated CMDB solution that never really materialized because at the time they could never understand the difference between the information model (repositories) and the management model (subset under change management). regards, William Louth JXInsight Product Architect "Java EE tuning, testing, tracing and monitoring with JXInsight" JInspired