Andrew Sterling Hanenkamp > Java-JCR > Java::JCR



Annotate this POD


New  3
Open  0
View/Report Bugs
Module Version: 0.08   Source  


Java::JCR - Use JSR 170 (JCR) repositories from Perl


  use Java::JCR;
  use Java::JCR::Jackrabbit;

  my $session = $repository->login(
      Java::JCR::SimpleCredentials->new('username', 'password')

  my $root = $session->get_root_node;
  my $node = $root->add_node('foo', 'nt:unstructured');
  $node->set_property('bar', 10);
  $node->set_property('baz', 'blah');
  $node->set_property('qux', 4.8');


The JSR 170 specification describes a Java-based API for access hierarchical databases. This is generally referred to by the abbreviation JCR, which is an abbreviation for Content Repository API for Java Technology Specification.

The biggest OSS implementation, as of this writing, is Jackrabbit, which is a project at the Apache Software Foundation, Currently, this library allows Perl programmers to develop using the JCR and Jackrabbit, though, there's no reason why connectors can't be written for other implementations, such as Jaceira, CRX, eXoplatform, etc. The JCR library wrappers included are not at all specific to Jackrabbit.


At this time, this library does not have documentation for any of the methods used. However, the Perl documentation included with each package links to the Java documentation for that package. That documentation can be used with this API by keeping the following in mind:


Here's my opportunity to plug Inline::Java. It works very well and made this possible. There are some deficiencies in exception handling and other places that one would expect difficulties, but all-in-all it works very well. The actual mapping to Java is done through this facility.

In addition, I've created a pure-Perl wrapper object for each to allow me to easily cope with problems in the mappings and to provide an opportunity to hook in better features.

For example, the Java Date object isn't really an ideal solution for Perl coders. Therefore, it is planned that dates be mapped to a Perl equivalent (probably with the option of choosing your favorite since there are quite a few to choose from). This wouldn't be possible if the mapping was just the raw Inline::Java one.

The wrappers also help smooth off some of the rough edges of the mapping from Java.


Some things don't work. As of this writing, this is the first release, and I've only done just enough to get the first three "hops" from the Jackrabbit documentation going. You should be able to connect to a repository, login, get nodes and properties by path, create nodes and properties, and import XML using the examples on the Jackrabbit web site. (Perl ports of those are in the ex/ directory of the distribution, by the way.)

If you would like to contribute, let me know of a bug, or make a comment, please send me email at <> or post a ticket to CPAN RT at

SEE ALSO ^,, Inline::Java, Java::JCR::Lock, Java::JCR::Nodetype, Java::JCR::Observation, Java::JCR::Query, Java::JCR::Util, Java::JCR::Version, Java::JCR::Jackrabbit


Andrew Sterling Hanenkamp, <>


Copyright 2006 Andrew Sterling Hanenkamp <>. All Rights Reserved.



syntax highlighting: