mirror of https://github.com/apache/lucene.git
SOLR-6365
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1636330 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7702efb849
commit
19a2ea8679
|
@ -79,7 +79,7 @@ public class InitParams {
|
|||
}
|
||||
|
||||
public void apply(NamedList initArgs) {
|
||||
merge(defaults, (NamedList) initArgs.get(PluginInfo.DEFAULTS), initArgs, PluginInfo.DEFAULTS, false);
|
||||
merge( (NamedList) initArgs.get(PluginInfo.DEFAULTS), defaults,initArgs, PluginInfo.DEFAULTS, false);
|
||||
merge((NamedList) initArgs.get(PluginInfo.INVARIANTS), invariants, initArgs, PluginInfo.INVARIANTS, false);
|
||||
merge((NamedList) initArgs.get(PluginInfo.APPENDS), appends, initArgs, PluginInfo.APPENDS, true);
|
||||
}
|
||||
|
|
|
@ -184,7 +184,7 @@ public final class RequestHandlers {
|
|||
for (Map.Entry<PluginInfo,SolrRequestHandler> entry : handlers.entrySet()) {
|
||||
PluginInfo info = entry.getKey();
|
||||
SolrRequestHandler requestHandler = entry.getValue();
|
||||
info = applyParamSet(config, info);
|
||||
info = applyInitParams(config, info);
|
||||
if (requestHandler instanceof PluginInfoInitialized) {
|
||||
((PluginInfoInitialized) requestHandler).init(info);
|
||||
} else{
|
||||
|
@ -198,7 +198,7 @@ public final class RequestHandlers {
|
|||
log.warn("no default request handler is registered (either '/select' or 'standard')");
|
||||
}
|
||||
|
||||
private PluginInfo applyParamSet(SolrConfig config, PluginInfo info) {
|
||||
private PluginInfo applyInitParams(SolrConfig config, PluginInfo info) {
|
||||
List<InitParams> ags = new ArrayList<>();
|
||||
String p = info.attributes.get(InitParams.TYPE);
|
||||
if(p!=null) {
|
||||
|
@ -207,13 +207,12 @@ public final class RequestHandlers {
|
|||
else log.warn("INVALID paramSet {} in requestHandler {}", arg, info.toString());
|
||||
}
|
||||
}
|
||||
for (InitParams args : config.getInitParams().values()) {
|
||||
for (InitParams args : config.getInitParams().values())
|
||||
if(args.matchPath(info.name)) ags.add(args);
|
||||
}
|
||||
if(!ags.isEmpty()){
|
||||
info = new PluginInfo(info.type, info.attributes, info.initArgs.clone(), info.children);
|
||||
for (InitParams args : ags) {
|
||||
args.apply(info.initArgs);
|
||||
for (InitParams initParam : ags) {
|
||||
initParam.apply(info.initArgs);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
|
|
|
@ -32,7 +32,7 @@ public class TestInitParams extends SolrTestCaseJ4 {
|
|||
initCore("solrconfig-paramset.xml","schema.xml");
|
||||
}
|
||||
@Test
|
||||
public void testComponentWithParamSet(){
|
||||
public void testComponentWithInitParams(){
|
||||
|
||||
for (String s : Arrays.asList("/dump1", "/dump3","/root/dump5" , "/root1/anotherlevel/dump6")) {
|
||||
SolrRequestHandler handler = h.getCore().getRequestHandler(s);
|
||||
|
@ -49,7 +49,7 @@ public class TestInitParams extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testMultiParamSet(){
|
||||
public void testMultiInitParams(){
|
||||
SolrRequestHandler handler = h.getCore().getRequestHandler("/dump6");
|
||||
SolrQueryResponse rsp = new SolrQueryResponse();
|
||||
handler.handleRequest(req("initArgs", "true"), rsp);
|
||||
|
@ -65,7 +65,7 @@ public class TestInitParams extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testComponentWithParamSetRequestParam(){
|
||||
public void testComponentWithInitParamAndRequestParam(){
|
||||
for (String s : Arrays.asList("/dump4")) {
|
||||
SolrRequestHandler handler = h.getCore().getRequestHandler(s);
|
||||
SolrQueryResponse rsp = new SolrQueryResponse();
|
||||
|
@ -77,13 +77,13 @@ public class TestInitParams extends SolrTestCaseJ4 {
|
|||
}
|
||||
}
|
||||
@Test
|
||||
public void testComponentWithConflictingParamSet(){
|
||||
public void testComponentWithConflictingInitParams(){
|
||||
SolrRequestHandler handler = h.getCore().getRequestHandler("/dump2");
|
||||
SolrQueryResponse rsp = new SolrQueryResponse();
|
||||
handler.handleRequest(req("initArgs", "true"), rsp);
|
||||
NamedList nl = (NamedList) rsp.getValues().get("initArgs");
|
||||
NamedList def = (NamedList) nl.get(PluginInfo.DEFAULTS);
|
||||
assertEquals("A" ,def.get("a"));
|
||||
assertEquals("A1" ,def.get("a"));
|
||||
def = (NamedList) nl.get(PluginInfo.INVARIANTS);
|
||||
assertEquals("B1" ,def.get("b"));
|
||||
def = (NamedList) nl.get(PluginInfo.APPENDS);
|
||||
|
|
Loading…
Reference in New Issue