jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1449691 - in /jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr: ./ index/ query/
Date Mon, 25 Feb 2013 13:02:12 GMT
Author: tommaso
Date: Mon Feb 25 13:02:12 2013
New Revision: 1449691

URL: http://svn.apache.org/r1449691
Log:
OAK-651 - added OakSolrUtils method to adapt existing service providers from bundle context,
removed HookFactory, added constructor to providers to be eventually instantiated directly

Removed:
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/DefaultSolrHookFactory.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrHookFactory.java
Modified:
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrUtils.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookProvider.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrUtils.java?rev=1449691&r1=1449690&r2=1449691&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrUtils.java
Mon Feb 25 13:02:12 2013
@@ -19,8 +19,15 @@ package org.apache.jackrabbit.oak.plugin
 import java.io.IOException;
 import javax.annotation.Nonnull;
 
+import org.apache.jackrabbit.oak.plugins.index.IndexHookProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexHookProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider;
+import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.SolrServerException;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleReference;
+import org.osgi.framework.ServiceReference;
 
 /**
  * Utilities for Oak Solr integration.
@@ -38,4 +45,30 @@ public class OakSolrUtils {
     public static boolean checkServerAlive(@Nonnull SolrServer solrServer) throws IOException,
SolrServerException {
         return solrServer.ping().getStatus() == 0;
     }
+
+    /**
+     * adapts the OSGi Solr {@link IndexHookProvider} service
+     *
+     * @return a {@link SolrIndexHookProvider}
+     */
+    public static IndexHookProvider adaptOsgiIndexHookProvider() {
+        BundleContext ctx = BundleReference.class.cast(SolrIndexHookProvider.class
+                .getClassLoader()).getBundle().getBundleContext();
+
+        ServiceReference serviceReference = ctx.getServiceReference(SolrIndexHookProvider.class.getName());
+        return SolrIndexHookProvider.class.cast(ctx.getService(serviceReference));
+    }
+
+    /**
+     * adapts the OSGi Solr {@link QueryIndexProvider} service
+     *
+     * @return a {@link SolrQueryIndexProvider}
+     */
+    public static QueryIndexProvider adaptOsgiQueryIndexProvider() {
+        BundleContext ctx = BundleReference.class.cast(SolrQueryIndexProvider.class
+                .getClassLoader()).getBundle().getBundleContext();
+
+        ServiceReference serviceReference = ctx.getServiceReference(SolrQueryIndexProvider.class.getName());
+        return SolrQueryIndexProvider.class.cast(ctx.getService(serviceReference));
+    }
 }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookProvider.java?rev=1449691&r1=1449690&r2=1449691&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookProvider.java
Mon Feb 25 13:02:12 2013
@@ -21,9 +21,13 @@ import javax.annotation.Nonnull;
 
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.ReferencePolicyOption;
 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.plugins.index.solr.OakSolrConfigurationProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.SolrServerProvider;
 import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.slf4j.Logger;
@@ -40,11 +44,22 @@ import com.google.common.collect.Immutab
 @Service(IndexHookProvider.class)
 public class SolrIndexHookProvider implements IndexHookProvider {
 
-    @Reference
-    private SolrHookFactory hookFactory;
-
     private final Logger log = LoggerFactory.getLogger(SolrIndexHookProvider.class);
 
+    @Reference(policyOption = ReferencePolicyOption.GREEDY, policy = ReferencePolicy.STATIC)
+    private SolrServerProvider solrServerProvider;
+
+    @Reference(policyOption = ReferencePolicyOption.GREEDY, policy = ReferencePolicy.STATIC)
+    private OakSolrConfigurationProvider oakSolrConfigurationProvider;
+
+    public SolrIndexHookProvider() {
+    }
+
+    public SolrIndexHookProvider(SolrServerProvider solrServerProvider, OakSolrConfigurationProvider
oakSolrConfigurationProvider) {
+        this.solrServerProvider = solrServerProvider;
+        this.oakSolrConfigurationProvider = oakSolrConfigurationProvider;
+    }
+
     @Override
     @Nonnull
     public List<? extends IndexHook> getIndexHooks(String type, NodeBuilder builder)
{
@@ -53,7 +68,7 @@ public class SolrIndexHookProvider imple
                 log.info("Creating a Solr index hook");
             }
             try {
-                IndexHook indexHook = hookFactory.createIndexHook("/", builder);
+                IndexHook indexHook = new SolrIndexDiff(builder, solrServerProvider.getSolrServer(),
oakSolrConfigurationProvider.getConfiguration());
                 return ImmutableList.of(indexHook);
             } catch (Exception e) {
                 log.error("unable to create Solr IndexHook ", e);

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java?rev=1449691&r1=1449690&r2=1449691&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndexProvider.java
Mon Feb 25 13:02:12 2013
@@ -22,6 +22,8 @@ import javax.annotation.Nonnull;
 
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.ReferencePolicyOption;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.oak.plugins.index.IndexDefinition;
 import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfigurationProvider;
@@ -41,14 +43,22 @@ import static org.apache.jackrabbit.oak.
 @Service(QueryIndexProvider.class)
 public class SolrQueryIndexProvider implements QueryIndexProvider {
 
-    private Logger log = LoggerFactory.getLogger(SolrQueryIndexProvider.class);
+    private final Logger log = LoggerFactory.getLogger(SolrQueryIndexProvider.class);
 
-    @Reference
+    @Reference(policyOption = ReferencePolicyOption.GREEDY, policy = ReferencePolicy.STATIC)
     private SolrServerProvider solrServerProvider;
 
-    @Reference
+    @Reference(policyOption = ReferencePolicyOption.GREEDY, policy = ReferencePolicy.STATIC)
     private OakSolrConfigurationProvider oakSolrConfigurationProvider;
 
+    public SolrQueryIndexProvider() {
+    }
+
+    public SolrQueryIndexProvider(OakSolrConfigurationProvider oakSolrConfigurationProvider,
SolrServerProvider solrServerProvider) {
+        this.oakSolrConfigurationProvider = oakSolrConfigurationProvider;
+        this.solrServerProvider = solrServerProvider;
+    }
+
     @Nonnull
     @Override
     public List<? extends QueryIndex> getQueryIndexes(NodeState nodeState) {



Mime
View raw message