1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.search.solr.internal; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Provider; |
24 |
|
import javax.inject.Singleton; |
25 |
|
|
26 |
|
import org.xwiki.component.annotation.Component; |
27 |
|
import org.xwiki.component.manager.ComponentLookupException; |
28 |
|
import org.xwiki.component.manager.ComponentManager; |
29 |
|
import org.xwiki.component.phase.Initializable; |
30 |
|
import org.xwiki.component.phase.InitializationException; |
31 |
|
import org.xwiki.search.solr.internal.api.SolrConfiguration; |
32 |
|
import org.xwiki.search.solr.internal.api.SolrInstance; |
33 |
|
|
34 |
|
|
35 |
|
@link |
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
40 |
|
@Component |
41 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
42 |
|
public class SolrInstanceProvider implements Provider<SolrInstance>, Initializable |
43 |
|
{ |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@Inject |
48 |
|
private SolrConfiguration configuration; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@Inject |
54 |
|
private ComponentManager componentManager; |
55 |
|
|
56 |
|
|
57 |
|
private SolrInstance configuredInstance; |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 0.5 |
|
59 |
6 |
@Override... |
60 |
|
public void initialize() throws InitializationException |
61 |
|
{ |
62 |
6 |
String type = this.configuration.getServerType(); |
63 |
6 |
try { |
64 |
6 |
this.configuredInstance = this.componentManager.getInstance(SolrInstance.class, type); |
65 |
|
} catch (ComponentLookupException e) { |
66 |
1 |
throw new InitializationException( |
67 |
|
String.format("Failed to lookup configured Solr instance type [%s]", type), e); |
68 |
|
} |
69 |
|
} |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
71 |
1442 |
@Override... |
72 |
|
public SolrInstance get() |
73 |
|
{ |
74 |
1442 |
return this.configuredInstance; |
75 |
|
} |
76 |
|
} |