propertiesConfiguration.setEncoding(NinjaConstant.UTF_8); propertiesConfiguration.setDelimiterParsingDisabled(true); propertiesConfiguration.setFileName(fileOrUrlOrClasspathUrl); propertiesConfiguration.getLayout().setSingleLine(NinjaConstant.applicationSecret, true);
/** * Loads configuration from a specified path. If not absolute, will look in * the user home directory, the current classpath and the system classpath. * Absolute classpath references will not work. * * @param path the path to try first as a resource, then as a file * @throws ConfigurationLoadException if the configuration could not be * loaded. * @returns properties loaded from the specified path or null. */ public Configuration fromFile(String path) throws ConfigurationLoadException { PropertiesConfiguration propertiesConfiguration = setupConfiguration(new PropertiesConfiguration()); propertiesConfiguration.setFileName(path); try { propertiesConfiguration.load(); } catch (ConfigurationException e) { if (Throwables.getRootCause(e) instanceof AccessControlException){ AdsServiceLoggers.ADS_API_LIB_LOG.debug("Properties could not be loaded.", e); } else { throw new ConfigurationLoadException( "Encountered a problem reading the provided configuration file \"" + path + "\"!", e); } } return propertiesConfiguration; }
/** * Loads configuration from a specified path. If not absolute, will look in * the user home directory, the current classpath and the system classpath. * Absolute classpath references will not work. * * @param path the path to try first as a resource, then as a file * @throws ConfigurationLoadException if the configuration could not be * loaded. * @returns properties loaded from the specified path or null. */ public Configuration fromFile(String path) throws ConfigurationLoadException { PropertiesConfiguration propertiesConfiguration = setupConfiguration(new PropertiesConfiguration()); propertiesConfiguration.setFileName(path); try { propertiesConfiguration.load(); } catch (ConfigurationException e) { if (Throwables.getRootCause(e) instanceof AccessControlException){ AdsServiceLoggers.ADS_API_LIB_LOG.debug("Properties could not be loaded.", e); } else { throw new ConfigurationLoadException( "Encountered a problem reading the provided configuration file \"" + path + "\"!", e); } } return propertiesConfiguration; }
/** * The method allows system properties to be set from a property file. * @param basePath The base path to look for the property file. * @param fileName The name of the property file. * @throws Exception if an error occurs. * @since 1.6 */ public static void setSystemProperties(String basePath, String fileName) throws Exception { PropertiesConfiguration config = fileName.endsWith(".xml") ? new XMLPropertiesConfiguration() : new PropertiesConfiguration(); if (basePath != null) { config.setBasePath(basePath); } config.setFileName(fileName); config.load(); setSystemProperties(config); }
/** * The method allows system properties to be set from a property file. * @param basePath The base path to look for the property file. * @param fileName The name of the property file. * @throws Exception if an error occurs. * @since 1.6 */ public static void setSystemProperties(String basePath, String fileName) throws Exception { PropertiesConfiguration config = fileName.endsWith(".xml") ? new XMLPropertiesConfiguration() : new PropertiesConfiguration(); if (basePath != null) { config.setBasePath(basePath); } config.setFileName(fileName); config.load(); setSystemProperties(config); }
private CompositeConfiguration getConfiguration(String databaseName) { CompositeConfiguration compositeConfiguration = new CompositeConfiguration(); // Configuration for specific DB. Can be absent PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.setDelimiterParsingDisabled(true); configuration.setFileName("modeshape-" + databaseName + ".properties"); try { configuration.load(); compositeConfiguration.addConfiguration(configuration); } catch (ConfigurationException e) { log.debug("Configuration: {} file is absent", "modeshape-" + databaseName + ".properties", e); } // Default configuration configuration = new PropertiesConfiguration(); configuration.setDelimiterParsingDisabled(true); configuration.setFileName("modeshape.properties"); try { configuration.load(); } catch (ConfigurationException e) { log.error("Error when initializing configuration: {}", "modeshape.properties", e); } compositeConfiguration.addConfiguration(configuration); return compositeConfiguration; }
private FileConfiguration createFileConfiguration(String configLocation, boolean createIfNotExist) { PropertiesConfiguration configuration = null; if (configLocation != null) { try { if (createIfNotExist) { configuration = new PropertiesConfiguration(); configuration.setDelimiterParsingDisabled(true); File file = new File(configLocation); configuration.setFile(file); if (file.exists()) { configuration.load(); } } else { try { configuration = new PropertiesConfiguration(); configuration.setDelimiterParsingDisabled(true); configuration.setFileName(configLocation); configuration.load(); } catch (ConfigurationException ignored) { // Configuration isn't found. Skip it return null; } } } catch (Exception e) { log.error("Error when initializing configuration: {}", configLocation, e); } } return configuration; }
try { conf = new PropertiesConfiguration(); conf.setFileName(basePath + bundleName); conf.setDelimiterParsingDisabled(true); conf.load(); String defaultBundleName = basePath + resourceBundleBaseName + ".properties"; conf = new PropertiesConfiguration(); conf.setFileName(defaultBundleName); conf.setDelimiterParsingDisabled(true); conf.load();
try { conf = new PropertiesConfiguration(); conf.setFileName(basePath + bundleName); conf.setDelimiterParsingDisabled(true); conf.load(); String defaultBundleName = basePath + resourceBundleBaseName + ".properties"; conf = new PropertiesConfiguration(); conf.setFileName(defaultBundleName); conf.setDelimiterParsingDisabled(true); conf.load();