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:com.siapa.managedbean.JaulaManangedBean.java

@Override
public void saveNew(ActionEvent event) {
    if (getUsuario() != null) {
        String msg = ResourceBundle.getBundle("/crudbundle").getString(Jaula.class.getSimpleName() + "Created");
        getSelected().setFechaSiembraJaula(new Date());
        getSelected().setFechaVentaJaula(new Date());
        getSelected().setIdTipoJaula(getTipoJaula());
        getSelected().setListaVentaJaula(getJaulaVenta());
        persist(PersistAction.CREATE, msg);
        tipoJaulaList = tipoJaulaService.findAllActives();
        setSuma(this.jaulaService.sumAllJ());
        toCreateJaula();// w  ww  .  j  a va2s.  c om
    }
}

From source file:com.apporiented.hermesftp.server.impl.SecureFtpServer.java

/**
 * {@inheritDoc}/*from w  ww  . j ava2 s  .c o  m*/
 */
protected FtpSessionContext createFtpContext() {
    FtpSessionContext ctx = new FtpSessionContextImpl(getOptions(), getUserManager(),
            ResourceBundle.getBundle(getResources()), this);
    ctx.setAttribute(ATTR_SSL, Boolean.TRUE);
    return ctx;
}

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

public LDAPCleaner(SessionFactory factory) {
    rb = ResourceBundle.getBundle("cleaner");

    this.factory = factory;

    try {// w w w  .j a  v  a  2s.  co  m
        String strCycles[] = rb.getString("NotifyCycle").split(",");
        cycle = new int[strCycles.length];

        for (int i = 0; i < strCycles.length; i++) {
            cycle[i] = Integer.parseInt(strCycles[i]);
        }
    } catch (MissingResourceException mre) {
        cycle = new int[3];
        cycle[0] = 20;
        cycle[1] = 10;
        cycle[2] = 5;
    }
}

From source file:edu.ucsb.nceas.metacat.lsid.LSIDDataLookup.java

public String getDocType(LSID lsid) {
    // example/*from  www .  ja v  a  2  s  .c  o m*/
    //http://metacat.nceas.ucsb.edu/knb/metacat?action=getrevisionanddoctype&docid=knb-lter-gce.109.6
    // returns rev;doctype

    String _docType = null;
    String ns = lsid.getNamespace();
    String id = lsid.getObject();
    String ver = lsid.getRevision();
    InputStream docStream = null;

    ResourceBundle rb = ResourceBundle.getBundle("metacat-lsid");
    String theServer = rb.getString("metacatserver");
    logger.debug("the server is " + theServer);

    String url = theServer + "?action=getrevisionanddoctype&docid=";
    url = url + ns + "." + id + "." + ver;
    try {
        URL theDoc = new URL(url);
        docStream = theDoc.openStream();

        StringTokenizer _st = new StringTokenizer(LSIDAuthorityMetaData.getStringFromInputStream(docStream),
                ";");
        _st.nextToken();
        _docType = _st.nextToken();
        docStream.close();
    } catch (MalformedURLException mue) {
        logger.error("MalformedURLException in LSIDDataLookup: " + mue);
        mue.printStackTrace();
    } catch (IOException ioe) {
        logger.error("IOException in LSIDDataLookup: " + ioe);
        ioe.printStackTrace();
    }
    return _docType;
}

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

private static String getNombreFicheroExterno() {
    String resultado = FICHERO_PROPIEDADES;
    try {/*  w  ww  .j av a2s .c  o  m*/
        ResourceBundle propiedadesPorDefecto = ResourceBundle.getBundle(FICHERO_RESOURCE);
        resultado = propiedadesPorDefecto.getString(CONFIG_EXT_FILE);
    } catch (MissingResourceException ex) {
    }
    return resultado;
}

From source file:be.fedict.eidviewer.lib.X509Utilities.java

public static String getHumanReadableName(X509Certificate certificate) {
    String commonName = getCN(certificate);
    ResourceBundle bundle = ResourceBundle.getBundle("be/fedict/eidviewer/lib/resources/X509Utilities");
    if (bundle != null) {
        try {/*from  ww  w  . j  a v a  2  s .c om*/
            return bundle.getString(commonName);
        } catch (MissingResourceException mre) {
            // intentionally empty ; will return commonName below
        }
    }

    return commonName;
}

From source file:ninja.javafx.smartcsv.fx.FXMLController.java

protected final void loadFXML() throws IOException {
    try (InputStream fxmlStream = getClass().getResourceAsStream(fxmlFilePath)) {
        FXMLLoader loader = new FXMLLoader();
        loader.setResources(ResourceBundle.getBundle(this.resourcePath));
        loader.setController(this);
        this.view = (loader.load(fxmlStream));
    } catch (Throwable t) {
        t.printStackTrace();/*from ww  w  . j a  va2 s .c  o  m*/
    }
}

From source file:org.dlw.ai.blackboard.dao.BaseDaoTestCase.java

/**
 * Default constructor - populates "rb" variable if properties file exists for the class in
 * src/test/resources.//  www . ja v a 2  s  . c  o  m
 */
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.warn("No resource bundle found for: " + className);
    }
}

From source file:net.big_oh.common.utils.PropertyUtil.java

/**
 * Construct a new {@link Properties} object from the {@link ResourceBundle}
 * identified by resourceBundleName. Prior to looking up the ResourceBundle,
 * the resourceBundleName parameter is processed to conform to the naming
 * conventions for ResourceBundles: <br/>
 * <ul>/* w  w w . j av a2 s  .  com*/
 * <li>1) Any terminating ".properties" is stripped off.</li>
 * <li>2) Period characters ('.') are replaced with forward slash characters
 * ('/').</li>
 * </ul>
 * 
 * @param resourceBundleName
 *            The name of the ResourceBundle from which the new Properties
 *            object will be constructed.
 * @return A Properties object built from the named REsourceBundle.
 * @throws MissingResourceException
 */
public static Properties loadProperties(String resourceBundleName) throws MissingResourceException {

    logger.info("Requested properties file from resource bundle named " + resourceBundleName + ".");

    Properties props = new Properties();

    if (resourceBundleName != null) {

        // correct common naming mistakes when getting resource bundles
        String requestedResourceBundleName = resourceBundleName;
        resourceBundleName = resourceBundleName.replaceAll("\\.properties$", "");
        resourceBundleName = resourceBundleName.replace('/', '.');

        if (!resourceBundleName.equals(requestedResourceBundleName)) {
            logger.info("Translated requested resource bundle name from '" + requestedResourceBundleName
                    + "' to '" + resourceBundleName + "'");
        }

        ResourceBundle rb = ResourceBundle.getBundle(resourceBundleName);

        for (Enumeration<String> keys = rb.getKeys(); keys.hasMoreElements();) {
            final String key = (String) keys.nextElement();
            final String value = rb.getString(key);

            props.put(key, value);
        }

    }

    return props;

}

From source file:ec.com.ebos.web.master.jsf.bean.TechnicalInfo.java

public void initialize() {
    try {//from www.  j  a v a 2s.co  m
        ResourceBundle rb = ResourceBundle.getBundle(Constantes.DOMAIN_NAME + ".admin.resources.ebosconfig");

        String strAppProps = rb.getString("application.properties");
        int lastBrace = strAppProps.indexOf("}");
        strAppProps = strAppProps.substring(1, lastBrace);

        Map<String, String> appProperties = new HashMap<String, String>();
        String[] appProps = strAppProps.split("[\\s,]+");
        for (String appProp : appProps) {
            String[] keyValue = appProp.split("=");
            if (keyValue != null && keyValue.length > 1) {
                appProperties.put(keyValue[0], keyValue[1]);
            }
        }

        version = appProperties.get("ebos.version");
        spring = "Spring: " + appProperties.get("spring.version");
        hibernate = "Hibernate: " + appProperties.get("hibernate.version");
        primeFaces = "PrimeFaces: " + appProperties.get("primefaces.version");
        primeFacesExt = "PrimeFaces Extensions: " + appProperties.get("primefaces-extensions.version");
        jsfImpl = "JSF: " + appProperties.get("jsf-impl") + " " + appProperties.get("jsfVersion");
        server = "Server: "
                + ((ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext())
                        .getServerInfo();

        DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Calendar calendar = Calendar.getInstance();

        if (appProperties.containsKey("timestamp")) {
            calendar.setTimeInMillis(Long.valueOf(appProperties.get("timestamp")));
        }

        buildTime = "Build time: " + formatter.format(calendar.getTime());
        mojarra = appProperties.get("jsf-impl").contains("mojarra");

        //mfenoglio process new and updated components
        this.proccessNewsComponents(appProperties.get("primefaces-extensions.new-components"),
                appProperties.get("primefaces-extensions.updated-components"));
    } catch (MissingResourceException e) {
        LOGGER.warning("Resource bundle 'ebosconfig' was not found");
    }
}