lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r793088 - in /lucene/solr/trunk/src: java/org/apache/solr/core/RequestHandlers.java java/org/apache/solr/core/SolrCore.java webapp/web/admin/index.jsp webapp/web/admin/replication/header.jsp
Date Fri, 10 Jul 2009 19:37:31 GMT
Author: hossman
Date: Fri Jul 10 19:37:30 2009
New Revision: 793088

URL: http://svn.apache.org/viewvc?rev=793088&view=rev
Log:
followup to SOLR-1255 ... previous commit caused compilation errors in test cases, this commit
alters the methods added to SolrCore/RequestHandlers both to fix the compilation error and
be more generally useful beyond just SOLR-1255

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
    lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
    lucene/solr/trunk/src/webapp/web/admin/index.jsp
    lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp

Modified: lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java?rev=793088&r1=793087&r2=793088&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java Fri Jul 10 19:37:30
2009
@@ -74,11 +74,16 @@
     return handlers.get(normalize(handlerName));
   }
 
-  public SolrRequestHandler get(Class clazz) {
-    for (SolrRequestHandler requestHandler : handlers.values()) {
-      if(requestHandler.getClass() == clazz) return requestHandler;
+  /**
+   * @return a Map of all registered handlers of the specified type.
+   */
+  public Map<String,SolrRequestHandler> getAll(Class clazz) {
+    Map<String,SolrRequestHandler> result 
+      = new HashMap<String,SolrRequestHandler>(7);
+    for (Map.Entry<String,SolrRequestHandler> e : handlers.entrySet()) {
+      if(clazz.isInstance(e.getValue())) result.put(e.getKey(), e.getValue());
     }
-    return null;
+    return result;
   }
 
   /**

Modified: lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java?rev=793088&r1=793087&r2=793088&view=diff
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java Fri Jul 10 19:37:30 2009
@@ -768,8 +768,11 @@
     return reqHandlers.get(handlerName);
   }
 
-  public SolrRequestHandler getRequestHandler(Class clazz) {
-    return reqHandlers.get(clazz);
+  /**
+   * Returns an unmodifieable Map containing the registered handlers of the specified type.
+   */
+  public Map<String,SolrRequestHandler> getRequestHandlers(Class clazz) {
+    return reqHandlers.getAll(clazz);
   }
   
   /**

Modified: lucene/solr/trunk/src/webapp/web/admin/index.jsp
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/index.jsp?rev=793088&r1=793087&r2=793088&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/web/admin/index.jsp (original)
+++ lucene/solr/trunk/src/webapp/web/admin/index.jsp Fri Jul 10 19:37:30 2009
@@ -29,7 +29,7 @@
 <%-- jsp:include page="header.jsp"/ --%>
 <%-- do a verbatim include so we can use the local vars --%>
 <%@include file="header.jsp" %>
-<%SolrRequestHandler replicationhandler = core.getRequestHandler(ReplicationHandler.class);%>
+<%boolean replicationhandler = !core.getRequestHandlers(ReplicationHandler.class).isEmpty();%>
 <br clear="all">
 <table>
 
@@ -45,7 +45,7 @@
     [<a href="file/?file=<%=core.getConfigResource()%>">Config</a>]
     <% } %>
     [<a href="analysis.jsp?highlight=on">Analysis</a>]
-    [<a href="schema.jsp">Schema Browser</a>] <%if(replicationhandler != null
){%>[<a href="replication/index.jsp">Replication</a>]<%}%>
+    [<a href="schema.jsp">Schema Browser</a>] <%if(replicationhandler){%>[<a
href="replication/index.jsp">Replication</a>]<%}%>
     <br>
     [<a href="stats.jsp">Statistics</a>]
     [<a href="registry.jsp">Info</a>]

Modified: lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp?rev=793088&r1=793087&r2=793088&view=diff
==============================================================================
--- lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp (original)
+++ lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp Fri Jul 10 19:37:30 2009
@@ -20,7 +20,8 @@
 				 org.apache.solr.common.util.SimpleOrderedMap,
 				 org.apache.solr.request.LocalSolrQueryRequest,
 				 org.apache.solr.request.SolrQueryResponse,
-				 org.apache.solr.request.SolrRequestHandler"%>
+				 org.apache.solr.request.SolrRequestHandler,
+                                 java.util.Map"%>
 <%@ page import="org.apache.solr.handler.ReplicationHandler" %>
 <%
 request.setCharacterEncoding("UTF-8");
@@ -55,11 +56,15 @@
 %>
 
 <%
-final SolrRequestHandler rh = core.getRequestHandler(ReplicationHandler.class);
-  if(rh == null){
+final Map<String,SolrRequestHandler> all = core.getRequestHandlers(ReplicationHandler.class);
+  if(all.isEmpty()){
     response.sendError( 404, "No ReplicationHandler registered" );
     return;
   }
+
+// :HACK: we should be more deterministic if multiple instances
+final SolrRequestHandler rh = all.values().iterator().next();
+
 NamedList namedlist = executeCommand("details",core,rh);
 NamedList detailsMap = (NamedList)namedlist.get("details");
 if(detailsMap != null)



Mime
View raw message