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) {
}
}
}
}
Aggregations