diff --git a/CHANGES.txt b/CHANGES.txt index 9f1a70ceff1..4352a9e887d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -557,7 +557,9 @@ Bug Fixes (Uri Boness, yonik) -66. SOLR-1381: Fixed improper handling of fields that have only term positions and not term offsets during Highlighting (Thorsten Fischer, gsingers) +66. SOLR-1381: Fixed improper handling of fields that have only term positions and not term offsets during Highlighting (Thorsten Fischer, gsingers) + +67. SOLR-1427: Fixed registry.jsp issue with MBeans (gsingers) Other Changes ---------------------- diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.java index 3827ef99153..8a6233b6324 100644 --- a/src/java/org/apache/solr/core/SolrCore.java +++ b/src/java/org/apache/solr/core/SolrCore.java @@ -574,6 +574,8 @@ public final class SolrCore implements SolrInfoMBean { // Finally tell anyone who wants to know resourceLoader.inform( resourceLoader ); resourceLoader.inform( this ); + //register any SolrInfoMBeans + resourceLoader.inform(infoRegistry); instance = this; // set singleton for backwards compatibility } catch (IOException e) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e); @@ -830,7 +832,11 @@ public final class SolrCore implements SolrInfoMBean { } private void addIfNotPresent(Map registry, String name, Class c){ if(!registry.containsKey(name)){ - registry.put(name, (T) resourceLoader.newInstance(c.getName())); + T searchComp = (T) resourceLoader.newInstance(c.getName()); + registry.put(name, searchComp); + if (searchComp instanceof SolrInfoMBean){ + infoRegistry.put(((SolrInfoMBean)searchComp).getName(), (SolrInfoMBean)searchComp); + } } } diff --git a/src/java/org/apache/solr/core/SolrResourceLoader.java b/src/java/org/apache/solr/core/SolrResourceLoader.java index 84ab4d8b5f3..cf644d87141 100644 --- a/src/java/org/apache/solr/core/SolrResourceLoader.java +++ b/src/java/org/apache/solr/core/SolrResourceLoader.java @@ -68,6 +68,7 @@ public class SolrResourceLoader implements ResourceLoader private String dataDir; private final List waitingForCore = new ArrayList(); + private final List infoMBeans = new ArrayList(); private final List waitingForResources = new ArrayList(); private static final Charset UTF_8 = Charset.forName("UTF-8"); @@ -345,6 +346,10 @@ public class SolrResourceLoader implements ResourceLoader assertAwareCompatibility( ResourceLoaderAware.class, obj ); waitingForResources.add( (ResourceLoaderAware)obj ); } + if (obj instanceof SolrInfoMBean){ + //TODO: Assert here? + infoMBeans.add((SolrInfoMBean) obj); + } return obj; } @@ -401,6 +406,10 @@ public class SolrResourceLoader implements ResourceLoader assertAwareCompatibility( ResourceLoaderAware.class, obj ); waitingForResources.add( (ResourceLoaderAware)obj ); } + if (obj instanceof SolrInfoMBean){ + //TODO: Assert here? + infoMBeans.add((SolrInfoMBean) obj); + } return obj; } @@ -427,6 +436,16 @@ public class SolrResourceLoader implements ResourceLoader } waitingForResources.clear(); } + + /** + * Register any {@link org.apache.solr.core.SolrInfoMBean}s + * @param infoRegistry The Info Registry + */ + public void inform(Map infoRegistry) { + for (SolrInfoMBean bean : infoMBeans) { + infoRegistry.put(bean.getName(), bean); + } + } /** * Determines the solrhome from the environment. * Tries JNDI (java:comp/env/solr/home) then system property (solr.solr.home); @@ -535,4 +554,5 @@ public class SolrResourceLoader implements ResourceLoader throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, builder.toString() ); } + } diff --git a/src/test/org/apache/solr/core/SolrCoreTest.java b/src/test/org/apache/solr/core/SolrCoreTest.java index afb2b579d6a..6d889aaa0ab 100755 --- a/src/test/org/apache/solr/core/SolrCoreTest.java +++ b/src/test/org/apache/solr/core/SolrCoreTest.java @@ -18,6 +18,8 @@ package org.apache.solr.core; import org.apache.solr.handler.RequestHandlerBase; +import org.apache.solr.handler.component.SpellCheckComponent; +import org.apache.solr.handler.component.QueryComponent; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryResponse; import org.apache.solr.request.SolrRequestHandler; @@ -164,6 +166,24 @@ public class SolrCoreTest extends AbstractSolrTestCase { service.shutdown(); assertTrue("Running for too long...", service.awaitTermination(60, TimeUnit.SECONDS)); } + + public void testInfoRegistry() throws Exception { + //TEst that SolrInfoMBeans are registered, including SearchComponents + SolrCore core = h.getCore(); + + Map infoRegistry = core.getInfoRegistry(); + assertTrue("infoRegistry Size: " + infoRegistry.size() + " is not greater than: " + 0, infoRegistry.size() > 0); + //try out some that we know are in the config + SolrInfoMBean bean = infoRegistry.get(SpellCheckComponent.class.getName()); + assertNotNull("bean not registered", bean); + //try a default one + bean = infoRegistry.get(QueryComponent.class.getName()); + assertNotNull("bean not registered", bean); + //try a Req Handler, which are stored by name, not clas + bean = infoRegistry.get("standard"); + assertNotNull("bean not registered", bean); + } + } diff --git a/src/webapp/web/admin/registry.xsl b/src/webapp/web/admin/registry.xsl index 70709b4e00e..1e13129a5dc 100644 --- a/src/webapp/web/admin/registry.xsl +++ b/src/webapp/web/admin/registry.xsl @@ -66,6 +66,7 @@ [Cache] [Query] [Update] + [Highlighting] [Other] @@ -248,6 +249,39 @@ + +
+

Highlighting

+ + + + + + +
+   + +
+
+ + + + + + + +   + + + + + + + + + + +