1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.localization.jar.internal; |
21 |
|
|
22 |
|
import javax.inject.Inject; |
23 |
|
import javax.inject.Named; |
24 |
|
import javax.inject.Provider; |
25 |
|
import javax.inject.Singleton; |
26 |
|
|
27 |
|
import org.slf4j.Logger; |
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.component.manager.ComponentLookupException; |
30 |
|
import org.xwiki.component.manager.ComponentManager; |
31 |
|
import org.xwiki.localization.TranslationBundle; |
32 |
|
import org.xwiki.localization.TranslationBundleDoesNotExistsException; |
33 |
|
import org.xwiki.localization.TranslationBundleFactory; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
41 |
|
@Component |
42 |
|
@Named(JARTranslationBundleFactory.ID) |
43 |
|
@Singleton |
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.5 |
|
44 |
|
public class JARTranslationBundleFactory implements TranslationBundleFactory |
45 |
|
{ |
46 |
|
|
47 |
|
@link |
48 |
|
|
49 |
|
public static final String ID = "jar"; |
50 |
|
|
51 |
|
|
52 |
|
@link |
53 |
|
|
54 |
|
@Inject |
55 |
|
@Named("context") |
56 |
|
private Provider<ComponentManager> contextComponentManagerProvider; |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
@Inject |
62 |
|
private Logger logger; |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
64 |
0 |
@Override... |
65 |
|
public TranslationBundle getBundle(String bundleId) throws TranslationBundleDoesNotExistsException |
66 |
|
{ |
67 |
0 |
String id = ID + ':' + bundleId; |
68 |
|
|
69 |
0 |
if (this.contextComponentManagerProvider.get().hasComponent(TranslationBundle.class, id)) { |
70 |
0 |
try { |
71 |
0 |
return this.contextComponentManagerProvider.get().getInstance(TranslationBundle.class, id); |
72 |
|
} catch (ComponentLookupException e) { |
73 |
0 |
this.logger.debug("Failed to lookup component [{}] with hint [{}].", TranslationBundle.class, bundleId, |
74 |
|
e); |
75 |
|
} |
76 |
|
} |
77 |
|
|
78 |
0 |
throw new TranslationBundleDoesNotExistsException(String.format("Can't find any JAR resource for jar [%s]", |
79 |
|
bundleId)); |
80 |
|
} |
81 |
|
} |