Search in sources :

Example 71 with PropertyResourceBundle

use of java.util.PropertyResourceBundle in project navajo by Dexels.

the class NavajoContextInstanceFactory method registerLocalClients.

private void registerLocalClients(String name, File instanceFolder) {
    Map<String, Object> settings = new HashMap<String, Object>();
    settings.put("instance", name);
    File clientProperties = new File(instanceFolder, "navajoclient.cfg");
    if (!clientProperties.exists()) {
        logger.debug("Ignoring non existing navajoclient.cfg");
        return;
    }
    String deployment = repositoryInstance.getDeployment();
    InputStream is = null;
    try {
        is = new FileInputStream(clientProperties);
        PropertyResourceBundle prb = new PropertyResourceBundle(new InputStreamReader(is, Charset.forName("UTF-8")));
        Enumeration<String> en = prb.getKeys();
        do {
            String next = en.nextElement();
            if (next.indexOf("/") != -1) {
                String[] parts = next.split("/");
                if (!parts[0].equals(deployment)) {
                    continue;
                } else {
                    settings.put(parts[1], prb.getObject(next));
                }
            } else {
                settings.put(next, prb.getObject(next));
            }
        } while (en.hasMoreElements());
        injectLocalClient(name, settings);
    } catch (Exception e) {
        logger.error("Error: ", e);
    } finally {
        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
            }
        }
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) PropertyResourceBundle(java.util.PropertyResourceBundle) File(java.io.File)

Aggregations

PropertyResourceBundle (java.util.PropertyResourceBundle)71 InputStream (java.io.InputStream)35 ResourceBundle (java.util.ResourceBundle)33 IOException (java.io.IOException)30 URL (java.net.URL)24 InputStreamReader (java.io.InputStreamReader)23 FileInputStream (java.io.FileInputStream)15 URLConnection (java.net.URLConnection)14 MissingResourceException (java.util.MissingResourceException)13 File (java.io.File)12 FileNotFoundException (java.io.FileNotFoundException)8 Locale (java.util.Locale)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 HashMap (java.util.HashMap)5 MalformedURLException (java.net.MalformedURLException)4 Bundle (org.osgi.framework.Bundle)4 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 TemplatePersistenceData (org.eclipse.jface.text.templates.persistence.TemplatePersistenceData)3 TemplateReaderWriter (org.eclipse.jface.text.templates.persistence.TemplateReaderWriter)3