Example usage for java.util ResourceBundle getBundle

List of usage examples for java.util ResourceBundle getBundle

Introduction

In this page you can find the example usage for java.util ResourceBundle getBundle.

Prototype

@CallerSensitive
public static final ResourceBundle getBundle(String baseName) 

Source Link

Document

Gets a resource bundle using the specified base name, the default locale, and the caller module.

Usage

From source file:jatoo.app.AppTexts.java

public AppTexts(Class<?> clazz, Log logger, AppTexts fallback) {

    this.clazz = clazz;
    this.logger = logger;
    this.fallback = fallback;

    try {/*from www  .  j  a  va 2  s.com*/
        resourceBundle = ResourceBundle.getBundle(clazz.getPackage().getName() + ".texts");
    }

    catch (Throwable e) {
        resourceBundle = null;
        logger.error("no texts for class: " + clazz.getName(), e);
    }
}

From source file:it.infn.ct.security.utilities.LDAPUtils.java

private static DirContext getContext() throws NamingException {
    ResourceBundle rb = ResourceBundle.getBundle("ldap");
    Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, rb.getString("url"));
    env.put(Context.SECURITY_PRINCIPAL, rb.getString("rootDN"));
    env.put(Context.SECURITY_AUTHENTICATION, "none");
    return new InitialDirContext(env);
}

From source file:io.apiman.plugins.session.util.Messages.java

/**
 * Creates a new {@link Messages} using the package name of the class as the path and the simple name of the
 * class as the message prefix.// w  ww.j a  va  2  s  . co m
 *
 * @param packageName the package name of the bundle
 * @param messagePrefix the message prefix (can be {@code null})
 */
public Messages(String packageName, String messagePrefix) {
    this.messagePrefix = (StringUtils.isNotBlank(messagePrefix) ? messagePrefix + "." : "");
    this.resourceBundle = ResourceBundle.getBundle(packageName + "." + DEFAULT_BUNDLE_NAME);
}

From source file:edu.lternet.pasta.dml.database.pooling.DatabaseConnectionPoolFactory.java

/**
 * Loads Data Manager options from a configuration file.
 *//* w  w  w.  jav  a  2  s  .com*/
private static void loadOptions() {

    try {
        options = ResourceBundle.getBundle(CONFIG_NAME);
        implementationClass = options.getString("dbImplementationClass");
    } catch (Exception e) {
        System.out.println("Error in loading options: " + e.getMessage());
    }
}

From source file:geotheme.servlet.wms.java

@Override
public void init() throws ServletException {
    // TODO Auto-generated method stub
    super.init();

    ResourceBundle rb = ResourceBundle.getBundle("properties.thematic");

    String url = rb.getString("GEOSERVER.BASE.URL");

    if (url.endsWith("/")) {
        url = url.substring(0, url.length() - 1);
    }//from   w  ww . j av a 2  s .  c o m

    this.geoserverURL = url + "/wms";
    this.pdfURL = rb.getString("PDF.OSM.URL");
    this.pdfLayers = rb.getString("PDF.OSM.LAYERS");

}

From source file:com.svds.geolocationservice.services.KafkaProducerService.java

/**
 * Create a producer connection to Kafka
 *//*  w ww.  j ava  2s.  c o  m*/
public KafkaProducerService() {
    LOG.info("KafkaProducerService - start");
    long starttime = System.currentTimeMillis();

    try {
        Properties kafkaProducerProps = new Properties();
        ResourceBundle kafkaProducerBundle = ResourceBundle.getBundle(KafkaProducerService.KAFKA_CONFIG);

        Enumeration<String> keys = kafkaProducerBundle.getKeys();
        while (keys.hasMoreElements()) {
            String key = keys.nextElement();
            kafkaProducerProps.put(key, kafkaProducerBundle.getString(key));
        }

        kafkaProducerConfig = new ProducerConfig(kafkaProducerProps);
        setKafkaProducer(new Producer<String, String>(kafkaProducerConfig));

    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
    }
    long endtime = System.currentTimeMillis() - starttime;
    LOG.info("KafkaProducerService : " + endtime);
}

From source file:com.siapa.managedbean.SsOpcionesManagedBean.java

@Override
public void saveNew(ActionEvent event) {
    if (getUsuario() != null) {
        String msg = ResourceBundle.getBundle("/crudbundle")
                .getString(SsOpciones.class.getSimpleName() + "Created");
        getSelected().setUsuarioRegistro(getUsuario());
        getSelected().setFechaRegistro(new Date());
        persist(PersistAction.CREATE, msg);
    }/*from  w ww . ja  v a 2 s. com*/
}

From source file:dataprocessing.elasticsearch.ElasticSearchClient.java

/** ***************************************************************
 * Constructor/*from  ww  w. j  a v a2s  .c om*/
 */
public ElasticSearchClient() {

    ResourceBundle resourceBundle = ResourceBundle.getBundle("elasticsearch");
    index = resourceBundle.getObject("index").toString();
    type = resourceBundle.getObject("type").toString();
    header = new BasicHeader("CloudMinds", "empty");

    client = RestClient.builder(new HttpHost(resourceBundle.getObject("host").toString(),
            Integer.parseInt(resourceBundle.getObject("port").toString()),
            resourceBundle.getObject("protocol").toString())).build();
}

From source file:com.yottaa.newrelic.PostJob.java

/**
 *
 *///from  w w  w. j av  a 2  s  .  co  m
public void postJobMethod() {

    DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");

    logger.info("Posting Yottaa metrics to New Relic @ " + dateFormat.format(System.currentTimeMillis()));

    ResourceBundle bundle = ResourceBundle.getBundle("yottaa");
    YottaaHttpClientPublic yottaaHttpClientPublic = new YottaaHttpClientPublic(
            bundle.getString("yottaaAPIKey"));

    YottaaHttpClientPartner yottaaHttpClientPartner = new YottaaHttpClientPartner(false);

    // Prepare JSON data that will be posted to New Relic
    JSONObject jsonData = new JSONObject();

    JSONObject agentData = new JSONObject();
    agentData.put("host", "apps.yottaa.com");
    agentData.put("pid", 0);
    agentData.put("version", "1.0.0");

    jsonData.put("agent", agentData);

    JSONArray components = new JSONArray();

    JSONArray sites = yottaaHttpClientPartner.getAccountSites(bundle.getString("yottaaUserId"));

    logger.info("Total number of sites is " + sites.size() + ".");

    for (int i = 0, len = sites.size(); i < len; i++) {
        JSONObject siteObj = (JSONObject) sites.get(i);
        String host = (String) siteObj.get("host");

        logger.info("Retrieve last sample for host " + host + "(" + i + " of " + len + ").");

        JSONObject lastSampleMetrics = yottaaHttpClientPublic.getLastSample(host);

        JSONObject yottaaMetricsObj = new JSONObject();
        yottaaMetricsObj.put("guid", "com.yottaa.Yottaa");
        yottaaMetricsObj.put("duration", 60);
        //yottaaMetricsObj.put("name", host);
        yottaaMetricsObj.put("name", (String) lastSampleMetrics.get("name"));

        JSONObject yottaaMetricsData = new JSONObject();

        // Http Metrics
        if (lastSampleMetrics.get("http_metrics") != null) {
            JSONObject httpMetrics = (JSONObject) lastSampleMetrics.get("http_metrics");

            JSONObject httpMetricsFirstByte = (JSONObject) httpMetrics.get("first_byte");
            JSONObject httpMetricsWait = (JSONObject) httpMetrics.get("wait");
            JSONObject httpMetricsDNS = (JSONObject) httpMetrics.get("dns");
            JSONObject httpMetricsConnect = (JSONObject) httpMetrics.get("connect");

            yottaaMetricsData.put("Component/Http Metrics/Time To First Byte[sec]",
                    Double.parseDouble(httpMetricsFirstByte.get("average").toString()));
            yottaaMetricsData.put("Component/Http Metrics/Waiting Time[sec]",
                    Double.parseDouble(httpMetricsWait.get("average").toString()));
            yottaaMetricsData.put("Component/Http Metrics/DNS Time[sec]",
                    Double.parseDouble(httpMetricsDNS.get("average").toString()));
            yottaaMetricsData.put("Component/Http Metrics/Connection Time[sec]",
                    Double.parseDouble(httpMetricsConnect.get("average").toString()));
        }

        // Issue Metrics
        if (lastSampleMetrics.get("issue_metrics") != null) {
            JSONObject issueMetrics = (JSONObject) lastSampleMetrics.get("issue_metrics");

            yottaaMetricsData.put("Component/Issue Metrics/Critical Error Count[times]",
                    Integer.parseInt(issueMetrics.get("critical_error_count").toString()));
            yottaaMetricsData.put("Component/Issue Metrics/Error Count[times]",
                    Integer.parseInt(issueMetrics.get("error_count").toString()));
            yottaaMetricsData.put("Component/Issue Metrics/Info Count[times]",
                    Integer.parseInt(issueMetrics.get("info_count").toString()));
            yottaaMetricsData.put("Component/Issue Metrics/Warning Count[times]",
                    Integer.parseInt(issueMetrics.get("warning_count").toString()));
        }

        //Webpage Metrics
        if (lastSampleMetrics.get("webpage_metrics") != null) {
            JSONObject webpageMetrics = (JSONObject) lastSampleMetrics.get("webpage_metrics");
            JSONObject webpageMetricsTimeToRender = (JSONObject) webpageMetrics.get("time_to_render");
            JSONObject webpageMetricsTimeToDisplay = (JSONObject) webpageMetrics.get("time_to_display");
            JSONObject webpageMetricsTimeToInteract = (JSONObject) webpageMetrics.get("time_to_interact");

            yottaaMetricsData.put("Component/Webpage Metrics/Time To Render[sec]",
                    Double.parseDouble(webpageMetricsTimeToRender.get("average").toString()));
            yottaaMetricsData.put("Component/Webpage Metrics/Time To Display[sec]",
                    Double.parseDouble(webpageMetricsTimeToDisplay.get("average").toString()));
            yottaaMetricsData.put("Component/Webpage Metrics/Time To Interact[sec]",
                    Double.parseDouble(webpageMetricsTimeToInteract.get("average").toString()));
        }
        yottaaMetricsObj.put("metrics", yottaaMetricsData);

        components.add(yottaaMetricsObj);

        logger.info("Finished Retrieve last sample for host " + host + "(" + i + " of " + len + ").");
    }

    jsonData.put("components", components);

    logger.info("Posted Yottaa Metrics :" + jsonData);

    this.newrelicPost(null, bundle.getString("newrelicLicenseKey"), jsonData);

}

From source file:es.mityc.firmaJava.configuracion.Configuracion.java

private static boolean chequeaPermiteFicheroExterno() {
    boolean resultado = false;
    try {//from  w w  w . j a v a  2 s .  co  m
        ResourceBundle propiedadesPorDefecto = ResourceBundle.getBundle(FICHERO_RESOURCE);
        String ficherExt = propiedadesPorDefecto.getString(CONFIG_EXT);
        resultado = isTrue(ficherExt);
    } catch (MissingResourceException ex) {
        // En caso de que no exista la clave en el SignXML por defecto, se recupera el externo 
        resultado = true;
    }
    return resultado;
}