JCR Component

The jcr component allows you to add nodes to a JCR compliant content repository (for example, Apache Jackrabbit).

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

<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

Usage

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

If a message is sent to a JCR producer endpoint:

  • A new node is created in the content repository,
  • All the message properties of the IN message are transformed to JCR Value instances and added to the new node,
  • The node's UUID is returned in the OUT message.

Message properties

All message properties are converted to node properties, except for the CamelJcrNodeName property (you can refer to JcrConstants.NODE_NAME in your code), which is used to determine the node name.

Example

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

from("direct:a").setProperty(JcrConstants.JCR_NODE_NAME, constant("node"))
    .setProperty("my.contents.property", body()).to("jcr://user:pass@repository/home/test");

See Also

© 2004-2011 The Apache Software Foundation.
Apache Camel, Camel, Apache, the Apache feather logo, and the Apache Camel project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram