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:edu.lternet.pasta.dml.database.pooling.PostgresDatabaseConnectionPool.java

/**
 * Loads Data Manager options from a configuration file.
 *//*  w  w w  .j a va 2 s. c o m*/
private static void loadOptions() {

    try {
        options = ResourceBundle.getBundle(CONFIG_NAME);
        serverName = options.getString("dbServerName");
        databaseName = options.getString("dbName");
        user = options.getString("dbUser");
        password = options.getString("dbPassword");
        maxConnections = Integer.parseInt(options.getString("dbMaxConnections"));
        databaseAdapterName = options.getString("dbAdapter");
    } catch (Exception e) {
        System.out.println("Error in loading options: " + e.getMessage());
    }
}

From source file:org.sinekartapdfa.share.webscript.BaseWS.java

protected String getMessage(String messageId) {
    String message = null;//from w ww .  j av  a  2s. c o m
    try {
        if (getResources().containsKey(messageId)) {
            message = getResources().getString(messageId);
        } else {
            message = ResourceBundle.getBundle("alfresco/messages/skds-commons").getString(messageId);
        }
    } catch (Exception e) {
        message = null;
    }
    if (message == null) {
        message = messageId;
    }
    return message;
}

From source file:it.doqui.index.ecmengine.client.backoffice.EcmEngineBackofficeDirectDelegateImpl.java

@Override
protected EcmEngineBackofficeBusinessInterface createBackofficeService() throws Throwable {
    Properties properties = new Properties();
    this.log.debug("[" + getClass().getSimpleName() + "::createBackofficeService] BEGIN ");

    rb = ResourceBundle.getBundle(ECMENGINE_BKO_PROPERTIES_FILE);
    /*/*from ww w .  ja  v a 2s  . co m*/
     * Caricamento della porta delegata del backoffice.
     */
    try {
        this.log.debug(
                "[" + getClass().getSimpleName() + "::createBackofficeService] P-Delegata di backoffice.");

        this.log.debug("[" + getClass().getSimpleName() + "::createBackofficeService] context factory vale : "
                + rb.getString(ECMENGINE_BKO_CONTEXT_FACTORY));
        properties.put(Context.INITIAL_CONTEXT_FACTORY, rb.getString(ECMENGINE_BKO_CONTEXT_FACTORY));
        this.log.debug("[" + getClass().getSimpleName() + "::createBackofficeService] url to connect vale : "
                + rb.getString(ECMENGINE_BKO_URL_TO_CONNECT));
        properties.put(Context.PROVIDER_URL, rb.getString(ECMENGINE_BKO_URL_TO_CONNECT));

        /* Controllo che la property cluster partition sia valorizzata per capire se 
         * sto lavorando in una configurazione in cluster oppure no */
        String clusterPartition = rb.getString(ECMENGINE_BKO_CLUSTER_PARTITION);
        this.log.debug("[" + getClass().getSimpleName() + "::createBackofficeService] clusterPartition vale : "
                + clusterPartition);
        if (clusterPartition != null && clusterPartition.length() > 0) {
            properties.put("jnp.partitionName", clusterPartition);
            this.log.debug(
                    "[" + getClass().getSimpleName() + "::createBackofficeService] disable discovery vale : "
                            + rb.getString(ECMENGINE_BKO_DISABLE_DISCOVERY));
            properties.put("jnp.disableDiscovery", rb.getString(ECMENGINE_BKO_DISABLE_DISCOVERY));
        }

        // Get an initial context
        InitialContext jndiContext = new InitialContext(properties);
        log.debug("[" + getClass().getSimpleName() + "::createBackofficeService] context istanziato");

        // Get a reference to the Bean
        Object ref = jndiContext.lookup(ECMENGINE_BKO_JNDI_NAME);

        // Get a reference from this to the Bean's Home interface
        EcmEngineBackofficeHome home = (EcmEngineBackofficeHome) PortableRemoteObject.narrow(ref,
                EcmEngineBackofficeHome.class);

        // Create an Adder object from the Home interface
        return home.create();

    } catch (Throwable e) {
        this.log.error("[" + getClass().getSimpleName() + "::createBackofficeService] "
                + "Impossibile istanziare la P-Delegata di backoffice: " + e.getMessage());
        throw e;
    } finally {
        this.log.debug("[" + getClass().getSimpleName() + "::createBackofficeService] END ");
    }
}

From source file:it.doqui.index.ecmengine.client.engine.EcmEngineDelegateFactory.java

/**
 * Metodo factory che crea una nuova istanza del client delegate.
 * //  w  ww.j ava  2 s  .c o m
 * <p>La factory cerca di istanziare la classe di implementazione
 * specificata dall'utente nel file di propriet&agrave;
 * {@code ecmengine-engine-delegate.properties}. Se tale operazione fallisce
 * la factory cerca di istanziare la classe di default definita
 * in {@link it.doqui.index.ecmengine.client.engine.util.EcmEngineDelegateConstants#ECMENGINE_DELEGATE_CLASS_NAME_DEFAULT}.
 * </p>
 * 
 * @return Una nuova istanza del client delegate.
 * 
 * @throws EcmEngineDelegateInstantiationException Se si verifica un
 * errore nell'istanziazione del client delegate.
 */
public static EcmEngineDelegate getEcmEngineDelegate() throws EcmEngineDelegateInstantiationException {
    final ResourceBundle resources = ResourceBundle.getBundle(ECMENGINE_PROPERTIES_FILE);
    final String caller = resources.getString(ECMENGINE_DELEGATE_CALLER);
    final Log logger = LogFactory.getLog(caller + ECMENGINE_DELEGATE_LOG_CATEGORY);
    final String implClass = resources.getString(ECMENGINE_DELEGATE_CLASS);

    EcmEngineDelegate ecmEngineDelegateImpl = null;
    logger.debug("[EcmEngineDelegateFactory::getEcmEngineDelegate] BEGIN");

    logger.debug("[EcmEngineDelegateFactory::getEcmEngineDelegate] " + "Classe delegate: " + implClass);
    try {
        ecmEngineDelegateImpl = getClassInstance(implClass, logger);
    } catch (EcmEngineDelegateInstantiationException e) {
        logger.warn("[EcmEngineDelegateFactory::getEcmEngineDelegate] " + "Impossibile caricare la classe \""
                + implClass + "\": " + e.getMessage());

        logger.debug("[EcmEngineDelegateFactory::getEcmEngineDelegate] " + "Classe delegate di default: "
                + ECMENGINE_DELEGATE_CLASS_NAME_DEFAULT);
        try {
            ecmEngineDelegateImpl = getClassInstance(ECMENGINE_DELEGATE_CLASS_NAME_DEFAULT, logger);
        } catch (EcmEngineDelegateInstantiationException ex) {
            logger.error("[EcmEngineDelegateFactory::getEcmEngineDelegate] "
                    + "Impossibile caricare la classe di default \"" + ECMENGINE_DELEGATE_CLASS_NAME_DEFAULT
                    + "\": " + ex.getMessage());

            throw ex; // Rilancia l'eccezione al chiamante
        }

    } finally {
        logger.debug("[EcmEngineDelegateFactory::getEcmEngineDelegate] END");
    }

    return ecmEngineDelegateImpl;
}

From source file:org.openmrs.contrib.metadatarepository.dao.BaseDaoTestCase.java

/**
 * Default constructor - populates "rb" variable if properties file exists for the class in
 * src/test/resources.//from   w ww. j  av  a2 s .  c om
 */
public BaseDaoTestCase() {
    // Since a ResourceBundle is not required for each class, just
    // do a simple check to see if one exists
    String className = this.getClass().getName();

    try {
        rb = ResourceBundle.getBundle(className);
    } catch (MissingResourceException mre) {
        log.trace("No resource bundle found for: " + className);
    }
}

From source file:it.cnr.icar.eric.common.CommonResourceBundle.java

protected CommonResourceBundle() {
    // Load the resource bundle of default locale
    bundle = ResourceBundle.getBundle(BASE_NAME);
}

From source file:io.github.benas.todolist.web.servlet.todo.DeleteTodoServlet.java

@Override
public void init(ServletConfig servletConfig) throws ServletException {
    ApplicationContext applicationContext = WebApplicationContextUtils
            .getWebApplicationContext(servletConfig.getServletContext());
    todoService = applicationContext.getBean(TodoService.class);
    resourceBundle = ResourceBundle.getBundle("todolist");
}

From source file:it.doqui.index.ecmengine.client.backoffice.EcmEngineBackofficeDelegateFactory.java

/**
 * Metodo factory che crea una nuova istanza del client delegate.
 * //w ww  . ja  v a2s . c o  m
 * <p>La factory cerca di istanziare la classe di implementazione
 * specificata dall'utente nel file di propriet&agrave;
 * {@code ecmengine-backoffice-delegate.properties}. Se tale operazione fallisce
 * la factory cerca di istanziare la classe di default definita
 * in {@link EcmEngineBackofficeDelegateConstants#ECMENGINE_BKO_DELEGATE_CLASS_NAME_DEFAULT}.
 * </p>
 * 
 * @return Una nuova istanza del client delegate.
 * 
 * @throws EcmEngineBackofficeDelegateInstantiationException Se si verifica un
 * errore nell'istanziazione del client delegate.
 */
public static EcmEngineBackofficeDelegate getEcmEngineBackofficeDelegate()
        throws EcmEngineBackofficeDelegateInstantiationException {
    final ResourceBundle resources = ResourceBundle.getBundle(ECMENGINE_BKO_PROPERTIES_FILE);
    final String caller = resources.getString(ECMENGINE_BKO_DELEGATE_CALLER);
    final Log logger = LogFactory.getLog(caller + ECMENGINE_BKO_DELEGATE_LOG_CATEGORY);
    final String implClass = resources.getString(ECMENGINE_BKO_DELEGATE_CLASS);

    logger.debug("[EcmEngineBackofficeDelegateFactory::getEcmEngineBackofficeDelegate] BEGIN");

    EcmEngineBackofficeDelegate backofficeInstance = null;

    logger.debug("[EcmEngineBackofficeDelegateFactory::getEcmEngineBackofficeDelegate] " + "Classe delegate: "
            + implClass);
    try {
        backofficeInstance = getClassInstance(implClass, logger);
    } catch (EcmEngineBackofficeDelegateInstantiationException e) {
        logger.warn("[EcmEngineBackofficeDelegateFactory::getEcmEngineBackofficeDelegate] "
                + "Impossibile caricare la classe \"" + implClass + "\": " + e.getMessage());

        logger.debug("[EcmEngineBackofficeDelegateFactory::getEcmEngineBackofficeDelegate] "
                + "Classe delegate di default: " + ECMENGINE_BKO_DELEGATE_CLASS_NAME_DEFAULT);
        try {
            backofficeInstance = getClassInstance(ECMENGINE_BKO_DELEGATE_CLASS_NAME_DEFAULT, logger);
        } catch (EcmEngineBackofficeDelegateInstantiationException ex) {
            logger.error("[EcmEngineBackofficeDelegateFactory::getEcmEngineBackofficeDelegate] "
                    + "Impossibile caricare la classe di default \"" + ECMENGINE_BKO_DELEGATE_CLASS_NAME_DEFAULT
                    + "\": " + ex.getMessage());

            throw ex; // Rilancia l'eccezione al chiamante
        }

    } finally {
        logger.debug("[EcmEngineBackofficeDelegateFactory::getEcmEngineBackofficeDelegate] END");
    }

    return backofficeInstance;
}