1
|
package eu.dnetlib.enabling.tools.registration;
|
2
|
|
3
|
import java.util.HashMap;
|
4
|
import java.util.Map;
|
5
|
|
6
|
/**
|
7
|
* Allow manual (external) override of service types, through an appropriate mapping (e.g. injected with spring).
|
8
|
*
|
9
|
* @author marko
|
10
|
*
|
11
|
*/
|
12
|
public class InterfaceServiceNameResolverCompatibility extends InterfaceServiceNameResolver {
|
13
|
|
14
|
/**
|
15
|
* Service names resolved with InterfaceServiceNameResolver will be used as keys in this map. If there is a match,
|
16
|
* the mapping is used instead of the inferred name.
|
17
|
*/
|
18
|
private Map<String, String> mapping = new HashMap<>();
|
19
|
|
20
|
public Map<String, String> getMapping() {
|
21
|
return mapping;
|
22
|
}
|
23
|
|
24
|
public void setMapping(final Map<String, String> mapping) {
|
25
|
this.mapping = mapping;
|
26
|
}
|
27
|
|
28
|
/**
|
29
|
* {@inheritDoc}
|
30
|
* @see eu.dnetlib.enabling.tools.registration.InterfaceServiceNameResolver#getName(java.lang.Object)
|
31
|
*/
|
32
|
@Override
|
33
|
public String getName(final Class<?> iface) {
|
34
|
final String name = super.getName(iface);
|
35
|
|
36
|
final String override = getMapping().get(name);
|
37
|
if (override != null)
|
38
|
return override;
|
39
|
|
40
|
if(name.charAt(0) == 'I' && Character.isUpperCase(name.charAt(1)) && !Character.isUpperCase(name.charAt(2)))
|
41
|
return name.substring(1);
|
42
|
|
43
|
return name;
|
44
|
}
|
45
|
}
|