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
This commit is contained in:
Noble Paul 2010-01-05 05:38:27 +00:00
parent fc9a0a78c9
commit ca76f3b50c
2 changed files with 15 additions and 14 deletions

View File

@ -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 * 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) 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 Optimizations
---------------------- ----------------------

View File

@ -57,19 +57,17 @@ public class PluginInfo {
} }
private List<PluginInfo> loadSubPlugins(Node node) { private List<PluginInfo> loadSubPlugins(Node node) {
List<PluginInfo> children = null; List<PluginInfo> children = new ArrayList<PluginInfo>();
try { //if there is another sub tag with a non namedlist tag that has to be another plugin
//if there is another sub tag with a 'class' attribute that has to be another plugin NodeList nlst = node.getChildNodes();
NodeList nodes = (NodeList) Config.xpathFactory.newXPath().evaluate("*[@class]",node, XPathConstants.NODESET); for (int i = 0; i < nlst.getLength(); i++) {
if(nodes.getLength() > 0){ Node nd = nlst.item(i);
children = new ArrayList<PluginInfo>(nodes.getLength()); if (nd.getNodeType() != Node.ELEMENT_NODE) continue;
for (int i=0; i<nodes.getLength(); i++) { if (NL_TAGS.contains(nd.getNodeName())) continue;
PluginInfo pluginInfo = new PluginInfo(nodes.item(i), null, false, false); PluginInfo pluginInfo = new PluginInfo(nd, null, false, false);
if (pluginInfo.isEnabled()) children.add(pluginInfo); if (pluginInfo.isEnabled()) children.add(pluginInfo);
} }
} return children.isEmpty() ? Collections.<PluginInfo>emptyList() : unmodifiableList(children);
} catch (XPathExpressionException e) { }
return children == null ? Collections.<PluginInfo>emptyList(): unmodifiableList(children);
} }
@Override @Override
@ -102,4 +100,5 @@ public class PluginInfo {
for (PluginInfo child : children) if(type.equals(child.type)) result.add(child); for (PluginInfo child : children) if(type.equals(child.type)) result.add(child);
return result; return result;
} }
private static final HashSet<String> NL_TAGS = new HashSet<String>(Arrays.asList("lst","str","int","bool","arr","float","double"));
} }