jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1530879 - in /jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr: index/ osgi/ query/
Date Thu, 10 Oct 2013 08:51:32 GMT
Author: tommaso
Date: Thu Oct 10 08:51:31 2013
New Revision: 1530879

URL: http://svn.apache.org/r1530879
Log:
OAK-1079 - created separate osgi services for SolrQueryIndexProvider and SolrIndexEditorProvider

Added:
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java
  (with props)
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java
  (with props)
Modified:
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorProvider.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/index/SolrIndexEditorProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorProvider.java?rev=1530879&r1=1530878&r2=1530879&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditorProvider.java
Thu Oct 10 08:51:31 2013
@@ -16,37 +16,29 @@
  */
 package org.apache.jackrabbit.oak.plugins.index.solr.index;
 
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
 import org.apache.jackrabbit.oak.api.CommitFailedException;
-import org.apache.jackrabbit.oak.plugins.index.IndexEditor;
 import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
-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.configuration.OakSolrConfigurationProvider;
 import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndex;
+import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
 import org.apache.jackrabbit.oak.spi.commit.Editor;
 import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
 import org.apache.jackrabbit.oak.spi.state.NodeState;
-
-import static org.apache.felix.scr.annotations.ReferencePolicy.STATIC;
-import static org.apache.felix.scr.annotations.ReferencePolicyOption.GREEDY;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * Service that provides Lucene based {@link IndexEditor}s
- * 
+ * Solr based {@link IndexEditorProvider}
+ *
  * @see SolrIndexEditor
- * @see IndexEditorProvider
- * 
+ *
  */
-@Component
-@Service(IndexEditorProvider.class)
 public class SolrIndexEditorProvider implements IndexEditorProvider {
 
-    @Reference(policyOption = GREEDY, policy = STATIC)
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
     private SolrServerProvider solrServerProvider;
 
-    @Reference(policyOption = GREEDY, policy = STATIC)
     private OakSolrConfigurationProvider oakSolrConfigurationProvider;
 
     public SolrIndexEditorProvider(
@@ -56,27 +48,29 @@ public class SolrIndexEditorProvider imp
         this.oakSolrConfigurationProvider = oakSolrConfigurationProvider;
     }
 
-    public SolrIndexEditorProvider() {
-    }
-
     @Override
     public Editor getIndexEditor(
             String type, NodeBuilder definition, NodeState root)
             throws CommitFailedException {
+
         if (SolrQueryIndex.TYPE.equals(type)
-                && solrServerProvider != null
-                && oakSolrConfigurationProvider != null) {
+                && isConfigurationOk()) {
             try {
                 return new SolrIndexEditor(
                         definition,
                         solrServerProvider.getSolrServer(),
                         oakSolrConfigurationProvider.getConfiguration());
             } catch (Exception e) {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
+                if (log.isErrorEnabled()) {
+                    log.error("unable to create SolrIndexEditor", e);
+                }
             }
         }
         return null;
     }
 
+    private boolean isConfigurationOk() {
+        return solrServerProvider != null && oakSolrConfigurationProvider != null;
+    }
+
 }

Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java?rev=1530879&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java
(added)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java
Thu Oct 10 08:51:31 2013
@@ -0,0 +1,68 @@
+/*
+ * 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.plugins.index.solr.osgi;
+
+import static org.apache.felix.scr.annotations.ReferencePolicy.STATIC;
+import static org.apache.felix.scr.annotations.ReferencePolicyOption.GREEDY;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.oak.api.CommitFailedException;
+import org.apache.jackrabbit.oak.plugins.index.IndexEditor;
+import org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
+import org.apache.jackrabbit.oak.spi.commit.Editor;
+import org.apache.jackrabbit.oak.spi.state.NodeBuilder;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+/**
+ * Osgi Service that provides Solr based {@link org.apache.jackrabbit.oak.plugins.index.IndexEditor}s
+ * 
+ * @see org.apache.jackrabbit.oak.plugins.index.solr.index.SolrIndexEditorProvider
+ * @see org.apache.jackrabbit.oak.plugins.index.IndexEditorProvider
+ */
+@Component(metatype = false, immediate = true)
+@Service(value = IndexEditorProvider.class)
+public class SolrIndexEditorProviderService implements IndexEditorProvider {
+    
+    @Reference(policyOption = GREEDY, policy = STATIC)
+    private SolrServerProvider solrServerProvider;
+
+    @Reference(policyOption = GREEDY, policy = STATIC)
+    private OakSolrConfigurationProvider oakSolrConfigurationProvider;
+
+    private SolrIndexEditorProvider solrIndexEditorProvider;
+
+    @Override
+    @CheckForNull
+    public Editor getIndexEditor(@Nonnull String type, @Nonnull NodeBuilder definition, 
+                    @Nonnull NodeState root) throws CommitFailedException {
+        Editor indexEditor = null;
+        if (solrServerProvider != null && oakSolrConfigurationProvider != null &&
solrIndexEditorProvider == null) {
+            solrIndexEditorProvider = new SolrIndexEditorProvider(solrServerProvider, oakSolrConfigurationProvider);
+            indexEditor = solrIndexEditorProvider.getIndexEditor(type, definition, root);
+        }
+        return indexEditor;
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrIndexEditorProviderService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java?rev=1530879&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java
(added)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java
Thu Oct 10 08:51:31 2013
@@ -0,0 +1,51 @@
+package org.apache.jackrabbit.oak.plugins.index.solr.osgi;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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.solr.configuration.OakSolrConfigurationProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
+import org.apache.jackrabbit.oak.spi.query.QueryIndex;
+import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+/**
+ * Osgi Service that provides Solr based {@link org.apache.jackrabbit.oak.spi.query.QueryIndex}es
+ * 
+ * @see org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider
+ * @see QueryIndexProviderr
+ */
+@Component(metatype = false, immediate = true)
+@Service(value = QueryIndexProvider.class)
+public class SolrQueryIndexProviderService implements QueryIndexProvider {
+
+    @Reference(policyOption = ReferencePolicyOption.GREEDY, policy = ReferencePolicy.STATIC)
+    private SolrServerProvider solrServerProvider;
+
+    @Reference(policyOption = ReferencePolicyOption.GREEDY, policy = ReferencePolicy.STATIC)
+    private OakSolrConfigurationProvider oakSolrConfigurationProvider;
+
+    private SolrQueryIndexProvider solrQueryIndexProvider;
+
+    @Override
+    @Nonnull
+    public List<? extends QueryIndex> getQueryIndexes(NodeState nodeState) {
+        List<? extends QueryIndex> queryIndexes = new ArrayList<QueryIndex>();
+        if (solrServerProvider != null && oakSolrConfigurationProvider != null
+                        && solrQueryIndexProvider == null) {
+            solrQueryIndexProvider = new SolrQueryIndexProvider(solrServerProvider,
+                            oakSolrConfigurationProvider);
+            queryIndexes = solrQueryIndexProvider.getQueryIndexes(nodeState);
+        }
+        return queryIndexes;
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/osgi/SolrQueryIndexProviderService.java
------------------------------------------------------------------------------
    svn:eol-style = native

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=1530879&r1=1530878&r2=1530879&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
Thu Oct 10 08:51:31 2013
@@ -21,17 +21,13 @@ import static org.apache.jackrabbit.oak.
 
 import java.util.ArrayList;
 import java.util.List;
+
 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.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Type;
-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.configuration.OakSolrConfigurationProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider;
 import org.apache.jackrabbit.oak.spi.query.QueryIndex;
 import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider;
 import org.apache.jackrabbit.oak.spi.state.ChildNodeEntry;
@@ -42,21 +38,14 @@ import org.slf4j.LoggerFactory;
 /**
  * {@link QueryIndexProvider} for {@link SolrQueryIndex}
  */
-@Component
-@Service(QueryIndexProvider.class)
 public class SolrQueryIndexProvider implements QueryIndexProvider {
 
     private final Logger log = LoggerFactory.getLogger(SolrQueryIndexProvider.class);
 
-    @Reference(policyOption = ReferencePolicyOption.GREEDY, policy = ReferencePolicy.STATIC)
     private SolrServerProvider solrServerProvider;
 
-    @Reference(policyOption = ReferencePolicyOption.GREEDY, policy = ReferencePolicy.STATIC)
     private OakSolrConfigurationProvider oakSolrConfigurationProvider;
 
-    public SolrQueryIndexProvider() {
-    }
-
     public SolrQueryIndexProvider(SolrServerProvider solrServerProvider, OakSolrConfigurationProvider
oakSolrConfigurationProvider) {
         this.oakSolrConfigurationProvider = oakSolrConfigurationProvider;
         this.solrServerProvider = solrServerProvider;
@@ -65,6 +54,7 @@ public class SolrQueryIndexProvider impl
     @Nonnull
     @Override
     public List<? extends QueryIndex> getQueryIndexes(NodeState nodeState) {
+
         List<QueryIndex> tempIndexes = new ArrayList<QueryIndex>();
         if (solrServerProvider == null || oakSolrConfigurationProvider == null) {
             return tempIndexes;
@@ -75,7 +65,9 @@ public class SolrQueryIndexProvider impl
             PropertyState type = definition.getProperty(TYPE_PROPERTY_NAME);
             if (type != null
                     && SolrQueryIndex.TYPE.equals(type.getValue(Type.STRING))) {
-                log.debug("found a Solr index definition {}", entry.getName());
+                if (log.isDebugEnabled()) {
+                    log.debug("found a Solr index definition {}", entry.getName());
+                }
             }
             try {
                 tempIndexes.add(new SolrQueryIndex(
@@ -83,10 +75,13 @@ public class SolrQueryIndexProvider impl
                         solrServerProvider.getSolrServer(),
                         oakSolrConfigurationProvider.getConfiguration()));
             } catch (Exception e) {
-                log.error("unable to create Solr query index at " + entry.getName(), e);
+                if (log.isErrorEnabled()) {
+                    log.error("unable to create Solr query index at " + entry.getName(),
e);
+                }
             }
-            
+
         }
         return tempIndexes;
     }
+
 }



Mime
View raw message