jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1464895 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/ main/java/org/apache/jackrabbit/oak/plugins/index/ main/java/org/apache/jackrabbit/oak/spi/lifecycle/ test/java/org/apache/jackrabbit/oak/plugins/index/ ...
Date Fri, 05 Apr 2013 09:01:51 GMT
Author: alexparvulescu
Date: Fri Apr  5 09:01:51 2013
New Revision: 1464895

URL: http://svn.apache.org/r1464895
Log:
OAK-751 IndexHookManager should implement EditorProvider instead of extending EditorHook

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManager.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java?rev=1464895&r1=1464894&r2=1464895&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/Oak.java Fri Apr
 5 09:01:51 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.annotation.Nonnull;
@@ -229,9 +230,12 @@ public class Oak {
         IndexHookProvider indexHooks = CompositeIndexHookProvider.compose(indexHookProviders);
         OakInitializer.initialize(store, new CompositeInitializer(initializers), indexHooks);
 
-        withEditorHook();
         QueryIndexProvider indexProvider = CompositeQueryIndexProvider.compose(queryIndexProviders);
 
+        List<CommitHook> initHooks = new ArrayList<CommitHook>(commitHooks);
+        initHooks.add(new EditorHook(CompositeEditorProvider
+                .compose(editorProviders)));
+
         // FIXME: move to proper workspace initialization
         // initialize default workspace
         Iterable<WorkspaceInitializer> workspaceInitializers =
@@ -244,10 +248,11 @@ public class Oak {
                         });
         OakInitializer.initialize(workspaceInitializers, store,
                 defaultWorkspaceName, indexHooks, indexProvider,
-                CompositeHook.compose(commitHooks));
+                CompositeHook.compose(initHooks));
 
         // add index hooks later to prevent the OakInitializer to do excessive indexing
-        commitHooks.add(IndexHookManager.of(indexHooks));
+        with(IndexHookManager.of(indexHooks));
+        withEditorHook();
         CommitHook commitHook = CompositeHook.compose(commitHooks);
         return new ContentRepositoryImpl(
                 store,

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManager.java?rev=1464895&r1=1464894&r2=1464895&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManager.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManager.java
Fri Apr  5 09:01:51 2013
@@ -17,43 +17,33 @@
 package org.apache.jackrabbit.oak.plugins.index;
 
 import org.apache.jackrabbit.oak.spi.commit.Editor;
-import org.apache.jackrabbit.oak.spi.commit.EditorHook;
 import org.apache.jackrabbit.oak.spi.commit.EditorProvider;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 
 /**
- * Keeps existing IndexHooks updated.
- * <br>
+ * Keeps existing IndexHooks updated. <br>
  * The existing index list is obtained via the IndexHookProvider.
  * 
  * @see IndexHook
  * @see IndexHookProvider
  * 
  */
-public class IndexHookManager extends EditorHook {
+public class IndexHookManager implements EditorProvider {
 
     public static final IndexHookManager of(IndexHookProvider provider) {
-        return new IndexHookManager(new EditorProviderWrapper(provider));
+        return new IndexHookManager(provider);
     }
 
-    private static class EditorProviderWrapper implements EditorProvider {
-
-        private final IndexHookProvider provider;
-
-        EditorProviderWrapper(IndexHookProvider provider) {
-            this.provider = provider;
-        }
-
-        @Override
-        public Editor getRootEditor(NodeState before, NodeState after,
-                NodeBuilder builder) {
-            return new IndexHookManagerDiff(provider, builder);
-        }
+    private final IndexHookProvider provider;
 
+    protected IndexHookManager(IndexHookProvider provider) {
+        this.provider = provider;
     }
 
-    protected IndexHookManager(EditorProvider provider) {
-        super(provider);
+    @Override
+    public Editor getRootEditor(NodeState before, NodeState after,
+            NodeBuilder builder) {
+        return new IndexHookManagerDiff(provider, builder);
     }
 }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java?rev=1464895&r1=1464894&r2=1464895&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/lifecycle/OakInitializer.java
Fri Apr  5 09:01:51 2013
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.oak.api.Com
 import org.apache.jackrabbit.oak.plugins.index.IndexHookManager;
 import org.apache.jackrabbit.oak.plugins.index.IndexHookProvider;
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
+import org.apache.jackrabbit.oak.spi.commit.EditorHook;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
 import org.apache.jackrabbit.oak.spi.state.NodeStore;
@@ -41,7 +42,7 @@ public final class OakInitializer {
         NodeState before = branch.getHead();
         branch.setRoot(initializer.initialize(before));
         try {
-            branch.merge(IndexHookManager.of(indexHook));
+            branch.merge(new EditorHook(IndexHookManager.of(indexHook)));
         } catch (CommitFailedException e) {
             throw new RuntimeException(e);
         }
@@ -60,7 +61,7 @@ public final class OakInitializer {
         }
         branch.setRoot(root);
         try {
-            branch.merge(IndexHookManager.of(indexHook));
+            branch.merge(new EditorHook(IndexHookManager.of(indexHook)));
         } catch (CommitFailedException e) {
             throw new RuntimeException(e);
         }

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java?rev=1464895&r1=1464894&r2=1464895&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/IndexHookManagerTest.java
Fri Apr  5 09:01:51 2013
@@ -84,7 +84,8 @@ public class IndexHookManagerTest {
 
         IndexHookManager im = IndexHookManager
                 .of(new Property2IndexHookProvider());
-        NodeState indexed = im.processCommit(before, after);
+        EditorHook hook = new EditorHook(im);
+        NodeState indexed = hook.processCommit(before, after);
 
         // first check that the index content nodes exist
         checkPathExists(indexed, "oak:index", "rootIndex", ":index");
@@ -136,7 +137,8 @@ public class IndexHookManagerTest {
 
         IndexHookManager im = IndexHookManager
                 .of(new Property2IndexHookProvider());
-        NodeState indexed = im.processCommit(before, after);
+        EditorHook hook = new EditorHook(im);
+        NodeState indexed = hook.processCommit(before, after);
 
         // first check that the index content nodes exist
         NodeState ns = checkPathExists(indexed, "oak:index", "rootIndex");
@@ -177,7 +179,8 @@ public class IndexHookManagerTest {
 
         IndexHookManager im = IndexHookManager
                 .of(new Property2IndexHookProvider());
-        NodeState indexed = im.processCommit(before, after);
+        EditorHook hook = new EditorHook(im);
+        NodeState indexed = hook.processCommit(before, after);
 
         // first check that the index content nodes exist
         NodeState ns = checkPathExists(indexed, "oak:index", "rootIndex");
@@ -219,7 +222,8 @@ public class IndexHookManagerTest {
 
         IndexHookManager im = IndexHookManager
                 .of(new Property2IndexHookProvider());
-        NodeState indexed = im.processCommit(before, after);
+        EditorHook hook = new EditorHook(im);
+        NodeState indexed = hook.processCommit(before, after);
 
         // first check that the index content nodes exist
         NodeState ns = checkPathExists(indexed, "oak:index", "rootIndex");

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java?rev=1464895&r1=1464894&r2=1464895&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/nodetype/NodeTypeIndexTest.java
Fri Apr  5 09:01:51 2013
@@ -34,6 +34,7 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.plugins.index.p2.Property2IndexHookProvider;
 import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
 import org.apache.jackrabbit.oak.query.index.FilterImpl;
+import org.apache.jackrabbit.oak.spi.commit.EditorHook;
 import org.apache.jackrabbit.oak.spi.lifecycle.OakInitializer;
 import org.apache.jackrabbit.oak.spi.query.Cursor;
 import org.apache.jackrabbit.oak.spi.query.Cursors;
@@ -75,7 +76,8 @@ public class NodeTypeIndexTest {
         addFile(root, "file-1");
 
         branch.setRoot(root.getNodeState());
-        branch.merge(IndexHookManager.of(new Property2IndexHookProvider()));
+        branch.merge(new EditorHook(IndexHookManager
+                .of(new Property2IndexHookProvider())));
 
         NodeState rootState = store.getRoot();
         NodeTypeIndex index = new NodeTypeIndex();



Mime
View raw message