blob: 458edac43796b638c13ba79ae81679b4f93d9fe4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.http;
import com.yahoo.component.ComponentId;
import com.yahoo.component.ComponentSpecification;
import com.yahoo.component.chain.model.ChainedComponentModel;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import com.yahoo.container.core.http.HttpFilterConfig;
import com.yahoo.osgi.provider.model.ComponentModel;
import com.yahoo.vespa.model.container.component.SimpleComponent;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import static com.yahoo.container.core.http.HttpFilterConfig.Param;
/**
* @author gjoranv
* @since 5.1.23
*/
public class FilterConfigProvider extends SimpleComponent implements HttpFilterConfig.Producer {
private static final ComponentSpecification filterConfigProviderClass =
ComponentSpecification.fromString(com.yahoo.container.FilterConfigProvider.class.getName());
private final ChainedComponentModel filterModel;
private HashMap<String, String> configMap = new LinkedHashMap<>();
public FilterConfigProvider(ChainedComponentModel filterModel) {
super(new ComponentModel(
new BundleInstantiationSpecification(
configProviderId(filterModel.getComponentId()),
filterConfigProviderClass,
null)));
this.filterModel = filterModel;
}
@Override
public void getConfig(HttpFilterConfig.Builder builder) {
builder.filterName(filterModel.getComponentId().stringValue())
.filterClass(filterModel.getClassId().stringValue());
for (Map.Entry<String, String> param : configMap.entrySet()) {
builder.param(
new Param.Builder()
.name(param.getKey())
.value(param.getValue()));
}
}
public String putConfig(String key, String value) {
return configMap.put(key, value);
}
static ComponentId configProviderId(ComponentId filterId) {
return ComponentId.fromString("filterConfig").nestInNamespace(filterId);
}
}
|