views:

449

answers:

3

Is there a way that I can configure custom node types for Apache Jackrabbit to be registered when a new repository is instantiated?

I am automating my build using Apache Maven and have some unit tests to run with JUnit and integration tests to run with Jetty and want to be able to easily set-up and tear-down a test repository.

A: 

I'm not sure about nodetypes, but I've read that apache sling has a way to specify initial content when a package (osgi bundle) is installed. Sounds at least similar to what you have in mind.

+3  A: 

I suggest that you define your nodetypes using a CND file and configure your JUnit test cases to register them for you, as in this example. I would say the most appropriate way to do so is to define an abstract test case which performs this configuration.

Also notice that the node types are associated to a workspace, and not to the whole repository.

DouglasJose
No, node types are installed repository-wide in Jackrabbit and are also seen this way by the spec. The reason is that you can clone/copy nodes from one workspace to the other, so it doesn't make sense to separate node type registrations.Otherwise I'd second your answer.
Alexander Klimetschek
+3  A: 

If you are able to upgrade to the newly-released Jackrabbit 2.0.0, you can programmatically create and register nodetypes. The main hook is the JSR-283 NodeTypeManager which doubles as a factory for new NodeTypes, and a place for them to be registered. Just register them in the setup method of your JUnit tests, and you should be good to go.

Adam