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.jcr.node2bean.Node2BeanException; |
37 |
|
import info.magnolia.jcr.node2bean.Node2BeanProcessor; |
38 |
|
import info.magnolia.objectfactory.ComponentProvider; |
39 |
|
import info.magnolia.objectfactory.Components; |
40 |
|
import info.magnolia.registry.RegistrationException; |
41 |
|
import info.magnolia.rest.client.ConfiguredRestClientDefinition; |
42 |
|
import info.magnolia.rest.client.RestClient; |
43 |
|
import info.magnolia.rest.client.RestClientDefinition; |
44 |
|
import info.magnolia.rest.client.factory.ClientFactory; |
45 |
|
|
46 |
|
import javax.jcr.Node; |
47 |
|
import javax.jcr.RepositoryException; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
@see |
53 |
|
@see |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.38 |
|
55 |
|
public class ConfiguredRestClientProvider implements RestClientProvider { |
56 |
|
|
57 |
|
private final String name; |
58 |
|
private RestClient restClient; |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 3 |
Complexity Density: 0.38 |
|
60 |
0 |
public ConfiguredRestClientProvider(String name, Node configNode, ComponentProvider componentProvider) throws Node2BeanException, RepositoryException, InstantiationException {... |
61 |
0 |
this.name = name; |
62 |
0 |
ConfiguredRestClientDefinition restClientDefinition = (ConfiguredRestClientDefinition) Components.getComponent(Node2BeanProcessor.class).toBean(configNode, RestClientDefinition.class); |
63 |
0 |
if (restClientDefinition != null) { |
64 |
0 |
restClientDefinition.setName(name); |
65 |
0 |
Class<? extends ClientFactory> clientFactoryClass = restClientDefinition.getClientFactoryClass(); |
66 |
0 |
if (clientFactoryClass == null) { |
67 |
0 |
throw new InstantiationException("Unable to instantiate rest client - no factory class for client " + name + " defined."); |
68 |
|
} |
69 |
0 |
this.restClient = componentProvider.newInstance(clientFactoryClass, restClientDefinition).createClient(); |
70 |
|
} |
71 |
|
} |
72 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
73 |
|
@Override... |
74 |
|
public String getName() { |
75 |
|
return name; |
76 |
|
} |
77 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
78 |
|
@Override... |
79 |
|
public RestClient getRestClient() throws RegistrationException { |
80 |
|
return restClient; |
81 |
|
} |
82 |
|
} |