Search in sources :

Example 86 with PostConstruct

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());
    }
}
Also used : Locale(java.util.Locale) I18nLocale(org.hisp.dhis.i18n.locale.I18nLocale) BaseIdentifiableObject(org.hisp.dhis.common.BaseIdentifiableObject) ArrayList(java.util.ArrayList) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject) BaseIdentifiableObject(org.hisp.dhis.common.BaseIdentifiableObject) PostConstruct(javax.annotation.PostConstruct)

Example 87 with PostConstruct

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);
}
Also used : Iso8601Calendar(org.hisp.dhis.calendar.impl.Iso8601Calendar) PostConstruct(javax.annotation.PostConstruct)

Example 88 with PostConstruct

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");
}
Also used : Date(java.util.Date) DateTime(org.joda.time.DateTime) PostConstruct(javax.annotation.PostConstruct)

Example 89 with PostConstruct

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.");
    }
}
Also used : File(java.io.File) PostConstruct(javax.annotation.PostConstruct)

Example 90 with PostConstruct

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());
}
Also used : ULocale(com.ibm.icu.util.ULocale) Locale(java.util.Locale) ULocale(com.ibm.icu.util.ULocale) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CacheLoader(com.google.common.cache.CacheLoader) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) HashMap(java.util.HashMap) Map(java.util.Map) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostConstruct (javax.annotation.PostConstruct)248 IOException (java.io.IOException)28 File (java.io.File)18 SamlRegisteredService (org.apereo.cas.support.saml.services.SamlRegisteredService)17 Map (java.util.Map)15 ArrayList (java.util.ArrayList)12 ExternalResource (com.vaadin.server.ExternalResource)11 HashMap (java.util.HashMap)10 InitialContext (javax.naming.InitialContext)9 Label (com.vaadin.ui.Label)8 VerticalLayout (com.vaadin.ui.VerticalLayout)8 Request (com.nabalive.framework.web.Request)7 Response (com.nabalive.framework.web.Response)7 Route (com.nabalive.framework.web.Route)7 Link (com.vaadin.ui.Link)7 Properties (java.util.Properties)7 Method (java.lang.reflect.Method)5 InputStream (java.io.InputStream)4 URISyntaxException (java.net.URISyntaxException)4 Path (java.nio.file.Path)4