jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1402088 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak: osgi/ plugins/index/ plugins/index/lucene/ plugins/index/property/
Date Thu, 25 Oct 2012 10:36:36 GMT
Author: alexparvulescu
Date: Thu Oct 25 10:36:35 2012
New Revision: 1402088

URL: http://svn.apache.org/viewvc?rev=1402088&view=rev
Log:
OAK-394 IndexManagerHook to manage existing indexes

Added:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiIndexHookProvider.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHook.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/plugins/index/IndexHookProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexHookProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexHookProvider.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexProvider.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java?rev=1402088&r1=1402087&r2=1402088&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/Activator.java
Thu Oct 25 10:36:35 2012
@@ -24,6 +24,7 @@ import org.apache.jackrabbit.mk.api.Micr
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
 import org.apache.jackrabbit.oak.kernel.KernelNodeStore;
+import org.apache.jackrabbit.oak.plugins.index.IndexHookManager;
 import org.apache.jackrabbit.oak.plugins.nodetype.DefaultTypeEditor;
 import org.apache.jackrabbit.oak.spi.commit.CompositeHook;
 import org.apache.jackrabbit.oak.spi.commit.ValidatingHook;
@@ -42,6 +43,8 @@ public class Activator implements Bundle
 
     private final OsgiIndexProvider indexProvider = new OsgiIndexProvider();
 
+    private final OsgiIndexHookProvider indexHookProvider = new OsgiIndexHookProvider();
+
     private final OsgiValidatorProvider validatorProvider = new OsgiValidatorProvider();
 
     private final OsgiRepositoryInitializer kernelTracker = new OsgiRepositoryInitializer();
@@ -56,6 +59,7 @@ public class Activator implements Bundle
         context = bundleContext;
 
         indexProvider.start(bundleContext);
+        indexHookProvider.start(bundleContext);
         validatorProvider.start(bundleContext);
         kernelTracker.start(bundleContext);
 
@@ -69,6 +73,7 @@ public class Activator implements Bundle
         tracker.close();
 
         indexProvider.stop();
+        indexHookProvider.stop();
         validatorProvider.stop();
         kernelTracker.stop();
     }
@@ -85,8 +90,8 @@ public class Activator implements Bundle
                     .with(new CompositeHook(
                         // TODO: DefaultTypeEditor is JCR specific and does not belong here
                         new DefaultTypeEditor(),
-                        new ValidatingHook(validatorProvider)))
-                        // new LuceneEditor());
+                        new ValidatingHook(validatorProvider),
+                        new IndexHookManager(indexHookProvider)))
                     .with(indexProvider);
             services.put(reference, context.registerService(
                     ContentRepository.class.getName(),

Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiIndexHookProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiIndexHookProvider.java?rev=1402088&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiIndexHookProvider.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiIndexHookProvider.java
Thu Oct 25 10:36:35 2012
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.osgi;
+
+import java.util.List;
+
+import javax.annotation.Nonnull;
+
+import org.apache.jackrabbit.oak.plugins.index.CompositeIndexHookProvider;
+import org.apache.jackrabbit.oak.plugins.index.IndexHook;
+import org.apache.jackrabbit.oak.plugins.index.IndexHookProvider;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+
+/**
+ * This IndexHook provider combines all index hooks of all available OSGi
+ * IndexHook providers.
+ */
+public class OsgiIndexHookProvider extends
+        AbstractServiceTracker<IndexHookProvider> implements IndexHookProvider {
+
+    public OsgiIndexHookProvider() {
+        super(IndexHookProvider.class);
+    }
+
+    @Override @Nonnull
+    public List<? extends IndexHook> getIndexHooks(String type,
+            NodeBuilder builder) {
+        IndexHookProvider composite = CompositeIndexHookProvider
+                .compose(getServices());
+        return composite.getIndexHooks(type, builder);
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/osgi/OsgiIndexHookProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHook.java?rev=1402088&r1=1402087&r2=1402088&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHook.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHook.java
Thu Oct 25 10:36:35 2012
@@ -18,6 +18,11 @@ package org.apache.jackrabbit.oak.plugin
 
 import org.apache.jackrabbit.oak.spi.commit.CommitHook;
 
+/**
+ * Represents the content of a QueryIndex as well as a mechanism for keeping
+ * this content up to date.
+ * 
+ */
 public interface IndexHook extends CommitHook {
 
 }

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=1402088&r1=1402087&r2=1402088&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
Thu Oct 25 10:36:35 2012
@@ -38,6 +38,17 @@ import org.apache.jackrabbit.oak.spi.sta
 import org.apache.jackrabbit.oak.spi.state.NodeStateDiff;
 import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
 
+/**
+ * Keeps existing IndexHooks updated.
+ * 
+ * <p>
+ * The existing index list is obtained via the IndexHookProvider.
+ * </p>
+ * 
+ * @see IndexHook
+ * @see IndexHookProvider
+ * 
+ */
 public class IndexHookManager implements CommitHook {
 
     private final IndexHookProvider provider;

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookProvider.java?rev=1402088&r1=1402087&r2=1402088&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/IndexHookProvider.java
Thu Oct 25 10:36:35 2012
@@ -22,8 +22,25 @@ import javax.annotation.Nonnull;
 
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 
+/**
+ * Extension point for plugging in different kinds of IndexHook providers.
+ * 
+ * @see IndexHook
+ */
 public interface IndexHookProvider {
 
+    /**
+     * 
+     * Each provider knows how to produce a certain type of index. If the
+     * <code>type</code> param is of an unknown value, the provider is expected
+     * to return an empty list.
+     * 
+     * @param type
+     *            the index type
+     * @param builder
+     *            the node state builder that will be used for updates
+     * @return a list of index hooks
+     */
     @Nonnull
     List<? extends IndexHook> getIndexHooks(String type, NodeBuilder builder);
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java?rev=1402088&r1=1402087&r2=1402088&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndex.java
Thu Oct 25 10:36:35 2012
@@ -70,7 +70,36 @@ import static org.apache.jackrabbit.oak.
 import static org.apache.jackrabbit.oak.query.Query.JCR_PATH;
 
 /**
- * This index uses internally runs a query against a Lucene index.
+ * Provides a QueryIndex that does lookups against a Lucene-based index
+ * 
+ * <p>
+ * To define a lucene index on a subtree you have to add an <code>oak:index<code>
node.
+ * 
+ * Under it follows the index definition node that:
+ * <ul>
+ * <li>must be of type <code>oak:queryIndexDefinition</code></li>
+ * <li>must have the <code>type</code> property set to <b><code>lucene</code></b></li>
+ * </ul>
+ * </p>
+ * 
+ * <p>
+ * Note: <code>reindex<code> is a property that when set to <code>true</code>,
triggers a full content reindex.
+ * </p>
+ * 
+ * <pre>
+ * <code>
+ * {
+ *     NodeBuilder index = root.child("oak:index");
+ *     index.child("lucene")
+ *         .setProperty("jcr:primaryType", "oak:queryIndexDefinition", Type.NAME)
+ *         .setProperty("type", "lucene")
+ *         .setProperty("reindex", "true");
+ * }
+ * </code>
+ * </pre>
+ * 
+ * @see QueryIndex
+ * 
  */
 public class LuceneIndex implements QueryIndex, LuceneIndexConstants {
 

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexHookProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexHookProvider.java?rev=1402088&r1=1402087&r2=1402088&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexHookProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexHookProvider.java
Thu Oct 25 10:36:35 2012
@@ -16,16 +16,28 @@
  */
 package org.apache.jackrabbit.oak.plugins.index.lucene;
 
+import static org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexConstants.TYPE_LUCENE;
+
 import java.util.List;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.oak.plugins.index.IndexHook;
 import org.apache.jackrabbit.oak.plugins.index.IndexHookProvider;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 
 import com.google.common.collect.ImmutableList;
 
-public class LuceneIndexHookProvider implements IndexHookProvider,
-        LuceneIndexConstants {
+/**
+ * Service that provides Lucene based IndexHooks
+ * 
+ * @see LuceneHook
+ * @see IndexHookProvider
+ * 
+ */
+@Component
+@Service(IndexHookProvider.class)
+public class LuceneIndexHookProvider implements IndexHookProvider {
 
     @Override
     public List<? extends IndexHook> getIndexHooks(String type,

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProvider.java?rev=1402088&r1=1402087&r2=1402088&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexProvider.java
Thu Oct 25 10:36:35 2012
@@ -32,6 +32,9 @@ import org.slf4j.LoggerFactory;
 
 /**
  * A provider for Lucene indexes.
+ * 
+ * @see LuceneIndex
+ * 
  */
 public class LuceneIndexProvider implements QueryIndexProvider,
         LuceneIndexConstants {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java?rev=1402088&r1=1402087&r2=1402088&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndex.java
Thu Oct 25 10:36:35 2012
@@ -42,19 +42,26 @@ import com.google.common.collect.Sets;
  * Provides a QueryIndex that does lookups against a property index
  * 
  * <p>
- * How to define a property index on a subtree you have to add an
- * <code>oak:index<code> node. Under it follows the index definition node that
must be of type <code>oak:queryIndexDefinition</code>
- * and contain the
- * <code>propertyNames<code> property that indicates what property will be stored
in the index.
+ * To define a property index on a subtree you have to add an <code>oak:index<code>
node.
+ * 
+ * Under it follows the index definition node that:
+ * <ul>
+ * <li>must be of type <code>oak:queryIndexDefinition</code></li>
+ * <li>must have the <code>type</code> property set to <b><code>property</code></b></li>
+ * <li>contains the <code>propertyNames<code> property that indicates what
property will be stored in the index</li>
+ * </ul>
+ * </p>
+ * <p>
+ * Optionally you can specify the uniqueness constraint on a property index by
+ * setting the <code>unique</code> flag to <code>true</code>.
  * </p>
  * 
  * <p>
- * <code>propertyNames<code> can be a list of properties, and it is optional.in
case it is missing, the node name will be used as a property name reference value
+ * Note: <code>propertyNames<code> can be a list of properties, and it is optional.in
case it is missing, the node name will be used as a property name reference value
  * </p>
  * 
  * <p>
- * Optionally you can specify the uniqueness constraint on a property index by
- * setting the <code>unique</code> flag to true.
+ * Note: <code>reindex<code> is a property that when set to <code>true</code>,
triggers a full content reindex.
  * </p>
  * 
  * <pre>
@@ -63,12 +70,15 @@ import com.google.common.collect.Sets;
  *     NodeBuilder index = root.child("oak:index");
  *     index.child("uuid")
  *         .setProperty("jcr:primaryType", "oak:queryIndexDefinition", Type.NAME)
+ *         .setProperty("type", "property")
  *         .setProperty("propertyNames", "jcr:uuid")
- *         .setProperty("unique", true);
+ *         .setProperty("unique", true)
+ *         .setProperty("reindex", true);
  * }
  * </code>
  * </pre>
  * 
+ * @see QueryIndex
  * @see PropertyIndexLookup
  */
 public class PropertyIndex implements QueryIndex {

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexHookProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexHookProvider.java?rev=1402088&r1=1402087&r2=1402088&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexHookProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexHookProvider.java
Thu Oct 25 10:36:35 2012
@@ -18,12 +18,23 @@ package org.apache.jackrabbit.oak.plugin
 
 import java.util.List;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.oak.plugins.index.IndexHook;
 import org.apache.jackrabbit.oak.plugins.index.IndexHookProvider;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 
 import com.google.common.collect.ImmutableList;
 
+/**
+ * Service that provides PropertyIndex based IndexHooks
+ * 
+ * @see PropertyIndexHook
+ * @see IndexHookProvider
+ * 
+ */
+@Component
+@Service(IndexHookProvider.class)
 public class PropertyIndexHookProvider implements IndexHookProvider {
 
     private static final String TYPE = "property";

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexProvider.java?rev=1402088&r1=1402087&r2=1402088&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexProvider.java
Thu Oct 25 10:36:35 2012
@@ -28,6 +28,9 @@ import com.google.common.collect.Immutab
 
 /**
  * A provider for property indexes.
+ * 
+ * @see PropertyIndex
+ * 
  */
 public class PropertyIndexProvider implements QueryIndexProvider {
 



Mime
View raw message