Same method as above, but loads DAR configuration from a string.

@param configuration
@return
@throws ParseException
169803
public Map<String, List<? extends SipApplicationRouterInfo>> parse(String configuration) throws ParseException {
        Properties tempProperties = new Properties();
        // tempProperties.load(new StringReader(configuration)); // This needs Java 1.6
        ByteArrayInputStream stringStream = new ByteArrayInputStream(configuration.getBytes());
        try {
            tempProperties.load(stringStream);
        } catch (IOException e) {
            log.warn("Failed to update AR configuration. Will use the old properties.");
            return null;
        }
        this.properties = tempProperties;
        return parse();
    }
435340
public static Config loadConfig(ConfigParseOptions parseOptions,
            ConfigResolveOptions resolveOptions, ClassLoader classLoader, String configResource) {
        return ConfigFactory.parseResources(classLoader, configResource, parseOptions)
                .resolve(resolveOptions);
    }
1350752
protected static Properties loadConfig(URL url) {
    InputStream is = null;
    try {
      URLConnection connection = url.openConnection();
      if(connection instanceof HttpURLConnection) {
        HttpURLConnection conn = (HttpURLConnection)connection;
        conn.setConnectTimeout(5000);
        conn.setReadTimeout(5000);        
      }
      is = connection.getInputStream();
      return loadConfig(url.toString(), is);     
    } catch (Exception ex) {
      ex.printStackTrace(System.err);
      throw new IllegalArgumentException("Failed to load configuration from [" + url + "]", ex);
    }finally {
      if(is!=null) try { is.close(); } catch (Exception ex) { /* No Op */ }
    }
  }
1063888
public Object parse(Reader in) throws ParseException {
		return parse(in, JSONValue.defaultReader.DEFAULT);
	}
1344956
public static Config loadConfig(ConfigParseOptions parseOptions,
            ConfigResolveOptions resolveOptions, Reader configReader) {
        return ConfigFactory.parseReader(configReader, parseOptions).resolve(resolveOptions);
    }
574900
@SuppressWarnings("unchecked")
    public static ServerConfig load(String[] args) throws ConfigurationException {
    	if(config != null) {
    		logger.warn("Configuration is loaded already. Use ServerConfig.getInstance() method. ");
    		return config;
    	}

        try {
            URL url = getConfigUrl();
            logger.info("Trying to load settings from: " + url);

            InputStream input = null;
            try {
                input = url.openStream();
            } catch (IOException e) {
                throw new AssertionError(e);
            }

            Yaml yaml = new Yaml();
            LinkedHashMap<String, ?> dataColl = (LinkedHashMap<String, ?>)yaml.load(input);
            config = new ServerConfig();
            setParams(dataColl);
                       
            logger.info("Ok. Configuration loaded.");

        } catch (ConfigurationException e) {
            logger.warn(e.getMessage() + " -- Ignoring.");
        } catch (YAMLException e) {
            logger.warn(e.getMessage() + " -- Ignoring.");
        }

        if (config == null) {
            logger.info("Initializing configuration by default settings.");
            config = new ServerConfig();
        }

        try {
            if (args != null && args.length > 0) {
                logger.info("Parsing the command line arguments...");
                parseCommandLineArgs(args);
                logger.info("Ok. Arguments parsed.");
            }
        } catch (ConfigurationException e) {
            logger.error("Fatal configuration error", e);
            System.err.println(e.getMessage() + "\nFatal configuration error. Unable to start server.  See log for stacktrace.");
            throw e;
        }

        //overrides with params from the file
        if (!Utils.isEmpty(config.param_override_filename)) {
            try {
                InputStream overrideFile = new FileInputStream(config.param_override_filename);
                Yaml yaml = new Yaml();
                LinkedHashMap<String, ?> overrideColl = (LinkedHashMap<String, ?>)yaml.load(overrideFile);
                setParams(overrideColl);
            } catch (Exception e) {
                logger.warn(e.getMessage() + " -- Ignoring.");
            }       
        }
        return config;
    }
544523
public static ServerParams load(String[] args) throws ConfigurationException {
        if (INSTANCE != null) {
            logger.warn("Configuration is loaded already. Use ServerParams.getInstance() method. ");
            return INSTANCE;
        }

        INSTANCE = new ServerParams();
        INSTANCE.parseConfigFile(getConfigUrl());
        INSTANCE.parseCommandLineArgs(args);
        INSTANCE.parseOverrideFile();
        INSTANCE.printConfig();
        
        // TODO: Delete the next line when ServerConfig is phased out.
        copyParamsToServerConfig();
        return INSTANCE;
    }
653256
static InternalConfig load() throws JsonParseException, JsonMappingException, IOException {
        URL configUrl = getResource(DEFAULT_CONFIG_RESOURCE_RELATIVE_PATH, true, false);
        if (configUrl == null) {
            configUrl = getResource(DEFAULT_CONFIG_RESOURCE_ABSOLUTE_PATH, false, false);
        }

        InternalConfigJsonHelper config = loadfrom(configUrl, InternalConfigJsonHelper.class);
        InternalConfigJsonHelper configOverride;

        URL overrideUrl = getResource(CONFIG_OVERRIDE_RESOURCE, false, true);
        if (overrideUrl == null) {
            overrideUrl = getResource(CONFIG_OVERRIDE_RESOURCE, false, false);
        }
        if (overrideUrl == null) {
            log.debug("Configuration override " + CONFIG_OVERRIDE_RESOURCE + " not found.");
            configOverride = new InternalConfigJsonHelper();
        } else {
            configOverride = loadfrom(overrideUrl, InternalConfigJsonHelper.class);
        }

        EndpointDiscoveryConfig endpointDiscoveryConfig = new EndpointDiscoveryConfig();

        URL endpointDiscoveryConfigUrl = getResource(ENDPOINT_DISCOVERY_CONFIG_ABSOLUTE_PATH, false, false);

        if (endpointDiscoveryConfigUrl != null) {
            endpointDiscoveryConfig = loadfrom(endpointDiscoveryConfigUrl, EndpointDiscoveryConfig.class);
        }

        InternalConfig merged = new InternalConfig(config, configOverride, endpointDiscoveryConfig);
        merged.setDefaultConfigFileLocation(configUrl);
        merged.setOverrideConfigFileLocation(overrideUrl);
        return merged;
    }
82072
public static <T> T loadConfigurationModel(Class<T> clzz, String configurationFileLocation) {
        System.out.println("Loading config file " + configurationFileLocation);
        InputStream fileContents = null;
        try {
            fileContents = getRequiredResourceAsStream(configurationFileLocation);
            return Jackson.load(clzz, fileContents);
        } catch (IOException e) {
            System.err.println("Failed to read the configuration file " + configurationFileLocation);
            throw new RuntimeException(e);
        } finally {
            if (fileContents != null) {
                Utils.closeQuietly(fileContents);
            }
        }
    }
1203272
@SuppressWarnings("checkstyle:avoidhidingcauseexception")
  public static ConfigurationBuilder parseToConfigurationBuilder(final String[] args,
                                                                 final Class<? extends Name<?>>... argClasses)
      throws ParseException {
    final CommandLine commandLine;
    try {
      commandLine = new CommandLine().processCommandLine(args, argClasses);
    } catch (final IOException e) {
      // processCommandLine() converts ParseException into IOException. This reverts that to make exception handling
      // more straight forward.
      throw new ParseException(e.getMessage());
    }

    // processCommandLine() indicates that it might return null. We need to guard users of this one from that
    if (commandLine == null) {
      throw new ParseException("Unable to parse the command line and the parser returned null.");
    } else {
      return commandLine.getBuilder();
    }
  }
428778
public static <T extends Request<T>> RequestAllocator<T> inferFromConfig(RequestAllocatorConfig<T> configuration) {
    try {
      String alias = configuration.getLimitedScopeConfig().hasPath(ALLOCATOR_ALIAS_KEY) ?
          configuration.getLimitedScopeConfig().getString(ALLOCATOR_ALIAS_KEY) :
          BruteForceAllocator.Factory.class.getName();
      RequestAllocator.Factory allocatorFactory = new ClassAliasResolver<>(RequestAllocator.Factory.class).
          resolveClass(alias).newInstance();

      log.info("Using allocator factory " + allocatorFactory.getClass().getName());

      return allocatorFactory.createRequestAllocator(configuration);
    } catch (ReflectiveOperationException roe) {
      throw new RuntimeException(roe);
    }
  }
1365500
public void validateConfiguration(String configuration) {

        try {
            JSONObject json = new JSONObject(configuration);
            String className = json.optString(CmsDataViewConstants.CONFIG_VIEW_CLASS);

            Class<?> cls = Class.forName(className, false, getClass().getClassLoader());
            if (!I_CmsDataView.class.isAssignableFrom(cls)) {
                throw new IllegalArgumentException(
                    "Class " + cls.getName() + " does not implement " + I_CmsDataView.class.getName());
            }
        } catch (Exception e) {
            throw new CmsWidgetConfigurationException(e);
        }

    }
212327
public static Configuration load(String file)
    throws IOException, SAXException {
    ConfigurationImpl cfg = new ConfigurationImpl();

    XMLReader parser = XMLReaderFactory.createXMLReader();
    parser.setContentHandler(new ConfigHandler(cfg, file));
    if (file.startsWith("classpath:")) {
      String resource = file.substring("classpath:".length());
      ClassLoader cloader = Thread.currentThread().getContextClassLoader();
      InputStream istream = cloader.getResourceAsStream(resource);
      parser.parse(new InputSource(istream));
    } else
      parser.parse(file);

    return cfg;
  }
1010223
public static Expression parse(String input) throws ParseException {
        return new Parser(new StringReader(input), new Scope()).parse();
    }
219937
private static void doParse(String connectionUri, JsonObject configuration) {
    Pattern pattern = Pattern.compile(FULL_URI_REGEX);
    Matcher matcher = pattern.matcher(connectionUri);

    if (matcher.matches()) {
      // parse the user and password
      parseUserandPassword(matcher.group(USER_INFO_GROUP), configuration);

      // parse the IP address/host/unix domainSocket address
      parseNetLocation(matcher.group(NET_LOCATION_GROUP), configuration);

      // parse the port
      parsePort(matcher.group(PORT_GROUP), configuration);

      // parse the database name
      parseDatabaseName(matcher.group(DATABASE_GROUP), configuration);

      // parse the parameters
      parseParameters(matcher.group(PARAMETER_GROUP), configuration);

    } else {
      throw new IllegalArgumentException("Wrong syntax of connection URI");
    }
  }
1098186
public static Configuration loadFromString(String config)
    throws IOException, SAXException {
    ConfigurationImpl cfg = new ConfigurationImpl();

    XMLReader parser = XMLReaderFactory.createXMLReader();
    parser.setContentHandler(new ConfigHandler(cfg, null));
    Reader reader = new StringReader(config);
    parser.parse(new InputSource(reader));
    return cfg;
  }
393727
private void parseConfiguration(String config) {

        m_configuration = new HashMap<String, String>();
        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(config)) {
            for (String param : config.split(",")) {
                int index = param.indexOf("=");
                if ((index > 0) && (param.length() > (index + 1))) {
                    m_configuration.put(param.substring(0, index), param.substring(index + 1));
                }
            }
        }
    }