Apache Lucene open-source search software
LUCENE-4044: get solr tests working
Robert Muir0e80c044b2f9
diff --git a/dev-tools/eclipse/dot.classpath b/dev-tools/eclipse/dot.classpathindex d90cec4c88d..05b121717dd 100644--- a/dev-tools/eclipse/dot.classpath+++ b/dev-tools/eclipse/dot.classpath@@ -17,28 +17,28 @@<classpathentry kind="src" path="lucene/test-framework/src/java"/><classpathentry kind="src" output="bin.tests-framework" path="lucene/test-framework/src/resources"/><classpathentry kind="src" path="lucene/analysis/common/src/java"/>- <classpathentry kind="src" path="lucene/analysis/common/src/resources"/>+ <classpathentry kind="src" output="bin.analysis-common" path="lucene/analysis/common/src/resources"/><classpathentry kind="src" path="lucene/analysis/common/src/test"/><classpathentry kind="src" path="lucene/analysis/icu/src/java"/>- <classpathentry kind="src" path="lucene/analysis/icu/src/resources"/>+ <classpathentry kind="src" output="bin.analysis-icu" path="lucene/analysis/icu/src/resources"/><classpathentry kind="src" path="lucene/analysis/icu/src/test"/><classpathentry kind="src" path="lucene/analysis/kuromoji/src/java"/>- <classpathentry kind="src" path="lucene/analysis/kuromoji/src/resources"/>+ <classpathentry kind="src" output="bin.analysis-kuromoji" path="lucene/analysis/kuromoji/src/resources"/><classpathentry kind="src" path="lucene/analysis/kuromoji/src/test"/><classpathentry kind="src" path="lucene/analysis/phonetic/src/java"/>- <classpathentry kind="src" path="lucene/analysis/phonetic/src/resources"/>+ <classpathentry kind="src" output="bin.analysis-phonetic" path="lucene/analysis/phonetic/src/resources"/><classpathentry kind="src" path="lucene/analysis/phonetic/src/test"/><classpathentry kind="src" path="lucene/analysis/smartcn/src/java"/>- <classpathentry kind="src" path="lucene/analysis/smartcn/src/resources"/>+ <classpathentry kind="src" output="bin.analysis-smartcn" path="lucene/analysis/smartcn/src/resources"/><classpathentry kind="src" path="lucene/analysis/smartcn/src/test"/><classpathentry kind="src" path="lucene/analysis/stempel/src/java"/>- <classpathentry kind="src" path="lucene/analysis/stempel/src/resources"/>+ <classpathentry kind="src" output="bin.analysis-stempel" path="lucene/analysis/stempel/src/resources"/><classpathentry kind="src" path="lucene/analysis/stempel/src/test"/><classpathentry kind="src" path="lucene/analysis/morfologik/src/java"/>- <classpathentry kind="src" path="lucene/analysis/morfologik/src/resources"/>+ <classpathentry kind="src" output="bin.analysis-morfologik" path="lucene/analysis/morfologik/src/resources"/><classpathentry kind="src" path="lucene/analysis/morfologik/src/test"/><classpathentry kind="src" path="lucene/analysis/uima/src/java"/>- <classpathentry kind="src" path="lucene/analysis/uima/src/resources"/>+ <classpathentry kind="src" output="bin.analysis-uima" path="lucene/analysis/uima/src/resources"/><classpathentry kind="src" path="lucene/analysis/uima/src/test"/><classpathentry kind="src" path="lucene/benchmark/src/java"/><classpathentry kind="src" path="lucene/benchmark/src/test"/>diff --git a/solr/core/src/java/org/apache/solr/analysis/AnalysisPluginLoader.java b/solr/core/src/java/org/apache/solr/analysis/AnalysisPluginLoader.javanew file mode 100644index 00000000000..097aedf0049--- /dev/null+++ b/solr/core/src/java/org/apache/solr/analysis/AnalysisPluginLoader.java@@ -0,0 +1,62 @@+package org.apache.solr.analysis;++import java.util.regex.Matcher;+import java.util.regex.Pattern;++import org.apache.lucene.analysis.util.AbstractAnalysisFactory;+import org.apache.lucene.analysis.util.ResourceLoader;+import org.apache.solr.util.plugin.AbstractPluginLoader;+import org.w3c.dom.Node;++/*+ * 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.+ */++public abstract class AnalysisPluginLoader<S extends AbstractAnalysisFactory> extends AbstractPluginLoader<S> {++ public AnalysisPluginLoader(String type, Class<S> pluginClassType, boolean preRegister, boolean requireName) {+ super(type, pluginClassType, preRegister, requireName);+ }++ public AnalysisPluginLoader(String type, Class<S> pluginClassType) {+ super(type, pluginClassType);+ }++ @Override+ protected S create(ResourceLoader loader, String name, String className, Node node) throws Exception {+ S instance = null;+ Matcher m = legacyPattern.matcher(className);+ if (m.matches()) {+ try {+ instance = createSPI(m.group(4));+ } catch (IllegalArgumentException ex) {+ // ok+ }+ }++ if (instance != null) {+ // necessary because SolrResourceLoader manages its own list of 'awaiting ResourceLoaderAware'+ className = instance.getClass().getName();+ }++ return super.create(loader, name, className, node);+ }++ private static final Pattern legacyPattern =+ Pattern.compile("((org\\.apache\\.solr\\.analysis\\.)|(solr\\.))([\\p{L}_$][\\p{L}\\p{N}_$]+?)(TokenFilter|Filter|Tokenizer|CharFilter)Factory");++ protected abstract S createSPI(String name);+}diff --git a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.javaindex 5c2073ff16f..ebfee2ff05f 100644--- a/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java+++ b/solr/core/src/java/org/apache/solr/schema/FieldTypePluginLoader.java@@ -22,6 +22,7 @@ import org.apache.lucene.analysis.core.KeywordAnalyzer;import org.apache.lucene.analysis.core.KeywordTokenizerFactory;import org.apache.lucene.analysis.util.*;import org.apache.lucene.util.Version;+import org.apache.solr.analysis.AnalysisPluginLoader;import org.apache.solr.analysis.TokenizerChain;import org.apache.solr.common.SolrException;import org.apache.solr.util.DOMUtil;@@ -262,10 +263,15 @@ public final class FieldTypePluginLoaderfinal ArrayList<CharFilterFactory> charFilters= new ArrayList<CharFilterFactory>();- AbstractPluginLoader<CharFilterFactory> charFilterLoader =- new AbstractPluginLoader<CharFilterFactory>+ AnalysisPluginLoader<CharFilterFactory> charFilterLoader =+ new AnalysisPluginLoader<CharFilterFactory>("[schema.xml] analyzer/charFilter", CharFilterFactory.class, false, false) {+ @Override+ protected CharFilterFactory createSPI(String name) {+ return CharFilterFactory.forName(name);+ }+@Overrideprotected void init(CharFilterFactory plugin, Node node) throws Exception {if( plugin != null ) {@@ -295,9 +301,15 @@ public final class FieldTypePluginLoaderfinal ArrayList<TokenizerFactory> tokenizers= new ArrayList<TokenizerFactory>(1);- AbstractPluginLoader<TokenizerFactory> tokenizerLoader =- new AbstractPluginLoader<TokenizerFactory>+ AnalysisPluginLoader<TokenizerFactory> tokenizerLoader =+ new AnalysisPluginLoader<TokenizerFactory>("[schema.xml] analyzer/tokenizer", TokenizerFactory.class, false, false) {++ @Override+ protected TokenizerFactory createSPI(String name) {+ return TokenizerFactory.forName(name);+ }+@Overrideprotected void init(TokenizerFactory plugin, Node node) throws Exception {if( !tokenizers.isEmpty() ) {@@ -332,9 +344,15 @@ public final class FieldTypePluginLoaderfinal ArrayList<TokenFilterFactory> filters= new ArrayList<TokenFilterFactory>();- AbstractPluginLoader<TokenFilterFactory> filterLoader =- new AbstractPluginLoader<TokenFilterFactory>("[schema.xml] analyzer/filter", TokenFilterFactory.class, false, false)+ AnalysisPluginLoader<TokenFilterFactory> filterLoader =+ new AnalysisPluginLoader<TokenFilterFactory>("[schema.xml] analyzer/filter", TokenFilterFactory.class, false, false){++ @Override+ protected TokenFilterFactory createSPI(String name) {+ return TokenFilterFactory.forName(name);+ }+@Overrideprotected void init(TokenFilterFactory plugin, Node node) throws Exception {if( plugin != null ) {