/** * Loads the application configuration from the given properties * * @param properties application configuration properties * @throws Exception */ public void load(final Properties properties) throws Exception { if (!isConfigLoaded) { LOG.info("Loading application configuration"); LOG.debug( "Loading application configuration through properties. Given properties are :" + properties); this.applicationProperties = properties; registerProviders(); loadProvidersConfig(); setProxy(); String timeout = null; if (applicationProperties.containsKey(Constants.HTTP_CONNECTION_TIMEOUT)) { timeout = applicationProperties.getProperty(Constants.HTTP_CONNECTION_TIMEOUT).trim(); } if (timeout != null && !timeout.isEmpty()) { int time = 0; try { time = Integer.parseInt(timeout); } catch (NumberFormatException ne) { LOG.warn("Http connection timout is not an integer in configuration"); } HttpUtil.setConnectionTimeout(time); } isConfigLoaded = true; } }
private void setProxy() { String proxyHost = null; String proxyPort = null; if (applicationProperties.containsKey(Constants.PROXY_HOST)) { proxyHost = applicationProperties.getProperty(Constants.PROXY_HOST).trim(); } if (applicationProperties.containsKey(Constants.PROXY_PORT)) { proxyPort = applicationProperties.getProperty(Constants.PROXY_PORT).trim(); } if (proxyHost != null && !proxyHost.isEmpty()) { int port = 0; if (proxyPort != null && !proxyPort.isEmpty()) { try { port = Integer.parseInt(proxyPort); } catch (NumberFormatException ne) { LOG.warn("Proxy port is not an integer in configuration"); } } HttpUtil.setProxyConfig(proxyHost, port); } }