List of usage examples for org.apache.solr.core SolrCore createInitInstance
public <T extends Object> T createInitInstance(PluginInfo info, Class<T> cast, String msg, String defClassName)
From source file:com.o19s.solr.swan.highlight.SwanHighlightComponent.java
License:Apache License
@Override public void inform(SolrCore core) { SolrHighlighter highlighter;//from w ww . ja va 2 s . c o m List<PluginInfo> children = info.getChildren("highlighting"); if (children.isEmpty()) { PluginInfo pluginInfo = core.getSolrConfig().getPluginInfo(SolrHighlighter.class.getName()); //TODO deprecated configuration remove later if (pluginInfo != null) { highlighter = core.createInitInstance(pluginInfo, SolrHighlighter.class, null, DefaultSolrHighlighter.class.getName()); highlighter.initalize(core.getSolrConfig()); } else { DefaultSolrHighlighter defHighlighter = new DefaultSolrHighlighter(core); defHighlighter.init(PluginInfo.EMPTY_INFO); } } else { core.createInitInstance(children.get(0), SolrHighlighter.class, null, DefaultSolrHighlighter.class.getName()); } }
From source file:com.search.MySearchHandler.java
License:Apache License
/** * Initialize the components based on name. Note, if using * <code>INIT_FIRST_COMPONENTS</code> or <code>INIT_LAST_COMPONENTS</code>, * then the {@link DebugComponent} will always occur last. If this is not * desired, then one must explicitly declare all components using the * <code>INIT_COMPONENTS</code> syntax. *//*w ww . j a v a2s. c o m*/ @Override @SuppressWarnings("unchecked") public void inform(SolrCore core) { Object declaredComponents = initArgs.get(INIT_COMPONENTS); List<String> first = (List<String>) initArgs.get(INIT_FIRST_COMPONENTS); List<String> last = (List<String>) initArgs.get(INIT_LAST_COMPONENTS); List<String> list = null; boolean makeDebugLast = true; if (declaredComponents == null) { // Use the default component list list = getDefaultComponents(); if (first != null) { List<String> clist = first; clist.addAll(list); list = clist; } if (last != null) { list.addAll(last); } } else { list = (List<String>) declaredComponents; if (first != null || last != null) { System.out.println("First/Last components only valid if you do not declare 'components'"); } makeDebugLast = false; } // Build the component list components = new ArrayList<SearchComponent>(list.size()); DebugComponent dbgCmp = null; for (String c : list) { SearchComponent comp = core.getSearchComponent(c); if (comp instanceof DebugComponent && makeDebugLast == true) { dbgCmp = (DebugComponent) comp; } else { components.add(comp); log.debug("Adding component:" + comp); } } if (makeDebugLast == true && dbgCmp != null) { components.add(dbgCmp); log.debug("Adding debug component:" + dbgCmp); } if (shfInfo == null) { shardHandlerFactory = core.getCoreDescriptor().getCoreContainer().getShardHandlerFactory(); } else { shardHandlerFactory = core.createInitInstance(shfInfo, ShardHandlerFactory.class, null, null); core.addCloseHook(new CloseHook() { @Override public void preClose(SolrCore core) { shardHandlerFactory.close(); } @Override public void postClose(SolrCore core) { } }); } }
From source file:com.search.MySearchHandlerTest.java
License:Apache License
/** * Initialize the components based on name. Note, if using <code>INIT_FIRST_COMPONENTS</code> or <code>INIT_LAST_COMPONENTS</code>, * then the {@link DebugComponent} will always occur last. If this is not desired, then one must explicitly declare all components using * the <code>INIT_COMPONENTS</code> syntax. */// ww w. ja v a 2s.c o m @Override @SuppressWarnings("unchecked") public void inform(SolrCore core) { Object declaredComponents = initArgs.get(INIT_COMPONENTS); List<String> first = (List<String>) initArgs.get(INIT_FIRST_COMPONENTS); List<String> last = (List<String>) initArgs.get(INIT_LAST_COMPONENTS); List<String> list = null; boolean makeDebugLast = true; if (declaredComponents == null) { // Use the default component list list = getDefaultComponents(); if (first != null) { List<String> clist = first; clist.addAll(list); list = clist; } if (last != null) { list.addAll(last); } } else { list = (List<String>) declaredComponents; if (first != null || last != null) { throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "First/Last components only valid if you do not declare 'components'"); } makeDebugLast = false; } // Build the component list components = new ArrayList<SearchComponent>(list.size()); DebugComponent dbgCmp = null; for (String c : list) { SearchComponent comp = core.getSearchComponent(c); if (comp instanceof DebugComponent && makeDebugLast == true) { dbgCmp = (DebugComponent) comp; } else { components.add(comp); log.debug("Adding component:" + comp); } } if (makeDebugLast == true && dbgCmp != null) { components.add(dbgCmp); log.debug("Adding debug component:" + dbgCmp); } if (shfInfo == null) { shardHandlerFactory = core.getCoreDescriptor().getCoreContainer().getShardHandlerFactory(); } else { shardHandlerFactory = core.createInitInstance(shfInfo, ShardHandlerFactory.class, null, null); core.addCloseHook(new CloseHook() { @Override public void preClose(SolrCore core) { shardHandlerFactory.close(); } @Override public void postClose(SolrCore core) { } }); } }