SeamFramework.orgCommunity Documentation

Seam JCR


1. Seam JCR - Introduction
1.1. Introduction
1.2. Maven dependency configuration
2. Seam JCR - JBoss ModeShape Integration
2.1. ModeShape Integration Installation
2.2. Usage
3. Seam JCR - JackRabbit Integration
3.1. JackRabbit Integration Installation
3.2. Usage
4. Seam JCR - Event Mapping
4.1.
4.2.

If you are using Maven as your build tool, you can add the following single dependency to your pom.xml file to include Seam JCR:


<dependency>
   <groupId>org.jboss.seam.jcr</groupId>
   <artifactId>seam-jcr</artifactId>
   <version>${seam.jcr.version}</version>
</dependency>
        

Tip

Substitute the expression ${seam.jcr.version} with the most recent or appropriate version of Seam JCR. Alternatively, you can create a Maven user-defined property to satisfy this substitution so you can centrally manage the version.

Alternatively, you can use the API at compile time and only include the implementation at runtime. This protects you from inadvertantly depending on an implementation class.


<dependency>
   <groupId>org.jboss.seam.jcr</groupId>
   <artifactId>seam-jcr-api</artifactId>
   <version>${seam.jcr.version}</version>
   <scope>compile</scope>
</dependency>

<dependency>
   <groupId>org.jboss.seam.jcr</groupId>
   <artifactId>seam-jcr-impl</artifactId>
   <version>${seam.jcr.version}</version>
   <scope>runtime</scope>
</dependency>
        

In addition to your Seam JCR dependencies, you must also declare a dependency on a JCR Implementation.

Seam JCR provides functionality to fire CDI Events based on events found in JCR. The rules of how events are fired are based around the underlying implementation.

Tip

You will not have an active JCR Session during the event firing, a new one will need to be created.

Tip

Some JCR implementations, like Modeshape fires events on a separate thread, so probably you will get errors if your observer method is declared on a @RequestScoped object, for example.

To observe an event, use the @Observes and the additional qualifiers on seam-jcr-api module (Check package org.jboss.seam.jcr.annotations.events). If you need to watch any JCR event, then avoid using any Qualifier at all.

    import javax.jcr.observation.Event;
       
    public void observeAdded(@Observes @NodeAdded Event evt) {
    	// Called when a node is added
    }
    public void observeAll(@Observes javax.jcr.observation.Event evt) {
    	// Called when any node event occurs 
    }