jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1464955 - in /jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded: ./ osgi/
Date Fri, 05 Apr 2013 12:41:01 GMT
Author: tommaso
Date: Fri Apr  5 12:41:00 2013
New Revision: 1464955

URL: http://svn.apache.org/r1464955
Log:
OAK-735 - services moved to osgi package (not exported)

Added:
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/EmbeddedSolrProviderService.java
  (with props)
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/OsgiSolrServerConfigurationProvider.java
  (with props)
Removed:
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrProviderService.java
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OsgiSolrServerConfigurationProvider.java

Added: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/EmbeddedSolrProviderService.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/EmbeddedSolrProviderService.java?rev=1464955&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/EmbeddedSolrProviderService.java
(added)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/EmbeddedSolrProviderService.java
Fri Apr  5 12:41:00 2013
@@ -0,0 +1,85 @@
+/*
+ * 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.embedded.osgi;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.felix.scr.annotations.Services;
+import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration;
+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.embedded.DefaultOakSolrProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.embedded.EmbeddedSolrConfigurationProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.embedded.SolrServerConfigurationProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.embedded.UpToDateNodeStateConfiguration;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.solr.client.solrj.SolrServer;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * OSGi service for the embedded Solr server module.
+ */
+@Component
+@Services({
+        @Service(value = SolrServerProvider.class),
+        @Service(value = OakSolrConfigurationProvider.class)
+})
+public class EmbeddedSolrProviderService implements SolrServerProvider, OakSolrConfigurationProvider
{
+
+
+    @Property(value = "/oak:index/solrIdx", name = "configuration path",
+            description = "path to node holding Solr configuration")
+    private static final String CONFIGURATION_PATH = "solr.configuration.node.path";
+
+    @Reference
+    private NodeStore nodeStore;
+
+    @Reference
+    private SolrServerConfigurationProvider solrServerConfigurationProvider;
+
+    private OakSolrConfigurationProvider oakSolrConfigurationProvider;
+
+    private SolrServerProvider solrServerProvider;
+
+    @Activate
+    public void activate(ComponentContext context) throws Exception {
+        try {
+            // try reading configuration from the configured repository path
+            UpToDateNodeStateConfiguration nodeStateConfiguration = new UpToDateNodeStateConfiguration(nodeStore,
String.valueOf(
+                    context.getProperties().get(CONFIGURATION_PATH)));
+            solrServerProvider = new DefaultOakSolrProvider(nodeStateConfiguration.getSolrServerConfiguration());
+            oakSolrConfigurationProvider = new EmbeddedSolrConfigurationProvider(nodeStateConfiguration);
+        } catch (Exception e) {
+            // use the default config and the OSGi based server configuration
+            solrServerProvider = new DefaultOakSolrProvider(solrServerConfigurationProvider.getSolrServerConfiguration());
+            oakSolrConfigurationProvider = new EmbeddedSolrConfigurationProvider();
+        }
+    }
+
+    @Override
+    public OakSolrConfiguration getConfiguration() {
+        return oakSolrConfigurationProvider.getConfiguration();
+    }
+
+    @Override
+    public SolrServer getSolrServer() throws Exception {
+        return solrServerProvider.getSolrServer();
+    }
+}

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

Added: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/OsgiSolrServerConfigurationProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/OsgiSolrServerConfigurationProvider.java?rev=1464955&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/OsgiSolrServerConfigurationProvider.java
(added)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/OsgiSolrServerConfigurationProvider.java
Fri Apr  5 12:41:00 2013
@@ -0,0 +1,94 @@
+/*
+ * 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.embedded.osgi;
+
+import java.io.File;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.oak.plugins.index.solr.embedded.SolrServerConfiguration;
+import org.apache.jackrabbit.oak.plugins.index.solr.embedded.SolrServerConfigurationDefaults;
+import org.apache.jackrabbit.oak.plugins.index.solr.embedded.SolrServerConfigurationProvider;
+import org.apache.solr.client.solrj.SolrServer;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * An OSGi service {@link SolrServerConfigurationProvider}
+ */
+@Component
+@Service(value = SolrServerConfigurationProvider.class)
+public class OsgiSolrServerConfigurationProvider implements SolrServerConfigurationProvider
{
+
+    @Property(value = SolrServerConfigurationDefaults.SOLR_HOME_PATH)
+    private static final String SOLR_HOME_PATH = "solr.home.path";
+
+    @Property(value = SolrServerConfigurationDefaults.CORE_NAME)
+    private static final String SOLR_CORE_NAME = "solr.core.name";
+
+    @Property(value = SolrServerConfigurationDefaults.SOLR_CONFIG_PATH)
+    private static final String SOLR_CONFIG_FILE = "solr.config.path";
+
+    @Property(value = SolrServerConfigurationDefaults.HTTP_PORT)
+    private static final String SOLR_HTTP_PORT = "solr.http.port";
+
+    private static SolrServer solrServer;
+
+    private String solrHome;
+    private String solrConfigFile;
+    private String solrCoreName;
+
+    private Integer solrHttpPort;
+
+    private SolrServerConfiguration solrServerConfiguration;
+
+
+    @Activate
+    protected void activate(ComponentContext componentContext) throws Exception {
+        solrHome = String.valueOf(componentContext.getProperties().get(SOLR_HOME_PATH));
+        File file = new File(solrHome);
+        if (!file.exists()) {
+            assert file.createNewFile();
+        }
+        solrConfigFile = String.valueOf(componentContext.getProperties().get(SOLR_CONFIG_FILE));
+        solrCoreName= String.valueOf(componentContext.getProperties().get(SOLR_CORE_NAME));
+
+        solrHttpPort = Integer.valueOf(String.valueOf(componentContext.getProperties().get(SOLR_HTTP_PORT)));
+        // TODO : add the possibility to inject solrconfig and schema files
+
+        solrServerConfiguration = new SolrServerConfiguration(solrHome, solrConfigFile, solrCoreName);
+    }
+
+    @Deactivate
+    protected void deactivate() throws Exception {
+        solrHome = null;
+        solrHttpPort = null;
+        solrConfigFile = null;
+        solrCoreName = null;
+        if (solrServer != null) {
+            solrServer.shutdown();
+            solrServer = null;
+        }
+    }
+
+    @Override
+    public SolrServerConfiguration getSolrServerConfiguration() {
+        return solrServerConfiguration;
+    }
+}

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



Mime
View raw message