From ca76f3b50c786e867d43ffd96e4f6123043434ee Mon Sep 17 00:00:00 2001 From: Noble Paul Date: Tue, 5 Jan 2010 05:38:27 +0000 Subject: [PATCH] SOLR-1697 PluginInfo should load plugins w/o class attribute also git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@895909 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 4 ++- src/java/org/apache/solr/core/PluginInfo.java | 25 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ccada284a14..2dd278b2f9a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -77,7 +77,9 @@ New Features * SOLR-1131: FieldTypes can now output multiple Fields per Type and still be searched. This can be handy for hiding the details of a particular implementation such as in the spatial case. (Chris Mattmann, shalin, noble, gsingers, yonik) -* SOLR-1586: Add support for Geohash and Spatial Tile FieldType (Chris Mattmann, gsingers) +* SOLR-1586: Add support for Geohash and Spatial Tile FieldType (Chris Mattmann, gsingers) + +* SOLR-1697: PluginInfo should load plugins w/o class attribute also (noble) Optimizations ---------------------- diff --git a/src/java/org/apache/solr/core/PluginInfo.java b/src/java/org/apache/solr/core/PluginInfo.java index 87e18978377..0bb6c59b1b0 100644 --- a/src/java/org/apache/solr/core/PluginInfo.java +++ b/src/java/org/apache/solr/core/PluginInfo.java @@ -57,19 +57,17 @@ public class PluginInfo { } private List loadSubPlugins(Node node) { - List children = null; - try { - //if there is another sub tag with a 'class' attribute that has to be another plugin - NodeList nodes = (NodeList) Config.xpathFactory.newXPath().evaluate("*[@class]",node, XPathConstants.NODESET); - if(nodes.getLength() > 0){ - children = new ArrayList(nodes.getLength()); - for (int i=0; iemptyList(): unmodifiableList(children); + List children = new ArrayList(); + //if there is another sub tag with a non namedlist tag that has to be another plugin + NodeList nlst = node.getChildNodes(); + for (int i = 0; i < nlst.getLength(); i++) { + Node nd = nlst.item(i); + if (nd.getNodeType() != Node.ELEMENT_NODE) continue; + if (NL_TAGS.contains(nd.getNodeName())) continue; + PluginInfo pluginInfo = new PluginInfo(nd, null, false, false); + if (pluginInfo.isEnabled()) children.add(pluginInfo); + } + return children.isEmpty() ? Collections.emptyList() : unmodifiableList(children); } @Override @@ -102,4 +100,5 @@ public class PluginInfo { for (PluginInfo child : children) if(type.equals(child.type)) result.add(child); return result; } + private static final HashSet NL_TAGS = new HashSet(Arrays.asList("lst","str","int","bool","arr","float","double")); }