Class | Line # | Actions | |||||
---|---|---|---|---|---|---|---|
DocumentTranslationBundleInitializer | 45 | 3 | 0% | 3 | 0 |
1 | /* | |
2 | * See the NOTICE file distributed with this work for additional | |
3 | * information regarding copyright ownership. | |
4 | * | |
5 | * This is free software; you can redistribute it and/or modify it | |
6 | * under the terms of the GNU Lesser General Public License as | |
7 | * published by the Free Software Foundation; either version 2.1 of | |
8 | * the License, or (at your option) any later version. | |
9 | * | |
10 | * This software is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | * Lesser General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU Lesser General Public | |
16 | * License along with this software; if not, write to the Free | |
17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
19 | */ | |
20 | package org.xwiki.localization.wiki.internal; | |
21 | ||
22 | import java.util.Arrays; | |
23 | import java.util.List; | |
24 | ||
25 | import javax.inject.Inject; | |
26 | import javax.inject.Named; | |
27 | import javax.inject.Provider; | |
28 | import javax.inject.Singleton; | |
29 | ||
30 | import org.xwiki.bridge.event.ApplicationReadyEvent; | |
31 | import org.xwiki.component.annotation.Component; | |
32 | import org.xwiki.localization.TranslationBundleFactory; | |
33 | import org.xwiki.observation.EventListener; | |
34 | import org.xwiki.observation.event.Event; | |
35 | ||
36 | /** | |
37 | * Trigger existing translations bundles initialization at startup. | |
38 | * | |
39 | * @version $Id: 8e340074077d7b89131509a62cde009052faa4d3 $ | |
40 | * @since 4.3M2 | |
41 | */ | |
42 | @Component | |
43 | @Named(DocumentTranslationBundleInitializer.NAME) | |
44 | @Singleton | |
45 | public class DocumentTranslationBundleInitializer implements EventListener | |
46 | { | |
47 | /** | |
48 | * The name of the event listener. | |
49 | */ | |
50 | protected static final String NAME = "localization.bundle.DocumentTranslationBundleInitializer"; | |
51 | ||
52 | /** | |
53 | * The events to listen. | |
54 | */ | |
55 | private static final List<Event> EVENTS = Arrays.<Event> asList(new ApplicationReadyEvent()); | |
56 | ||
57 | /** | |
58 | * Lazily loaded to avoid dependency issue (default BundleFactory depends on | |
59 | * {@link org.xwiki.observation.ObservationManager}). | |
60 | */ | |
61 | @Inject | |
62 | @Named(DocumentTranslationBundleFactory.ID) | |
63 | private Provider<TranslationBundleFactory> bundleFactoryProvider; | |
64 | ||
65 | 73 | ![]() |
66 | public List<Event> getEvents() | |
67 | { | |
68 | 73 | return EVENTS; |
69 | } | |
70 | ||
71 | 279 | ![]() |
72 | public String getName() | |
73 | { | |
74 | 279 | return NAME; |
75 | } | |
76 | ||
77 | 32 | ![]() |
78 | public void onEvent(Event arg0, Object arg1, Object arg2) | |
79 | { | |
80 | // Start DocumentBundleFactory initialization | |
81 | // TODO: do something cleaner; | |
82 | 32 | this.bundleFactoryProvider.get(); |
83 | } | |
84 | } |