String className = DOMUtil.getAttr(node,"class","requestHandler config");
String startup = DOMUtil.getAttr(node,"startup", null );
NamedList<Object> args = DOMUtil.childNodesToNamedList(node);
// Perhaps lazy load the request handler with a wrapper
SolrRequestHandler handler = null;
if( "lazy".equals( startup ) ) {
log.info("adding lazy requestHandler: " + name + "=" + className);
handler = new LazyRequestHandlerWrapper( className, args );
}
else {
Class<? extends SolrRequestHandler> clazz = Config.findClass( className, new String[]{} );
log.info("adding requestHandler: " + name + "=" + className);
handler = clazz.newInstance();
}
SolrRequestHandler old = register( name, handler );
if( old != null ) {
String msg = "multiple handlers registered on the same path! ignoring: "+old;
Throwable t = new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );
SolrConfig.severeErrors.add( t );
SolrException.logOnce(log,null,t);
}
names.put( name, args );
}
catch (Exception e) {
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
}
}
// Call init() on each handler after they have all been registered
for( Map.Entry<String, NamedList<Object>> reg : names.entrySet() ) {
try {
handlers.get( reg.getKey() ).init( reg.getValue() );
}
catch( Exception e ) {
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
}
}
}
//
// Get the default handler and add it in the map under null and empty
// to act as the default.
//
SolrRequestHandler handler = get(RequestHandlers.DEFAULT_HANDLER_NAME);
if (handler == null) {
handler = new StandardRequestHandler();
register(RequestHandlers.DEFAULT_HANDLER_NAME, handler);
}
register(null, handler);