= JCR Component
:doctitle: JCR
:shortname: jcr
:artifactid: camel-jcr
:description: Read and write nodes to/from a JCR compliant content repository.
:since: 1.3
:supportlevel: Stable
:component-header: Both producer and consumer are supported
//Manually maintained attributes
:camel-spring-boot-name: jcr

*Since Camel {since}*

*{component-header}*

The JCR component allows you to add/read nodes to/from a JCR
compliant content repository (for example,
http://jackrabbit.apache.org/[Apache Jackrabbit]) with its producer, or
register an EventListener with the consumer.

You can use consumer as an EventListener in
JCR or a producer to read a node by identifier.

Maven users will need to add the following dependency to their `pom.xml`
for this component:

[source,xml]
------------------------------------------------------------
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-jcr</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
------------------------------------------------------------

== URI format

-------------------------------------------
jcr://user:password@repository/path/to/node
-------------------------------------------

The `repository` element of the URI is used to look up the JCR
`Repository` object in the Camel context registry.


// component-configure options: START

// component-configure options: END

// component options: START
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
// component options: END

// endpoint options: START

// endpoint options: END

// component headers: START
include::partial$component-endpoint-headers.adoc[]
// component headers: END

== Example

The snippet below creates a node named `node` under the `/home/test`
node in the content repository. One additional property is added to the
node as well: `my.contents.property` which will contain the body of the
message being sent.

[source,java]
------------------------------------------------------------------------
from("direct:a").setHeader(JcrConstants.JCR_NODE_NAME, constant("node"))
    .setHeader("my.contents.property", body())
    .to("jcr://user:pass@repository/home/test");
------------------------------------------------------------------------

The following code will register an EventListener under the path
import-application/inbox for Event.NODE_ADDED and Event.NODE_REMOVED
events (event types 1 and 2, both masked as 3) and listening deep for
all the children.

[source,xml]
---------------------------------------------------------------------------------------------
<route>
    <from uri="jcr://user:pass@repository/import-application/inbox?eventTypes=3&deep=true" />
    <to uri="direct:execute-import-application" />
</route>
---------------------------------------------------------------------------------------------



include::spring-boot:partial$starter.adoc[]
