6 Replies Latest reply on Jan 21, 2013 4:18 AM by Horia Chiorean

    ModeShape and Spring-Jcr

    Marius Giepz Newbie

      Hi everyone!

      I am new to modeshape and I have a question regarding integration with spring.


      I would like to evaluate if it is possible to build a repository for my spring-based webapp.

      Does anybody know if ModeShape works with the springmodules-jcr? I know that this project

      is not developed further but to me it seems like the easiest way to get started with a spring app and jcr.

      There are very few examples out there and all of them use Jackrabbit.


      kind regards,



        • 1. Re: ModeShape and Spring-Jcr
          Horia Chiorean Master

          Hi Marius,


          We don't have any "active" examples with Spring integration, but I'm thinking it should be pretty easy to integrate in the following way (hoping you're referring to a ModeShape 3.x version):


          - create your own subclass of org.springframework.extensions.jcr.RepositoryFactoryBean (from the se-jcr Spring extension module)


          - in the above subclass, use ModeShape's Java API and a JSON configuration file to start up & initialize the repository (see https://docs.jboss.org/author/display/MODE/ModeShape+in+Java+applications for the different ways in which you can start up the repository)

          I think you can do this in 2 different ways: either using a ModeShapeEngine instance or use a JcrSessionFactory instance, both of which need a RepositoryConfiguration (see the above link for more information).


          - after you have started the repository, all you need to do is to hold onto it and return in  the RepositoryFactoryBean#createRepository method.


          Hope this helps

          • 2. Re: ModeShape and Spring-Jcr
            Horia Chiorean Master

            I've also created https://issues.jboss.org/browse/MODE-1759, so we hope to provide a Spring integration example with the next version.

            • 3. Re: ModeShape and Spring-Jcr
              Marius Giepz Newbie

              Thank you for your suggestions!

              I was able to get it working using the ModeShapeEngine.


              Anyhow, it seems like my evaluation of ModeShape will probably stop now as I just realized that it

              seems not possible to model user-privileges on nodes in the repository. Is that correct?

              One part of my applications repository would have to be a folder/file like structure with custom privileges per node-type like

              view, execute, modify and such. The privileges should also be inherited from parent nodes of the same type.

              Do I see it correctly that AccessControlManager.hasPrivileges (which ModeShape does not support) would be the only means

              to achieve that? Or are there other possibilities using custom code (doesnt have to be jcr-api)?

              Could  a custom AuthorizationProvider do sth. like that?


              kind regards,



              • 4. Re: ModeShape and Spring-Jcr
                Horia Chiorean Master

                You are correct, ModeShape does not currently support the "access control management" feature (as defined by the JSR 283 spec)


                However, if you have a look at org.modeshape.jcr.JcrSession#hasPermission method (which is called for pretty much all node operations) we have a pretty easy way of customizing access control logic, via a org.modeshape.jcr.security.AuthorizationProvider instance.

                You can see some more details around this here: https://docs.jboss.org/author/display/MODE/Custom+authentication+providers

                • 5. Re: ModeShape and Spring-Jcr
                  Marius Giepz Newbie

                  Thanks for the answer. I have just read that description.

                  Is it possible to create some additional ModeShapePermissions?

                  I am asking because READ might be too unspecific for my application. Apart from the

                  operation on the repository itself I would like to map the permissions to some

                  additional applicationlevel meaning.

                  • 6. Re: ModeShape and Spring-Jcr
                    Horia Chiorean Master

                    Unfortunatelly from the perspective of the JCR layer implementation, we use the permissions from the {{ModeShapePermissions}} interface directly, so atm extending that wouldn't really work.