I got Jackrabbit Oak running on top of a MongoDB instance. Pretty simple and pretty much straight from the docs (Sprint Boot application):
@PostConstruct
public void initRepository() {
LOG.info("Initializing Oak repository");
@SuppressWarnings({ "resource", "deprecation" })
DB db = new MongoClient("127.0.0.1", 27017).getDB("tenantX" + System.currentTimeMillis());
DocumentNodeStore ns = new DocumentMK.Builder().setMongoDB(db).getNodeStore();
this.repository = new Jcr(new Oak(ns)).createRepository();
}
@Override
public Session getThreadLocalSession() throws RepositoryException {
Session session = this.repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
return session;
}
Now, where to from here if I want transactions? Simply adding @Transactional to a service method doesn't change anything.
In our previous "old school" Jackrabbit application we used something like
<bean id="transactionManager" class="org.jencks.factory.TransactionManagerFactoryBean" />
<bean id="jcrConnectionManager" class="org.jencks.factory.ConnectionManagerFactoryBean">
<property name="transactionManager" ref="transactionManager" />
<property name="transaction" value="xa" />
<property name="poolMinSize" value="1" />
<property name="poolMaxSize" value="50" />
<property name="connectionMaxIdleMinutes" value="5" />
<property name="partitionStrategy" value="by-connector-properties" />
</bean>
<bean id="jcrManagedConnectionFactory"
class="org.apache.jackrabbit.jca.JCAManagedConnectionFactory">
<property name="configFile" value="classpath:repository.xml" />
<property name="homeDir" value="/repository" />
</bean>
<bean id="repository"
class="org.springframework.jca.support.LocalConnectionFactoryBean">
<property name="managedConnectionFactory" ref="jcrManagedConnectionFactory" />
<property name="connectionManager" ref="jcrConnectionManager" />
</bean>
But Oak doesn't ship with a class like JCAManagedConnectionFactory.