As of 0.19, Rave has a MongoDB module that provides implementations for all of Rave's repository interfaces; thus providing support for MongoDB.

Using MongoDB for Persistence

JPA remains the primary supported data access method in the rave-portal & rave-portal-resources projects; but can be easily replaced with MongoDB using the following techniques:

Build from source

To build a MongoDB version of the demo binaries follow these steps:

  1. Obtain the source from the downloads or from Source Control
  2. From the project root directory execute: mvn install -Pmongodb

The rave-portal, rave-portal-resources & rave-shindig wars created by this process contain everything needed to run Rave with MongoDB persistence. See configuring MongoDB for information on how to set the database properties.

Custom Rave Extension

In a custom build that depends on rave-jpa directly, the only thing that needs to be done is to replace the rave-jpa dependency with rave-mongodb.

If the custom application depends on JPA indirectly, via a dependency on rave-portal-dependencies, add an exclusion of rave-jpa to rave-portal-dependencies as follows:

 <dependency>
    <groupId>org.apache.rave</groupId>
    <artifactId>rave-portal-dependencies</artifactId>
    <type>pom</type>
    <exclusions>
       <exclusion>
          <groupId>org.apache.rave</groupId>
          <artifactId>rave-jpa</artifactId>
       </exclusion>
    </exclusions>
 </dependency>
 <dependency>
     <groupId>org.apache.rave</groupId>
     <artifactId>rave-mongodb</artifactId>
 </dependency>

Configure the properties files for portal & shindig as described in configuring MongoDB

Demo Binaries

To replace the JPA implementation with Mongo in an extracted demo binary or other packaged Rave instance, take the following steps. This method is NOT recommended for production deployments. The preferred method is to modify a custom extension, or build, of Rave to as noted above:

  1. Start the demo binary as normal to allow it to extract the war archives
  2. Remove rave-jpa.jar from webapps/portal/WEB-INF/lib & webapps/ROOT/WEB-INF/lib
  3. Configure the properties files located in webapps/portal/WEB-INF/classes & webapps/ROOT/WEB-INF/classes per configuring MongoDB

 

Configuring MongoDB

Both portal.properties & rave.shindig.properties have entries for connecting to MongoDB.

mongo.host=localhost
mongo.port=27017  
mongo.database=rave
mongo.username=
mongo.password=

Architecture

Rave leverages Spring Data MongoDB to simplify interactions with the MongoDB database using the MongoOperations model serialization pattern. One the the primary benefits of using MongoDB for Rave persistence is that entire object hierarchies can be deserialized from the database in a single call. For example, rather than making a call to the database for a Page object, its Regions and RegionWidgets, we can now just deserialize the entire page in one call. Since Rave currently has repositories for many of the sub-components of a hierarchy, we needed a way to access the same object type from multiple repositories. This lead to the following component architecture:

|_ Rave MongoDB repository implementations
   | 
   |_ MongoModelOperations implementations 
      |
      |_ Spring MongoOperations
         |
         |_ Mongo Driver

As with any Rave component, MongoModelOperations instances can be wired in by interface or class name to custom components.

NOTE: Since some simple Rave objects such as PortalPreference & PageLayout instances don't have sub-component repositories, not every Rave model object has a corresponding MongoModelOperations instance.