/** * {@inheritDoc} This implementation evaluates the file name pattern using * the configured {@code ConfigurationInterpolator}. If this file has * already been loaded, the corresponding builder is accessed. Otherwise, a * new builder is created for loading this configuration file. */ @Override public T getConfiguration() throws ConfigurationException { return getManagedBuilder().getConfiguration(); }
/** * Creates a {@code XMLConfiguration} instance from the content of the file * identified by the given path. This is a convenience method which can be * used if no builder is needed for managing the configuration object. * (Although, behind the scenes a builder is created). * * @param path the path to the file to be loaded * @return a {@code XMLConfiguration} object initialized from this file * @throws ConfigurationException if an error occurred when loading the * configuration */ public XMLConfiguration xml(final String path) throws ConfigurationException { return xmlBuilder(path).getConfiguration(); }
/** * Creates a {@code INIConfiguration} instance from the content of the given * file. This is a convenience method which can be used if no builder is * needed for managing the configuration object. (Although, behind the * scenes a builder is created). * * @param file the file to be loaded * @return a {@code INIConfiguration} object initialized from this file * @throws ConfigurationException if an error occurred when loading the * configuration */ public INIConfiguration ini(final File file) throws ConfigurationException { return iniBuilder(file).getConfiguration(); }
/** * Creates a {@code XMLConfiguration} instance from the content of the given * URL. This is a convenience method which can be used if no builder is * needed for managing the configuration object. (Although, behind the * scenes a builder is created). * * @param url the URL to be loaded * @return a {@code XMLConfiguration} object initialized from this file * @throws ConfigurationException if an error occurred when loading the * configuration */ public XMLConfiguration xml(final URL url) throws ConfigurationException { return xmlBuilder(url).getConfiguration(); }
/** * Creates a {@code INIConfiguration} instance from the content of the file * identified by the given path. This is a convenience method which can be * used if no builder is needed for managing the configuration object. * (Although, behind the scenes a builder is created). * * @param path the path to the file to be loaded * @return a {@code INIConfiguration} object initialized from this file * @throws ConfigurationException if an error occurred when loading the * configuration */ public INIConfiguration ini(final String path) throws ConfigurationException { return iniBuilder(path).getConfiguration(); }
/** * Creates a {@code XMLConfiguration} instance from the content of the given * file. This is a convenience method which can be used if no builder is * needed for managing the configuration object. (Although, behind the * scenes a builder is created). * * @param file the file to be loaded * @return a {@code XMLConfiguration} object initialized from this file * @throws ConfigurationException if an error occurred when loading the * configuration */ public XMLConfiguration xml(final File file) throws ConfigurationException { return xmlBuilder(file).getConfiguration(); }
/** * Creates a {@code INIConfiguration} instance from the content of the given * URL. This is a convenience method which can be used if no builder is * needed for managing the configuration object. (Although, behind the * scenes a builder is created). * * @param url the URL to be loaded * @return a {@code INIConfiguration} object initialized from this file * @throws ConfigurationException if an error occurred when loading the * configuration */ public INIConfiguration ini(final URL url) throws ConfigurationException { return iniBuilder(url).getConfiguration(); }
/** * Creates a {@code PropertiesConfiguration} instance from the content of * the given URL. This is a convenience method which can be used if no * builder is needed for managing the configuration object. (Although, * behind the scenes a builder is created). * * @param url the URL to be loaded * @return a {@code PropertiesConfiguration} object initialized from this * URL * @throws ConfigurationException if an error occurred when loading the * configuration */ public PropertiesConfiguration properties(final URL url) throws ConfigurationException { return propertiesBuilder(url).getConfiguration(); }
/** * Creates a {@code PropertiesConfiguration} instance from the content of * the file identified by the given path. This is a convenience method which * can be used if no builder is needed for managing the configuration * object. (Although, behind the scenes a builder is created). * * @param path the path to the file to be loaded * @return a {@code PropertiesConfiguration} object initialized from this * path * @throws ConfigurationException if an error occurred when loading the * configuration */ public PropertiesConfiguration properties(final String path) throws ConfigurationException { return propertiesBuilder(path).getConfiguration(); }
/** * Creates a {@code PropertiesConfiguration} instance from the content of * the given file. This is a convenience method which can be used if no * builder is needed for managing the configuration object. (Although, * behind the scenes a builder is created). * * @param file the file to be loaded * @return a {@code PropertiesConfiguration} object initialized from this * file * @throws ConfigurationException if an error occurred when loading the * configuration */ public PropertiesConfiguration properties(final File file) throws ConfigurationException { return propertiesBuilder(file).getConfiguration(); }
/** * Creates an instance of the specified file-based configuration class from * the content of the given file. This is a convenience method which can be * used if no builder is needed for managing the configuration object. * (Although, behind the scenes a builder is created). * * @param configClass the configuration class * @param file the file to be loaded * @param <T> the type of the configuration to be constructed * @return a {@code FileBasedConfiguration} object initialized from this * file * @throws ConfigurationException if an error occurred when loading the * configuration */ public <T extends FileBasedConfiguration> T fileBased(final Class<T> configClass, final File file) throws ConfigurationException { return fileBasedBuilder(configClass, file).getConfiguration(); }
/** * Creates an instance of the specified file-based configuration class from * the content of the file identified by the given path. This is a * convenience method which can be used if no builder is needed for managing * the configuration object. (Although, behind the scenes a builder is * created). * * @param configClass the configuration class * @param path the path to the file to be loaded * @param <T> the type of the configuration to be constructed * @return a {@code FileBasedConfiguration} object initialized from this * file * @throws ConfigurationException if an error occurred when loading the * configuration */ public <T extends FileBasedConfiguration> T fileBased(final Class<T> configClass, final String path) throws ConfigurationException { return fileBasedBuilder(configClass, path).getConfiguration(); }
/** * Creates an instance of the specified file-based configuration class from * the content of the given URL. This is a convenience method which can be * used if no builder is needed for managing the configuration object. * (Although, behind the scenes a builder is created). * * @param configClass the configuration class * @param url the URL to be loaded * @param <T> the type of the configuration to be constructed * @return a {@code FileBasedConfiguration} object initialized from this * file * @throws ConfigurationException if an error occurred when loading the * configuration */ public <T extends FileBasedConfiguration> T fileBased(final Class<T> configClass, final URL url) throws ConfigurationException { return fileBasedBuilder(configClass, url).getConfiguration(); }
private static FileBasedConfiguration createConfiguration(Reader reader) throws ConfigurationException { if (reader == null) { throw new NullPointerException("reader: null"); } FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(XMLConfiguration.class) .configure(new Parameters().xml()); FileBasedConfiguration fileBasedConfiguration = builder.getConfiguration(); FileHandler handler = new FileHandler(fileBasedConfiguration); handler.load(reader); return fileBasedConfiguration; }
public XMLConfiguration loadConfig(String configFile) throws ConfigurationException { Parameters params = new Parameters(); FileBasedConfigurationBuilder<XMLConfiguration> builder = new FileBasedConfigurationBuilder<XMLConfiguration>(XMLConfiguration.class) .configure(params.xml() .setFileName(configFile)); XMLConfiguration xmlConfig = builder.getConfiguration(); return xmlConfig; }
public ApplicationConfiguration(final String filePath) { final CombinedConfiguration combinedConfiguration = new CombinedConfiguration(new MergeCombiner()); // Prefer System properties. combinedConfiguration.addConfiguration(new SystemConfiguration()); final Parameters parameters = new Parameters(); final FileBasedConfigurationBuilder builder = new FileBasedConfigurationBuilder<>(PropertiesConfiguration.class).configure(parameters.properties() .setFileName(filePath)); try { combinedConfiguration.addConfiguration((Configuration) builder.getConfiguration()); } catch (ConfigurationException var5) { LOGGER.warn(String.format("No configuration found at %s.\nUsing defaults.", filePath)); } this.configuration = combinedConfiguration; }
private HierarchicalConfiguration<ImmutableNode> loadPropertiesFromUrl(FileObject file) { try { return new FileBasedConfigurationBuilder<>(FixedYAMLConfiguration.class) .configure(new Parameters().hierarchical().setURL(file.getURLDa())) .getConfiguration(); } catch (ConfigurationException e) { throw new DeployerRuntimeException(e); } }
private HierarchicalConfiguration<ImmutableNode> loadPropertiesFromUrl(FileObject file) { try { return new FileBasedConfigurationBuilder<>(FixedYAMLConfiguration.class) .configure(new Parameters().hierarchical().setURL(file.getURLDa())) .getConfiguration(); } catch (ConfigurationException e) { throw new DeployerRuntimeException(e); } }
public ExternalToolService() throws ConfigurationException { ClasspathResource resource = new ClasspathResource(ExternalToolConstants.EXTERNAL_TOOL_VERSIONS_FILE); Parameters params = new Parameters(); FileBasedConfigurationBuilder<JSONConfiguration> configBuilder = new FileBasedConfigurationBuilder<>(JSONConfiguration.class).configure(params.hierarchical() .setLocationStrategy(new ClasspathLocationStrategy()) .setFileName(ExternalToolConstants.EXTERNAL_TOOL_VERSIONS_FILE)); externalToolsConfiguration = configBuilder.getConfiguration(); }
@Test public void yamlTest() throws Exception { ImmutableHierarchicalConfiguration configuration = new FileBasedConfigurationBuilder<>(FixedYAMLConfiguration.class) .configure(new Parameters().hierarchical() .setFile(new File("./src/test/resources/DbEnvironmentXmlEnricher/system-config.yaml")) // .setFile(new File("./src/test/resources/DbEnvironmentXmlEnricher/system-config.xml")) ).getConfiguration(); System.out.println(configuration); }