NoSQL Data storage with Modeshape 4
- Published: 04 January 2015
ModeShape is a distributed, hierarchical, transactional and consistent datastore with support for queries and full text search. It also supports versioning, events, locking and even more. Clients can use the JSR-283 Java API to access the Modeshape repository (also known as JCR), the Modeshape REST API, or the JDBC driver that can be used to query the content using SQL syntax.
The release 4 of Modeshape perfectly integrates with WildFly and sits on top of an Infinispan data grid. Let's see how to install it on a WildFly server distribution. Start by downloading the ModeShape subsystem for Wildfly 8.
The WildFly kit contains the following list of files:
. . . .
As you can see, the modules will install the Modeshape basic libraries, the Repository web explorer (http://localhost:8080/modeshape-explorer/), the REST Web Application (http://localhost:8080/modeshape-rest/) and the WebDav application (http://localhost:8080/modeshape-webdav)
$ unzip modeshape-4.1.0.Final-jboss-wf8-dist.zip
Before being able to use all the applications included in the kit, you need anyway to add an application user with connect,admin permission. Therefore execute add-user.sh such as:
$ add-user.sh -a admin admin
Then, in your application-roles.properties include the roles for the admin user:
We are done. Start one of the available modeshape configurations such as:
$ standalone.sh -c standalone-modeshape.xml
We will now have a look at the available repositories. We can use for example the Web explorer interface
The Repository Web Explorer provides the bulk of functionality for browsing and managing repositories.
The Web Explorer contains five main tabs, each of which provides management page for a aspect of the repository:
- The "Explore" page on controls content of the repository. Using this page user is able to browse content, add, remove or edit node. Change properties of the node, etc;
- The "Node Types" page on provides web-based management interface for node types management functions;
- The "Descriptor" page on shows repository parameters;
- The "Query" page on allows user execute query;
- The "Admin" page on provides access to the administrative functions and metrics.
Out of the box, two repositories are already configured in Modeshape. You might wonder where are repository configured and stored ? Repositories are configured centrally within the Wildfly configuration, and make use of the existing Infinispan configuration and management support.
<subsystem xmlns="urn:jboss:domain:modeshape:2.0"> <repository name="sample" anonymous-roles="admin"/> <repository name="artifacts" anonymous-roles="admin"> . . . </subsystem>
As we said, each ModeShape repository stores its content in an Infinispan cache. Hence you will need to match your repository with an Infinispan local cache element:
<cache-container name="modeshape" default-cache="sample" module="org.modeshape"> <local-cache name="sample"> <locking isolation="READ_COMMITTED"/> <transaction mode="NON_XA"/> <file-store passivation="false" purge="false" path="modeshape/store/sample"/> </local-cache> <local-cache name="artifacts"> <locking isolation="READ_COMMITTED"/> <transaction mode="NON_XA"/> <file-store passivation="false" purge="false" path="modeshape/store/artifacts"/> </local-cache> </cache-container>
Using the Modeshape REST API
You can query your Modeshape list of repositories also using the REST API. A typical conversation might start with a request to the server to dynamically discover the available repositories:
This request would generate a response that mapped the names of the available repositories to metadata information about the repositories:
. . . .
. . . .
The REST web application is also navigable and can lead you through the Workspaces contained in the repository and finally into the single items.
In this tutorial Modeshape 4 in action you can learn how to use the Modeshape 4 API to access and display the content of a JCR Repository. Good reading !