org.wisdom-framework.jcr:wisdom-jcr-core

JCR support for Wisdom-Framework

License

License

GroupId

GroupId

org.wisdom-framework.jcr
ArtifactId

ArtifactId

wisdom-jcr-core
Last Version

Last Version

0.4.0
Release Date

Release Date

Type

Type

wisdom
Description

Description

JCR support for Wisdom-Framework
Project Organization

Project Organization

Wisdom Framework

Download wisdom-jcr-core

Dependencies

compile (3)

Group / Artifact Type Version
org.apache.felix : org.apache.felix.ipojo.annotations jar 1.12.1
org.jcrom : jcrom jar 2.1.0
org.apache.tika : tika-core jar 1.9

provided (1)

Group / Artifact Type Version
org.wisdom-framework : wisdom-api jar 0.9.1

test (2)

Group / Artifact Type Version
org.wisdom-framework : wisdom-test jar 0.9.1
org.slf4j : slf4j-jcl jar 1.7.6

Project Modules

There are no modules declared in this project.

Wisdom-JCR

This project integrates JCR repositories within Wisdom-Framework.

Introduction

JCR

JCR is a Content Repository API for Java and is speficied in the JSR 283: Content Repository for JavaTM Technology API Version 2.0. See Wikipedia for an overview of the JCR API.

Implementations

Several JCR implementations exists. The most famous open source implementations are Apache Jackrabbit and ModeShape

The Wisdom-JCR project is compatible with any JCR implementation. It expects that a service provides a javax.jcr.RepositoryFactory to load the repository.

Currently, the wisdom-modeshape module provides an integration with ModeShape repositories.

Object mapping

JCR repositories do not provide a mapping layer with Java entities. The Wisdom-JCR project relies on JCROM to map objects between Wisdom and the JCR repository.

Usage

Add the wisdom-jcr-core module to your project:

<dependency>
    <groupId>org.wisdom-framework.jcr</groupId>
    <artifactId>wisdom-jcr-core</artifactId>
    <version>0.2.0-SNAPSHOT</version>
</dependency>

And pick-up a module providing access to the repository implementation, for example wisdom-modeshape :

<dependency>
    <groupId>org.wisdom-framework.jcr</groupId>
    <artifactId>wisdom-modeshape</artifactId>
    <version>0.2.0-SNAPSHOT</version>
</dependency>

The full list of Maven dependencies depends on the JCR implementation used. See wisdom-modeshape module documentation for the dependencies to add for the ModeShape implementation.

Configuration

wisdom-jcr reads its configuration from the wisdom application configuration file.

Two sections are used in the configuration file

  • the jcrom section configures the object mapping layer
  • the jcr section configures which JCR repositories should be loaded

JCROM configuration

JCROM configuration keys starts with jcrom. This part allow to configure the mapping between the JCR repository and the Java entities.

Basic JCROM options :

  • packages Configure packages that need to be mapped by JCROM. Several packages can be listed comma-separated there.
  • dynamic.instantiation flag to enable dynamic instantiation for JCROM
  • clean.names flag to enable automatic name cleaning for JCROM

Additionnal options :

  • create.path if true, automatically create missing parent nodes when saving an entity

This is also the place where the link with the JCR repository used is configured :

  • "env".repository the name of the repository to use with JCROM for the given environment "env"

Full example :

jcrom {
    packages = todo.models,todo.other.models
    dynamic.instantiation = true
    clean.names = true
    create.path = true
    dev.repository = sample-repository-dev
    test.repository = sample-repository-test
    prod.repository = sample-repository-prod
}

JCR configuration

The JCR repositories declared in the JCROM configuration must also be configured in the wisdom application configuration file, starting with a jcr key. Each jcr repository must be declared using a key matching the repository named referenced in the JCROM configuration.

For each repository to load, you can specify a map of parameters to pass to the RepositoryFactory in the jcr configuration block. These parameters depends on the repository vendor. The following example is for the Modeshape repository factory provided with the wisdom-modeshape module :

jcr {
    sample-repository-dev {
        "org.modeshape.jcr.RepositoryName" = sample-repository-dev
        "org.modeshape.jcr.URL" = "modeshape.json"
    }
}

Checkout an example of configuration in the modeshape-sample project.

ModeShape configuration

This section is specific to ModeShape repositories.

The org.modeshape.jcr.URL declared in the configuration file references a json file used to configure the ModeShape repository.

See ModeShape documentation for more details about the modeshape configuration file.

Note that the name of the repository declared in the jcr part of the wisdom configuration must match the name of the repository declared in the modeshape json configuration file

ModeShape configuration file might itself reference other configuration files such as cnd files defining the node types used in the repository.

To allow Modeshape to correctly load cnd files when running tests, the following configuration must be added to the failsafe plugin in your pom:

<plugin>    
    <artifactId>maven-failsafe-plugin</artifactId>
    <configuration>
        <additionalClasspathElements>
            <additionalClasspathElement>${basedir}/target/wisdom</additionalClasspathElement>
        </additionalClasspathElements>
    </configuration>
</plugin>

See #12 for more information about this issue.

Sample

The modeshape-sample provides a simple wisdom application demonstrating the use of the wisdom-jcr module with a ModeShape repository.

Links

JCR

org.wisdom-framework.jcr

Wisdom Framework

Versions

Version
0.4.0
0.3.0
0.2.0
0.1.0