public Transaction addContainer(Map<String, Object> container) { Object names = container.get(CONTAINER_KEY); if (names instanceof Collection<?>) { for (Object name : (Collection<?>) names) { setContainers.put(name.toString(), container); } } else if (names != null) { setContainers.put(names.toString(), container); } else { throwException = new ContainerConfigException( "A container configuration doesn't have the " + CONTAINER_KEY + " property"); } return this; }
public Transaction addContainer(Map<String, Object> container) { Object names = container.get(CONTAINER_KEY); if (names instanceof Collection<?>) { for (Object name : (Collection<?>) names) { setContainers.put(name.toString(), container); } } else if (names != null) { setContainers.put(names.toString(), container); } else { throwException = new ContainerConfigException( "A container configuration doesn't have the " + CONTAINER_KEY + " property"); } return this; }
public Transaction addContainer(Map<String, Object> container) { Object names = container.get(CONTAINER_KEY); if (names instanceof Collection<?>) { for (Object name : (Collection<?>) names) { setContainers.put(name.toString(), container); } } else if (names != null) { setContainers.put(names.toString(), container); } else { throwException = new ContainerConfigException( "A container configuration doesn't have the " + CONTAINER_KEY + " property"); } return this; }
/** * Processes a container file. * * @param json * @throws ContainerConfigException */ protected void loadFromString(String json, JSONObject all) throws ContainerConfigException { try { JSONObject contents = new JSONObject(json); JSONArray containers = contents.getJSONArray(CONTAINER_KEY); for (int i = 0, j = containers.length(); i < j; ++i) { // Copy the default object and produce a new one. String container = containers.getString(i); all.put(container, contents); } } catch (JSONException e) { LOG.warning("Trouble parsing " + json); throw new ContainerConfigException("Trouble parsing " + json, e); } }
/** * Processes a container file. * * @param json * @throws ContainerConfigException */ protected void loadFromString(String json, JSONObject all) throws ContainerConfigException { try { JSONObject contents = new JSONObject(json); JSONArray containers = contents.getJSONArray(CONTAINER_KEY); for (int i = 0, j = containers.length(); i < j; ++i) { // Copy the default object and produce a new one. String container = containers.getString(i); all.put(container, contents); } } catch (JSONException e) { LOG.warning("Trouble parsing " + json); throw new ContainerConfigException("Trouble parsing " + json, e); } }
/** * Processes a container file. * * @param json json to parse and load * @throws ContainerConfigException when invalid json is encountered */ private static Map<String, Object> loadFromString(String json) throws ContainerConfigException { try { return jsonToMap(new JSONObject(json)); } catch (JSONException e) { if (LOG.isLoggable(Level.WARNING)) { LOG.logp(Level.WARNING, classname, "loadFromString", MessageKeys.READING_CONFIG, new Object[] {json}); } throw new ContainerConfigException("Trouble parsing " + json, e); } }
/** * Processes a container file. * * @param json json to parse and load * @throws ContainerConfigException when invalid json is encountered */ private static Map<String, Object> loadFromString(String json) throws ContainerConfigException { try { return jsonToMap(new JSONObject(json)); } catch (JSONException e) { if (LOG.isLoggable(Level.WARNING)) { LOG.logp(Level.WARNING, classname, "loadFromString", MessageKeys.READING_CONFIG, new Object[] {json}); } throw new ContainerConfigException("Trouble parsing " + json, e); } }
/** * Processes a container file. * * @param json json to parse and load * @throws ContainerConfigException when invalid json is encountered */ private static Map<String, Object> loadFromString(String json) throws ContainerConfigException { try { return jsonToMap(new JSONObject(json)); } catch (JSONException e) { if (LOG.isLoggable(Level.WARNING)) { LOG.logp(Level.WARNING, classname, "loadFromString", MessageKeys.READING_CONFIG, new Object[] {json}); } throw new ContainerConfigException("Trouble parsing " + json, e); } }
/** * Recursively merge values from parent objects in the prototype chain. * * @return The object merged with all parents. * * @throws ContainerConfigException If there is an invalid parent parameter * in the prototype chain. */ private JSONObject mergeParents(String container, JSONObject all) throws ContainerConfigException, JSONException { JSONObject base = all.getJSONObject(container); if (DEFAULT_CONTAINER.equals(container)) { return base; } String parent = base.optString(PARENT_KEY, DEFAULT_CONTAINER); if (!all.has(parent)) { throw new ContainerConfigException( "Unable to locate parent '" + parent + "' required by " + base.getString(CONTAINER_KEY)); } return mergeObjects(mergeParents(parent, all), base); }
/** * Loads resources recursively. * * @param files The base paths to look for container.xml * @throws ContainerConfigException when IO errors occur */ private static void loadResources(Iterable<String> files, List<Map<String, Object>> all) throws ContainerConfigException { try { for (String entry : files) { if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "loadResources", MessageKeys.READING_CONFIG, new Object[] {entry}); } String content = ResourceLoader.getContent(entry); if (content == null || content.length() == 0) throw new IOException("The file " + entry + "is empty"); all.add(loadFromString(content)); } } catch (IOException e) { throw new ContainerConfigException(e); } }
/** * Loads resources recursively. * @param files The base paths to look for container.xml * @throws ContainerConfigException */ private void loadResources(String[] files, JSONObject all) throws ContainerConfigException { try { for (String entry : files) { LOG.info("Reading container config: " + entry); String content = ResourceLoader.getContent(entry); if (content == null || content.length() == 0) throw new IOException("The file " + entry + "is empty"); loadFromString(content, all); } } catch (IOException e) { throw new ContainerConfigException(e); } }
/** * Loads resources recursively. * @param files The base paths to look for container.xml * @throws ContainerConfigException */ private void loadResources(String[] files, JSONObject all) throws ContainerConfigException { try { for (String entry : files) { LOG.info("Reading container config: " + entry); String content = ResourceLoader.getContent(entry); if (content == null || content.length() == 0) throw new IOException("The file " + entry + "is empty"); loadFromString(content, all); } } catch (IOException e) { throw new ContainerConfigException(e); } }
/** * Loads resources recursively. * * @param files The base paths to look for container.xml * @throws ContainerConfigException when IO errors occur */ private static void loadResources(Iterable<String> files, List<Map<String, Object>> all) throws ContainerConfigException { try { for (String entry : files) { if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "loadResources", MessageKeys.READING_CONFIG, new Object[] {entry}); } String content = ResourceLoader.getContent(entry); if (content == null || content.length() == 0) throw new IOException("The file " + entry + "is empty"); all.add(loadFromString(content)); } } catch (IOException e) { throw new ContainerConfigException(e); } }
/** * Recursively merge values from parent objects in the prototype chain. * * @return The object merged with all parents. * * @throws ContainerConfigException If there is an invalid parent parameter * in the prototype chain. */ private JSONObject mergeParents(String container, JSONObject all) throws ContainerConfigException, JSONException { JSONObject base = all.getJSONObject(container); if (DEFAULT_CONTAINER.equals(container)) { return base; } String parent = base.optString(PARENT_KEY, DEFAULT_CONTAINER); if (!all.has(parent)) { throw new ContainerConfigException( "Unable to locate parent '" + parent + "' required by " + base.getString(CONTAINER_KEY)); } return mergeObjects(mergeParents(parent, all), base); }
/** * Loads resources recursively. * * @param files The base paths to look for container.xml * @throws ContainerConfigException when IO errors occur */ private static void loadResources(Iterable<String> files, List<Map<String, Object>> all) throws ContainerConfigException { try { for (String entry : files) { if (LOG.isLoggable(Level.INFO)) { LOG.logp(Level.INFO, classname, "loadResources", MessageKeys.READING_CONFIG, new Object[] {entry}); } String content = ResourceLoader.getContent(entry); if (content == null || content.length() == 0) throw new IOException("The file " + entry + "is empty"); all.add(loadFromString(content)); } } catch (IOException e) { throw new ContainerConfigException(e); } }
|| file.getName().toLowerCase(Locale.ENGLISH).endsWith(".json")) { if (!file.exists()) { throw new ContainerConfigException( "The file '" + file.getAbsolutePath() + "' doesn't exist."); throw new ContainerConfigException( "The file '" + file.getAbsolutePath() + "' has errors", e);
|| file.getName().toLowerCase(Locale.ENGLISH).endsWith(".json")) { if (!file.exists()) { throw new ContainerConfigException( "The file '" + file.getAbsolutePath() + "' doesn't exist."); throw new ContainerConfigException( "The file '" + file.getAbsolutePath() + "' has errors", e);
file.getName().toLowerCase(Locale.ENGLISH).endsWith(".json")) { if (!file.exists()) { throw new ContainerConfigException( "The file '" + file.getAbsolutePath() + "' doesn't exist."); throw new ContainerConfigException("The file '" + file.getAbsolutePath() + "' has errors", e);
file.getName().toLowerCase(Locale.ENGLISH).endsWith(".json")) { if (!file.exists()) { throw new ContainerConfigException( "The file '" + file.getAbsolutePath() + "' doesn't exist."); throw new ContainerConfigException("The file '" + file.getAbsolutePath() + "' has errors", e);
|| file.getName().toLowerCase(Locale.ENGLISH).endsWith(".json")) { if (!file.exists()) { throw new ContainerConfigException( "The file '" + file.getAbsolutePath() + "' doesn't exist."); throw new ContainerConfigException( "The file '" + file.getAbsolutePath() + "' has errors", e);