Java 类org.apache.commons.configuration2.CompositeConfiguration 实例源码

项目:databricks-client-java    文件:DatabricksClientConfiguration.java   
public Configuration getClientConfiguration() {
    Configuration clientConfig = new CompositeConfiguration();
    Iterator<String> iter = getKeys();
    while (iter.hasNext()) {
        String key = iter.next();
        if (key.startsWith(CLIENT_PREFIX)) {
            clientConfig.setProperty(key, getProperty(key));
        }
    }
    return clientConfig;
}
项目:cryptotrader    文件:ConfigurationProviderImpl.java   
@VisibleForTesting
Configuration create(String versionPath, String sitePath, String defaultPath) {

    CompositeConfiguration composite = new CompositeConfiguration();

    try {

        createClasspath(versionPath).ifPresent(composite::addConfiguration);

        createSystem().ifPresent(composite::addConfiguration);

        createFilePath(sitePath).ifPresent(composite::addConfiguration);

        createClasspath(defaultPath).ifPresent(composite::addConfiguration);

    } catch (Exception e) {

        throw new RuntimeException("Failed to load configurations.", e);

    }

    return composite;

}
项目:yajsw    文件:FileUtils.java   
/**
 * The main method.
 * 
 * @param args
 *            the arguments
 */
public static void main(String[] args)
{
    System.out.println(getFiles(".", "z:\\dev\\yajsw\\..\\yajsw\\*.jar")
            .size());
    try
    {
        // String
        // fileName=FilenameUtils.separatorsToSystem("C:\\init\\MOBILEguard\\yajsw/lib/jvmstat/*.jar");
        // System.out.println("FileName: "+fileName);
        CompositeConfiguration compConfig = new CompositeConfiguration();
        AbstractConfiguration configuraton = new BaseConfiguration();
        compConfig.addConfiguration(new EnvironmentConfiguration());
        configuraton.setProperty("wrapper.java.classpath.1",
                "${VERSANT_ROOT}/lib/jvi.*jar");
        configuraton.setProperty("wrapper.java.classpath.2",
                "${GROOVY_HOME}/lib/*.jar");
        compConfig.addConfiguration(configuraton);
        System.out.println("Configuration: "
                + ConfigurationConverter.getProperties(compConfig));
        System.out.println("subset: "
                + ConfigurationConverter.getProperties(compConfig
                        .subset("wrapper.java")));

        // Collection files=FileUtils.getFiles("../..",
        // "C:/versant/7_0_1/lib/jvi*.jar");
        // Collection collection=
        // org.apache.commons.io.FileUtils.listFiles(new File("C:/"),
        // new WildcardFileFilter("jvi*.jar"), new
        // WildcardFileFilter("*jar"));
        // File[] files= new
        // File("C:").listFiles((FilenameFilter)FileFilterUtils.nameFileFilter("C:/versant/7_0_1/lib/jvi*.jar"));

        //
        // FileUtils.getFiles("C:/versant/7_0_1/lib/", "jvi*.jar");
        // System.out.println("FileList="+
        // FileUtils.getFiles("C:/versant/7_0_1/lib/", "jvi*.jar"));
        // java.util.Arrays.asList(files));
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
    }
}
项目:yajsw    文件:YajswConfigurationImpl.java   
public CompositeConfiguration getSystemConfiguration()
{
    return _systemConfiguration;
}
项目:bitflyer4j    文件:Bitflyer4jFactory.java   
/**
 * Create a {@link Configuration} instance,
 * composed of multiple configurations which are enumerated in {@link ConfigurationType}.
 *
 * @return Composite configuration instance.
 */
@VisibleForTesting
AbstractConfiguration createConfiguration() {

    CompositeConfiguration composite = new CompositeConfiguration();

    ConfigurationType[] types = ConfigurationType.values();

    Arrays.stream(types).forEach(s -> s.get().ifPresent(composite::addConfiguration));

    return composite;

}
项目:aptasuite    文件:Configuration.java   
/**
 * Adds the configuration stored on disk to the current set of parameters. The
 * file <code>fileName</code> must be a valid configuration file as per Javas
 * <code>Properties</code> class.
 * 
 * @param fileName
 */
public static void setConfiguration(String fileName) {

    try {
        AptaLogger.log(Level.INFO, Configuration.class, "Reading configuration from file.");

        builder = new FileBasedConfigurationBuilder<org.apache.commons.configuration2.FileBasedConfiguration>(
                PropertiesConfiguration.class)
                        .configure(new Parameters().properties().setFileName(fileName)
                                .setListDelimiterHandler(new DefaultListDelimiterHandler(',')));


        // Create a composite configuration which allows to keep user parameters and defaults separated
        CompositeConfiguration  cc = new CompositeConfiguration(); 

        cc.addConfiguration(builder.getConfiguration(), true); // changes will be saved in the user config
        cc.addConfiguration(getDefaultParametersBuilder().getConfiguration(), false);

        parameters = cc;

    } catch (Exception e) {

        AptaLogger.log(Level.SEVERE, Configuration.class,
                "Error, could not read configuration file. Please check it for correctness");
        AptaLogger.log(Level.SEVERE, Configuration.class, e);
        e.printStackTrace();
    }


    // TODO: Sanity checks!
}
项目:aptasuite    文件:Configuration.java   
/**
 * Creates an empty configuration and configures the class 
 * @param filename location at which the config should be stored in the future
 */
public static void createConfiguration(Path filePath) {

    try {

        builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class)
            .configure(new Parameters().properties()
                //.setFile(filePath.toFile())
                .setListDelimiterHandler(new DefaultListDelimiterHandler(',')));

        org.apache.commons.configuration2.Configuration userParameters = builder.getConfiguration();


        //We need to explicitly save the file before setting it in the builder, for whatever reason...
        builder.getFileHandler().save(filePath.toFile());
        builder.getFileHandler().setFile(filePath.toFile());

        // Create a composite configuration which allows to keep user parameters and defaults separated
        CompositeConfiguration  cc = new CompositeConfiguration();

        cc.addConfiguration(builder.getConfiguration(), true); // changes will be saved in the user config
        cc.addConfiguration(getDefaultParametersBuilder().getConfiguration(), false);

        parameters = cc;

    } catch (Exception e) {

        AptaLogger.log(Level.SEVERE, Configuration.class,
                "Error, could not create configuration file.");
        AptaLogger.log(Level.SEVERE, Configuration.class, e);
        e.printStackTrace();
    }

}