Question

I am learning how to use a content repository and I am using Jackrabbit. I have a Spring 3.x application that I successfully have connected with the content repository. I read about deployment models (http://jackrabbit.apache.org/deployment-models.html) and I wonder what type of deployment model I use? I have installed Jackrabbit as a module in JBoss 7 server, but that is esentially the same as bundling the Jackrabbit lib with the application so I guess that I use the Application bundle model?

And then the next question: which option is preferred?

I am currently using this configuration: http://wiki.apache.org/jackrabbit/ExamplesPage

<bean id="repository" class="org.apache.jackrabbit.core.RepositoryImpl">
    <constructor-arg index="0" ref="config" />
</bean>
<bean id="config" class="org.apache.jackrabbit.core.config.RepositoryConfig" factory-method="create">
    <constructor-arg index="0" value="./repository.xml"/>
    <constructor-arg index="1" value="." />
</bean>
Was it helpful?

Solution

The three deployment models listed on that page don't fully reflect the range of nuances available.

For example, on the face of it, the difference between the application bundle and shared J2EE resource models seems to be that in the former, there is a repository instance per application, and in the latter, an instance per app server. If you are only running one application on your app server, as i hope most people are, then the difference seems moot.

However, there is then another likely difference: in the application bundle, i would expect the app to create the repository directly, with something like new TransientRepository().login(), whereas in the shared J2EE resource, it has to be created and managed by the app server as a resource adapter.

That said, i think you can create a per-application resource adapter sort of thing in some containers, and you can package the code into the app server (as a module in JBoss AS7), and then create the repository in your code. That blurs the boundaries a bit. Like i said, nuances. If you're creating the repository in code, i think i would count your approach as being an application bundle, even if it uses a module.

Anyway, where this rambling is going is that i think the most interesting difference is the way the repository is created and managed, and the consequences that has. Doing that in your code is probably easier to get going, as it doesn't involve mucking about with XML. But doing it in the app server config means that the app server will automatically take care of pooling and transactions and whatnot. That sounds quite attractive to me.

There may also be consequences for integrating access control (if you need that) with user logins - if the app server is managing both, then it may be easier to integrate them. Or harder, you never know.

By amazing synchronicity, this afternoon i dusted off an old project of mine to try and get Jackrabbit working nicely in JBoss AS7 as a resource - JCRDemo - which may be of interest. It contains all the plumbing, but doesn't do anything interesting - it just has a servlet which renders the toString of the repository's root node!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top