jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: Custom nodetypes, any simple example?
Date Sun, 12 Mar 2006 08:52:07 GMT

On 3/11/06, Torgeir Veimo <torgeir@pobox.com> wrote:
> There's some code in jackrabbit contrib. Basically you can do it with;
> [reading and registering nodetypes]

There's a recently added and not yet much documented public API for
registering node types in Jackrabbit. Instead of casting a
NodeTypeManager instance to the internal NodeTypeManagerImpl class,
you should cast it to the JackrabbitNodeTypeManager API interface.
This interface extends the standard NodeTypeManager interface and is
guaranteed to remain backwards compatible at least through the
Jackrabbit 1.x cycle. No similar backwards compatibility claims are
made for the NodeTypeManagerImpl or the other classes in

The JackrabbitNodeTypeManager interface contains two registerNodeTypes
methods; one that takes an XML InputSource, and another that takes a
generic InputStream and a MIME content type string specifying the node
type syntax. The currently supported content types are "text/xml" for
the XML syntax and "text/x-jcr-cnd" for the CND syntax. The interface
has public string constants for the supported content types.

To register node types from a CND file called "nodetypes.cnd", you
could do this:

    Session session = ...;
    JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager)
        new FileInputStream("nodetypes.cnd"),

See the org.apache.api.JackrabbitNodeTypeManager interface and the
JCR-309 issue for more details.


Jukka Zitting

Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development
View raw message