You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by to...@apache.org on 2017/03/21 14:49:44 UTC
svn commit: r1787983 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
Author: tomekr
Date: Tue Mar 21 14:49:43 2017
New Revision: 1787983
URL: http://svn.apache.org/viewvc?rev=1787983&view=rev
Log:
OAK-4839: Allow to register DocumentNodeStore as a NodeStoreProvider
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java?rev=1787983&r1=1787982&r2=1787983&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStoreService.java Tue Mar 21 14:49:43 2017
@@ -88,6 +88,7 @@ import org.apache.jackrabbit.oak.spi.blo
import org.apache.jackrabbit.oak.spi.commit.BackgroundObserverMBean;
import org.apache.jackrabbit.oak.spi.state.Clusterable;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.jackrabbit.oak.spi.state.NodeStoreProvider;
import org.apache.jackrabbit.oak.spi.state.RevisionGC;
import org.apache.jackrabbit.oak.spi.state.RevisionGCMBean;
import org.apache.jackrabbit.oak.spi.whiteboard.Registration;
@@ -253,6 +254,12 @@ public class DocumentNodeStoreService {
)
public static final String PROP_PREFETCH_EXTERNAL_CHANGES = "prefetchExternalChanges";
+ @Property(
+ label = "NodeStoreProvider role",
+ description = "Property indicating that this component will not register as a NodeStore but as a NodeStoreProvider with given role"
+ )
+ public static final String PROP_ROLE = "role";
+
private static enum DocumentStoreType {
MONGO, RDB;
@@ -605,6 +612,11 @@ public class DocumentNodeStoreService {
log.warn("registerNodeStore: got RuntimeException while trying to determine time difference to server: " + e, e);
}
+ if (isNodeStoreProvider()) {
+ registerNodeStoreProvider(nodeStore);
+ return;
+ }
+
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put(Constants.SERVICE_PID, DocumentNodeStore.class.getName());
props.put(DESCRIPTION, getMetadata(ds));
@@ -620,6 +632,23 @@ public class DocumentNodeStoreService {
nodeStore, props);
}
+ private boolean isNodeStoreProvider() {
+ return prop(PROP_ROLE) != null;
+ }
+
+ private void registerNodeStoreProvider(final NodeStore ns) {
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put(NodeStoreProvider.ROLE, prop(PROP_ROLE));
+ nodeStoreReg = context.getBundleContext().registerService(NodeStoreProvider.class.getName(), new NodeStoreProvider() {
+ @Override
+ public NodeStore getNodeStore() {
+ return ns;
+ }
+ },
+ props);
+ log.info("Registered NodeStoreProvider backed by DocumentNodeStore");
+ }
+
@Deactivate
protected void deactivate() {
if (observerTracker != null) {