Apache Solr open-source search software
SOLR-1385 Add an 'enable' attribute to all plugins
Noble Paul4114447c8f0c
diff --git a/CHANGES.txt b/CHANGES.txtindex 50b2951c6f0..5b4162bb186 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -288,7 +288,9 @@ New Features73. SOLR-1156: Sort TermsComponent results by frequency (Matt Weber via yonik)-74. SOLR-1384 : load core properties from a properties file (noble)+74. SOLR-1335 : load core properties from a properties file (noble)++75. SOLR-1385 : Add an 'enable' attribute to all plugins (noble)Optimizations----------------------diff --git a/src/java/org/apache/solr/core/PluginInfo.java b/src/java/org/apache/solr/core/PluginInfo.javaindex ed96139adc8..68a5fd7551c 100644--- a/src/java/org/apache/solr/core/PluginInfo.java+++ b/src/java/org/apache/solr/core/PluginInfo.java@@ -74,4 +74,9 @@ public class PluginInfo {return sb.toString();}+ public boolean isEnabled(){+ String enable = attributes.get("enable");+ return enable == null || Boolean.parseBoolean(enable);+ }+}diff --git a/src/java/org/apache/solr/core/SolrConfig.java b/src/java/org/apache/solr/core/SolrConfig.javaindex beedf4797dc..24a1d9e9e49 100644--- a/src/java/org/apache/solr/core/SolrConfig.java+++ b/src/java/org/apache/solr/core/SolrConfig.java@@ -231,7 +231,8 @@ public class SolrConfig extends Config {}ArrayList<PluginInfo> result = new ArrayList<PluginInfo>();for (int j=0; j<nl.getLength(); j++) {- result.add(new PluginInfo(nl.item(j) ,"[solrconfig.xml] processor",false));+ PluginInfo pluginInfo = new PluginInfo(nl.item(j), "[solrconfig.xml] processor", false);+ if(pluginInfo.isEnabled()) result.add(pluginInfo);}chains.put(name,result);if(isDefault || nodes.getLength() == 1) chains.put(null,result);@@ -248,7 +249,8 @@ public class SolrConfig extends Config {private PluginInfo loadSinglePlugin(String tag){NodeList nodes = (NodeList) evaluate(tag, XPathConstants.NODESET);for (int i=0; i<nodes.getLength(); i++) {- return new PluginInfo(nodes.item(i) ,"[solrconfig.xml] "+tag,false);+ PluginInfo pluginInfo = new PluginInfo(nodes.item(i), "[solrconfig.xml] " + tag, false);+ return pluginInfo.isEnabled() ? pluginInfo : null;}return null;}@@ -257,7 +259,8 @@ public class SolrConfig extends Config {ArrayList<PluginInfo> result = new ArrayList<PluginInfo>();NodeList nodes = (NodeList) evaluate(tag, XPathConstants.NODESET);for (int i=0; i<nodes.getLength(); i++) {- result.add(new PluginInfo(nodes.item(i) ,"[solrconfig.xml] "+tag,requireName));+ PluginInfo pluginInfo = new PluginInfo(nodes.item(i), "[solrconfig.xml] " + tag, requireName);+ if(pluginInfo.isEnabled()) result.add(pluginInfo);}return result.isEmpty() ?Collections.<PluginInfo>emptyList() :diff --git a/src/test/org/apache/solr/TestPluginEnable.java b/src/test/org/apache/solr/TestPluginEnable.javanew file mode 100644index 00000000000..3a514725735--- /dev/null+++ b/src/test/org/apache/solr/TestPluginEnable.java@@ -0,0 +1,33 @@+package org.apache.solr;++import org.apache.solr.client.solrj.SolrServerException;+import org.apache.solr.util.AbstractSolrTestCase;++/**+ * <p> Test disabling components</p>+ * @version $Id:$+ * @since solr 1.4+ */+public class TestPluginEnable extends AbstractSolrTestCase {+++ public void testSimple() throws SolrServerException {+ assertNull( h.getCore().getRequestHandler("disabled"));+ assertNotNull( h.getCore().getRequestHandler("enabled"));++ }+++++ @Override+ public String getSchemaFile() {+ return "schema-replication1.xml";+ }++ @Override+ public String getSolrConfigFile() {+ return "solrconfig-enableplugin.xml";+ }++}diff --git a/src/test/test-files/solr/conf/solrconfig-enableplugin.xml b/src/test/test-files/solr/conf/solrconfig-enableplugin.xmlnew file mode 100644index 00000000000..419d999c89b--- /dev/null+++ b/src/test/test-files/solr/conf/solrconfig-enableplugin.xml@@ -0,0 +1,84 @@+<?xml version="1.0" ?>++<!--+ 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.+-->++<!-- $Id: solrconfig-slave.xml 741684 2009-02-06 19:21:44Z shalin $+ $Source$+ $Name$+ -->++<config>++ <dataDir>${solr.data.dir:./solr/data}</dataDir>++ <indexDefaults>+ <useCompoundFile>false</useCompoundFile>+ <mergeFactor>10</mergeFactor>+ <ramBufferSizeMB>32</ramBufferSizeMB>+ <maxMergeDocs>2147483647</maxMergeDocs>+ <maxFieldLength>10000</maxFieldLength>+ <writeLockTimeout>1000</writeLockTimeout>+ <commitLockTimeout>10000</commitLockTimeout>++ <writeLockTimeout>1000</writeLockTimeout>+ <commitLockTimeout>10000</commitLockTimeout>++ <lockType>single</lockType>+ </indexDefaults>++ <mainIndex>+ <useCompoundFile>false</useCompoundFile>+ <mergeFactor>10</mergeFactor>+ <ramBufferSizeMB>32</ramBufferSizeMB>+ <maxMergeDocs>2147483647</maxMergeDocs>+ <maxFieldLength>10000</maxFieldLength>++ <unlockOnStartup>true</unlockOnStartup>+ </mainIndex>++ <updateHandler class="solr.DirectUpdateHandler2">+ </updateHandler>++ <requestHandler name="standard" class="solr.StandardRequestHandler">+ <bool name="httpCaching">true</bool>+ </requestHandler>++ <!-- test query parameter defaults -->+ <requestHandler name="defaults" class="solr.StandardRequestHandler">++ </requestHandler>++ <requestHandler name="disabled" class="solr.StandardRequestHandler" enable="false"/>+ <requestHandler name="enabled" class="solr.StandardRequestHandler" enable="true"/>+++ <!-- test query parameter defaults -->+ <requestHandler name="lazy" class="solr.StandardRequestHandler" startup="lazy">+ </requestHandler>++ <requestHandler name="/update" class="solr.XmlUpdateRequestHandler"/>++ <!-- enable streaming for testing... -->+ <requestDispatcher handleSelect="true">+ <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048"/>+ <httpCaching lastModifiedFrom="openTime" etagSeed="Solr" never304="false">+ <cacheControl>max-age=30, public</cacheControl>+ </httpCaching>+ </requestDispatcher>++</config>