use of javax.annotation.PostConstruct in project dhis2-core by dhis2.
the class DefaultI18nLocaleService method init.
/**
* Load all ISO languages and countries into mappings.
*/
@PostConstruct
public void init() {
List<IdentifiableObject> langs = new ArrayList<>();
List<IdentifiableObject> countrs = new ArrayList<>();
for (String lang : Locale.getISOLanguages()) {
langs.add(new BaseIdentifiableObject(lang, lang, new Locale(lang).getDisplayLanguage()));
}
for (String country : Locale.getISOCountries()) {
countrs.add(new BaseIdentifiableObject(country, country, new Locale("en", country).getDisplayCountry()));
}
Collections.sort(langs);
Collections.sort(countrs);
for (IdentifiableObject lang : langs) {
languages.put(lang.getCode(), lang.getName());
}
for (IdentifiableObject countr : countrs) {
countries.put(countr.getCode(), countr.getName());
}
}
use of javax.annotation.PostConstruct in project dhis2-core by dhis2.
the class DefaultCalendarService method init.
// -------------------------------------------------------------------------
// CalendarService implementation
// -------------------------------------------------------------------------
@PostConstruct
public void init() {
for (Calendar calendar : calendars) {
calendarMap.put(calendar.name(), calendar);
}
PeriodType.setCalendarService(this);
Cal.setCalendarService(this);
DateUnitPeriodTypeParser.setCalendarService(this);
}
use of javax.annotation.PostConstruct in project dhis2-core by dhis2.
the class DefaultMonitoringService method init.
@PostConstruct
public void init() {
Date date = new DateTime().plus(PUSH_INITIAL_DELAY).toDate();
scheduler.scheduleWithFixedDelay(() -> pushMonitoringInfo(), date, PUSH_INTERVAL);
log.info("Scheduled monitoring push service");
}
use of javax.annotation.PostConstruct in project fess by codelibs.
the class OpenSearchHelper method init.
@PostConstruct
public void init() {
if (StringUtil.isNotBlank(osddPath)) {
final String path = LaServletContextUtil.getServletContext().getRealPath(osddPath);
osddFile = new File(path);
if (!osddFile.isFile()) {
osddFile = null;
logger.warn(path + " was not found.");
}
} else {
logger.info("OSDD file is not found.");
}
}
use of javax.annotation.PostConstruct in project fess by codelibs.
the class SystemHelper method init.
@PostConstruct
public void init() {
final FessConfig fessConfig = ComponentUtil.getFessConfig();
filterPathEncoding = fessConfig.getPathEncoding();
supportedLanguages = fessConfig.getSupportedLanguagesAsArray();
langItemsCache = CacheBuilder.newBuilder().maximumSize(20).expireAfterAccess(1, TimeUnit.HOURS).build(new CacheLoader<String, List<Map<String, String>>>() {
@Override
public List<Map<String, String>> load(final String key) throws Exception {
final ULocale uLocale = new ULocale(key);
final Locale displayLocale = uLocale.toLocale();
final List<Map<String, String>> langItems = new ArrayList<>(supportedLanguages.length);
final String msg = ComponentUtil.getMessageManager().getMessage(displayLocale, "labels.allLanguages");
final Map<String, String> defaultMap = new HashMap<>(2);
defaultMap.put(Constants.ITEM_LABEL, msg);
defaultMap.put(Constants.ITEM_VALUE, "all");
langItems.add(defaultMap);
for (final String lang : supportedLanguages) {
final Locale locale = LocaleUtils.toLocale(lang);
final String label = locale.getDisplayName(displayLocale);
final Map<String, String> map = new HashMap<>(2);
map.put(Constants.ITEM_LABEL, label);
map.put(Constants.ITEM_VALUE, lang);
langItems.add(map);
}
return langItems;
}
});
ComponentUtil.doInitProcesses(p -> p.run());
}
Aggregations