Search code examples
javaapacheaemjackrabbitsling

Adding custom nodetypes to Apache Sling WebApp


I'm trying to figure out a way to add custom nodetypes using a CND file to my Sling WebApp. I downloaded the WAR file and got it running but since all the code is already compiled (as .class files), I can't add code to read the CND file and add the custom nodetypes.

On a separate note, I do have Jackrabbit running and with it, I can use the JackrabbitNodeTypeManager or other ways to code reading a CND file and adding nodetypes. This works on my local repository that is not running on a server.

I want to be able to add new nodetypes to the Sling Web Application in a similar way. So I'll boil my questions down to:

  1. Is there a way to code the addition of new nodetypes in the Sling WebApp?
  2. How can I connect my Jackrabbit repository (local) to the Sling Web Application (on server) so that I can possibly explore adding custom nodetypes this way (as I'm doing on my Jackrabbit repo locally at the moment)?

I understand that Sling is a framework that uses Jackrabbit as a repo and provides REST-like services to work with the repository, but I imagine there's a way to add these custom nodetypes just like Jackrabbit allows.

Thanks.


Solution

  • Is there a way to code the addition of new nodetypes in the Sling WebApp?

    This is documented at Declared Node Type Registration. What you need to do is

    • write the node type definition in CND format
    • place it in a bundle
    • reference the file in the manifest using the Sling-Nodetypes header
    • deploy the bundle to your Sling app