void initHandlersFromConfig(SolrConfig config ){
// use link map so we iterate in the same order
Map<PluginInfo,SolrRequestHandler> handlers = new LinkedHashMap<PluginInfo,SolrRequestHandler>();
for (PluginInfo info : config.getPluginInfos(SolrRequestHandler.class.getName())) {
try {
SolrRequestHandler requestHandler;
String startup = info.attributes.get("startup") ;
if( startup != null ) {
if( "lazy".equals(startup) ) {
log.info("adding lazy requestHandler: " + info.className);
requestHandler = new LazyRequestHandlerWrapper( core, info.className, info.initArgs );
} else {
throw new Exception( "Unknown startup value: '"+startup+"' for: "+info.className );
}
} else {
requestHandler = core.createRequestHandler(info.className);
}
handlers.put(info,requestHandler);
SolrRequestHandler old = register(info.name, requestHandler);
if(old != null) {
log.warn("Multiple requestHandler registered to the same name: " + info.name + " ignoring: " + old.getClass().getName());
}
if(info.isDefault()){
old = register("",requestHandler);
if(old != null)
log.warn("Multiple default requestHandler registered" + " ignoring: " + old.getClass().getName());
}
log.info("created "+info.name+": " + info.className);
} catch (Exception e) {
SolrConfig.severeErrors.add( e );
SolrException.logOnce(log,null,e);
}
}
// we've now registered all handlers, time ot init them in the same order
for (Map.Entry<PluginInfo,SolrRequestHandler> entry : handlers.entrySet()) {
PluginInfo info = entry.getKey();
SolrRequestHandler requestHandler = entry.getValue();
if (requestHandler instanceof PluginInfoInitialized) {
((PluginInfoInitialized) requestHandler).init(info);
} else{
requestHandler.init(info.initArgs);
}
}
if(get("") == null) register("", get(DEFAULT_HANDLER_NAME));
}