+ }
+ } catch (IOException e) {
+ throw new UncheckedIOException("Cannot load configuration from " + dir, e);
+ }
+ }
+
+ /**
+ * Load config from a {@link Properties} formatted stream. If a property value
+ * starts with a '+' character, itis expected that the last character is a
+ * separator and it will be prepended to the existing value.
+ */
+ static void loadConfig(InputStream in, Map<String, String> config) throws IOException {
+ Properties props = new Properties();
+ props.load(in);
+ for (Object k : props.keySet()) {
+ String key = k.toString();
+ String value = props.getProperty(key);
+ if (value.length() > 1 && '+' == value.charAt(0)) {
+ String currentValue = config.get(key);
+ if (currentValue == null || "".equals(currentValue)) {
+ // remove the + and the trailing separator
+ value = value.substring(1, value.length() - 1);
+ config.put(key, value);
+ } else {
+ // remove the + but keep the trailing separator
+ value = value.substring(1);
+ config.put(key, value + currentValue);
+ }
+ } else {
+ config.put(key, value);