Search in sources :

Example 6 with Configuration

use of com.xilixir.fortniteapi.v2.Configuration in project hadoop by apache.

the class TestMetricsConfig method testInstances.

private void testInstances(MetricsConfig c) throws Exception {
    Map<String, MetricsConfig> map = c.getInstanceConfigs("t1");
    Map<String, MetricsConfig> map2 = c.getInstanceConfigs("t2");
    assertEquals("number of t1 instances", 2, map.size());
    assertEquals("number of t2 instances", 1, map2.size());
    assertTrue("contains t1 instance i1", map.containsKey("i1"));
    assertTrue("contains t1 instance 42", map.containsKey("42"));
    assertTrue("contains t2 instance i1", map2.containsKey("i1"));
    MetricsConfig t1i1 = map.get("i1");
    MetricsConfig t1i42 = map.get("42");
    MetricsConfig t2i1 = map2.get("i1");
    LOG.debug("--- t1 instance i1:" + t1i1);
    LOG.debug("--- t1 instance 42:" + t1i42);
    LOG.debug("--- t2 instance i1:" + t2i1);
    Configuration t1expected1 = new ConfigBuilder().add("name", "p1.t1.i1.name").config;
    Configuration t1expected42 = new ConfigBuilder().add("bar", "p1.t1.42.bar").config;
    Configuration t2expected1 = new ConfigBuilder().add("foo", "p1.t2.i1.foo").config;
    assertEq(t1expected1, t1i1);
    assertEq(t1expected42, t1i42);
    assertEq(t2expected1, t2i1);
    LOG.debug("asserting foo == default foo");
    // Check default lookups
    assertEquals("value of foo in t1 instance i1", "default foo", t1i1.getString("foo"));
    assertEquals("value of bar in t1 instance i1", "p1.t1 default bar", t1i1.getString("bar"));
    assertEquals("value of foo in t1 instance 42", "default foo", t1i42.getString("foo"));
    assertEquals("value of foo in t2 instance i1", "p1.t2.i1.foo", t2i1.getString("foo"));
    assertEquals("value of bar in t2 instance i1", "p1 default bar", t2i1.getString("bar"));
}
Also used : Configuration(org.apache.commons.configuration2.Configuration)

Example 7 with Configuration

use of com.xilixir.fortniteapi.v2.Configuration in project engine by craftercms.

the class GroovyScriptUtils method addSiteConfigVariable.

private static void addSiteConfigVariable(Map<String, Object> variables) {
    SiteContext siteContext = SiteContext.getCurrent();
    Configuration config = null;
    if (siteContext != null) {
        config = siteContext.getConfig();
    }
    variables.put(VARIABLE_SITE_CONFIG, config);
}
Also used : Configuration(org.apache.commons.configuration2.Configuration) SiteContext(org.craftercms.engine.service.context.SiteContext)

Example 8 with Configuration

use of com.xilixir.fortniteapi.v2.Configuration in project engine by craftercms.

the class MultiResourceConfigurationBuilder method getConfiguration.

@Override
public HierarchicalConfiguration getConfiguration() throws ConfigurationException {
    List<HierarchicalConfiguration> configs = new ArrayList<>();
    // Last configurations should be loaded and added first so that they have greater priority.
    logger.info("Loading XML configurations in the order in which the properties will be resolved");
    for (int i = configPaths.length - 1; i >= 0; i--) {
        try {
            Resource resource = resourceLoader.getResource(configPaths[i]);
            if (resource.exists()) {
                Map<String, Lookup> prefixLookups = null;
                if (configDecryptor != null) {
                    prefixLookups = Collections.singletonMap(encryptedValuePrefix, new DecryptionLookup(configDecryptor));
                }
                XMLConfiguration config = ConfigUtils.readXmlConfiguration(resource, configListDelimiter, prefixLookups);
                logger.info("XML configuration loaded from " + resource);
                configs.add(config);
            }
        } catch (Exception e) {
            throw new ConfigurationException("Unable to load configuration at " + configPaths[i], e);
        }
    }
    if (configs.size() > 1) {
        CombinedConfiguration combinedConfig = new CombinedConfiguration(new OverrideCombiner());
        for (Configuration config : configs) {
            combinedConfig.addConfiguration(config);
        }
        return combinedConfig;
    } else if (configs.size() == 1) {
        return configs.get(0);
    } else {
        return null;
    }
}
Also used : XMLConfiguration(org.apache.commons.configuration2.XMLConfiguration) HierarchicalConfiguration(org.apache.commons.configuration2.HierarchicalConfiguration) Configuration(org.apache.commons.configuration2.Configuration) CombinedConfiguration(org.apache.commons.configuration2.CombinedConfiguration) ArrayList(java.util.ArrayList) Resource(org.springframework.core.io.Resource) DecryptionLookup(org.craftercms.commons.config.DecryptionLookup) CombinedConfiguration(org.apache.commons.configuration2.CombinedConfiguration) HierarchicalConfiguration(org.apache.commons.configuration2.HierarchicalConfiguration) ConfigurationException(org.apache.commons.configuration2.ex.ConfigurationException) OverrideCombiner(org.apache.commons.configuration2.tree.OverrideCombiner) XMLConfiguration(org.apache.commons.configuration2.XMLConfiguration) ConfigurationException(org.apache.commons.configuration2.ex.ConfigurationException) DecryptionLookup(org.craftercms.commons.config.DecryptionLookup) Lookup(org.apache.commons.configuration2.interpol.Lookup)

Example 9 with Configuration

use of com.xilixir.fortniteapi.v2.Configuration in project cas by apereo.

the class CasConfigurationPropertiesEnvironmentManager method savePropertyForStandaloneProfile.

/**
 * Save property for standalone profile.
 *
 * @param pair the pair
 */
@SneakyThrows
public void savePropertyForStandaloneProfile(final Pair<String, String> pair) {
    final File file = getStandaloneProfileConfigurationDirectory();
    final Parameters params = new Parameters();
    final FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class).configure(params.properties().setFile(new File(file, getApplicationName() + ".properties")));
    final Configuration config = builder.getConfiguration();
    config.setProperty(pair.getKey(), pair.getValue());
    builder.save();
}
Also used : Parameters(org.apache.commons.configuration2.builder.fluent.Parameters) Configuration(org.apache.commons.configuration2.Configuration) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) FileBasedConfiguration(org.apache.commons.configuration2.FileBasedConfiguration) FileBasedConfiguration(org.apache.commons.configuration2.FileBasedConfiguration) File(java.io.File) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) SneakyThrows(lombok.SneakyThrows)

Example 10 with Configuration

use of com.xilixir.fortniteapi.v2.Configuration in project winery by eclipse.

the class Environment method copyConfiguration.

/**
 * Overwrite configuration parameters by using the given file
 *
 * @param path a path pointing to a file where the configuration should be read from
 */
public static void copyConfiguration(Path path) throws Exception {
    Configurations configs = new Configurations();
    Configuration configuration = configs.properties(path.toFile());
    copyConfiguration(configuration);
}
Also used : BaseConfiguration(org.apache.commons.configuration2.BaseConfiguration) Configuration(org.apache.commons.configuration2.Configuration) Configurations(org.apache.commons.configuration2.builder.fluent.Configurations)

Aggregations

Configuration (org.apache.commons.configuration2.Configuration)18 Configuration (org.graylog2.Configuration)10 Test (org.junit.Test)7 Configurations (org.apache.commons.configuration2.builder.fluent.Configurations)5 Before (org.junit.Before)5 Test (org.testng.annotations.Test)5 Configuration (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.Configuration)4 ConfigurationSet (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.ConfigurationSet)4 ArrayList (java.util.ArrayList)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2 DiffResult (de.tudarmstadt.ukp.clarin.webanno.curation.casdiff.CasDiff2.DiffResult)2 IOException (java.io.IOException)2 Map (java.util.Map)2 BaseConfiguration (org.apache.commons.configuration2.BaseConfiguration)2 HierarchicalConfiguration (org.apache.commons.configuration2.HierarchicalConfiguration)2 JCas (org.apache.uima.jcas.JCas)2 Role (org.graylog2.shared.users.Role)2 UserService (org.graylog2.shared.users.UserService)2 EventBus (com.google.common.eventbus.EventBus)1 Gson (com.google.gson.Gson)1