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 |
|
package info.magnolia.rest.client.registry; |
35 |
|
|
36 |
|
import info.magnolia.registry.RegistrationException; |
37 |
|
import info.magnolia.registry.RegistryMap; |
38 |
|
import info.magnolia.rest.client.RestClient; |
39 |
|
|
40 |
|
import java.util.List; |
41 |
|
import java.util.Set; |
42 |
|
|
43 |
|
import javax.inject.Singleton; |
44 |
|
|
45 |
|
import org.slf4j.Logger; |
46 |
|
import org.slf4j.LoggerFactory; |
47 |
|
|
48 |
|
|
49 |
|
@link |
50 |
|
|
51 |
|
@see |
52 |
|
@see |
53 |
|
|
54 |
|
@Singleton |
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 4 |
Complexity Density: 0.57 |
|
55 |
|
public class RestClientRegistry { |
56 |
|
|
57 |
|
private static final Logger log = LoggerFactory.getLogger(RestClientRegistry.class); |
58 |
|
|
59 |
|
private final RegistryMap<String, RestClientProvider> registry = new RegistryMap<String, RestClientProvider>() { |
60 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
61 |
0 |
@Override... |
62 |
|
protected String keyFromValue(RestClientProvider provider) { |
63 |
0 |
return provider.getName(); |
64 |
|
} |
65 |
|
}; |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
67 |
0 |
public RestClient getRestClient(String name) throws RegistrationException {... |
68 |
0 |
RestClientProvider provider; |
69 |
0 |
try { |
70 |
0 |
provider = registry.getRequired(name); |
71 |
|
} catch (RegistrationException e) { |
72 |
0 |
throw new RegistrationException("No rest client registered for name: " + name, e); |
73 |
|
} |
74 |
0 |
return provider.getRestClient(); |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
77 |
0 |
public Set<String> unregisterAndRegister(Set<String> registeredNames, List<RestClientProvider> providers) {... |
78 |
0 |
return registry.removeAndPutAll(registeredNames, providers); |
79 |
|
} |
80 |
|
|
81 |
|
} |