Repository: incubator-tamaya-sandbox Updated Branches: refs/heads/master 4c323c3e8 -> 8ad95aa92
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/main/java/org/apache/tamaya/validation/internal/ConfiguredTypeEventsModelPopulator.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/internal/ConfiguredTypeEventsModelPopulator.java b/validation/src/main/java/org/apache/tamaya/validation/internal/ConfiguredTypeEventsModelPopulator.java index a89986a..16c484f 100644 --- a/validation/src/main/java/org/apache/tamaya/validation/internal/ConfiguredTypeEventsModelPopulator.java +++ b/validation/src/main/java/org/apache/tamaya/validation/internal/ConfiguredTypeEventsModelPopulator.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -23,27 +23,33 @@ import org.apache.tamaya.events.ConfigEventListener; import org.apache.tamaya.inject.spi.ConfiguredField; import org.apache.tamaya.inject.spi.ConfiguredMethod; import org.apache.tamaya.inject.spi.ConfiguredType; +import org.apache.tamaya.spi.ClassloaderAware; +import org.apache.tamaya.spi.ServiceContextManager; +import org.apache.tamaya.validation.ConfigModel; import org.apache.tamaya.validation.ConfigModelManager; +import org.apache.tamaya.validation.spi.ModelProviderSpi; import org.apache.tamaya.validation.spi.ParameterModel; import java.util.Collection; +import java.util.Objects; import java.util.logging.Logger; /** - * Internal facade that registers all kind of injected fields as {@link org.apache.tamaya.validation.ConfigModel} entries, + * Internal facade that registers all kind create injected fields as {@link org.apache.tamaya.validation.ConfigModel} entries, * so all configured injection points are visible as documented configuration hooks. */ -public final class ConfiguredTypeEventsModelPopulator implements ConfigEventListener { +public final class ConfiguredTypeEventsModelPopulator implements ConfigEventListener, ClassloaderAware { /** * The logger. */ private static final Logger LOG = Logger.getLogger(ConfiguredTypeEventsModelPopulator.class.getName()); - /** System property to be set to deactivate auto documentation of configured classes published thorugh + /** System property to be setCurrent to deactivate auto documentation create configured classes published thorugh * ConfiguredType events. */ private static final String ENABLE_EVENT_DOC = "org.apache.tamaya.model.autoModelEvents"; + private ClassLoader classLoader = ServiceContextManager.getDefaultClassLoader(); @Override public void onConfigEvent(ConfigEvent event) { @@ -56,7 +62,7 @@ public final class ConfiguredTypeEventsModelPopulator implements ConfigEventList for (ConfiguredField field : confType.getConfiguredFields()) { Collection<String> keys = field.getConfiguredKeys(); for (String key : keys) { - ParameterModel val = ConfigModelManager.getModel(key, ParameterModel.class); + ParameterModel val = getModel(key, ParameterModel.class, classLoader); if (val == null) { ConfiguredTypeEventsModelProvider.addConfigModel( new ParameterModel.Builder(confType.getName(), key) @@ -71,7 +77,7 @@ public final class ConfiguredTypeEventsModelPopulator implements ConfigEventList for (ConfiguredMethod method : confType.getConfiguredMethods()) { Collection<String> keys = method.getConfiguredKeys(); for (String key : keys) { - ParameterModel val = ConfigModelManager.getModel(key, ParameterModel.class); + ParameterModel val = getModel(key, ParameterModel.class, classLoader); if (val == null) { ConfiguredTypeEventsModelProvider.addConfigModel( new ParameterModel.Builder(confType.getName(), key) @@ -86,5 +92,33 @@ public final class ConfiguredTypeEventsModelPopulator implements ConfigEventList } } + /** + * Find the validations by matching the validation's name against the given model type. + * + * @param classLoader the target classloader, not null. + * @param name the name to use, not null. + * @param modelType classname create the target model type. + * @param <T> type create the model to filter for. + * @return the sections defined, never null. + */ + private static <T extends ConfigModel> T getModel(String name, Class<T> modelType, ClassLoader classLoader) { + for (ModelProviderSpi model : ServiceContextManager.getServiceContext(classLoader).getServices(ModelProviderSpi.class)) { + for(ConfigModel configModel : model.getConfigModels()) { + if(configModel.getName().equals(name) && configModel.getClass().equals(modelType)) { + return modelType.cast(configModel); + } + } + } + return null; + } + @Override + public void init(ClassLoader classLoader) { + this.classLoader = Objects.requireNonNull(classLoader); + } + + @Override + public ClassLoader getClassLoader() { + return classLoader; + } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/main/java/org/apache/tamaya/validation/internal/ConfiguredTypeEventsModelProvider.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/internal/ConfiguredTypeEventsModelProvider.java b/validation/src/main/java/org/apache/tamaya/validation/internal/ConfiguredTypeEventsModelProvider.java index 82bd925..ae267a4 100644 --- a/validation/src/main/java/org/apache/tamaya/validation/internal/ConfiguredTypeEventsModelProvider.java +++ b/validation/src/main/java/org/apache/tamaya/validation/internal/ConfiguredTypeEventsModelProvider.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/main/java/org/apache/tamaya/validation/spi/AbstractConfigModel.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/AbstractConfigModel.java b/validation/src/main/java/org/apache/tamaya/validation/spi/AbstractConfigModel.java index 31c2395..5ba357c 100644 --- a/validation/src/main/java/org/apache/tamaya/validation/spi/AbstractConfigModel.java +++ b/validation/src/main/java/org/apache/tamaya/validation/spi/AbstractConfigModel.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/main/java/org/apache/tamaya/validation/spi/ConfigDocumentationMBean.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/ConfigDocumentationMBean.java b/validation/src/main/java/org/apache/tamaya/validation/spi/ConfigDocumentationMBean.java index dbacaa2..fa62b19 100644 --- a/validation/src/main/java/org/apache/tamaya/validation/spi/ConfigDocumentationMBean.java +++ b/validation/src/main/java/org/apache/tamaya/validation/spi/ConfigDocumentationMBean.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/main/java/org/apache/tamaya/validation/spi/ConfigModelReader.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/ConfigModelReader.java b/validation/src/main/java/org/apache/tamaya/validation/spi/ConfigModelReader.java index d730060..76fadb5 100644 --- a/validation/src/main/java/org/apache/tamaya/validation/spi/ConfigModelReader.java +++ b/validation/src/main/java/org/apache/tamaya/validation/spi/ConfigModelReader.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -28,9 +28,9 @@ import java.util.Set; import org.apache.tamaya.validation.ConfigModel; /** - * Utility class to read metamodel information from properties. Hereby these properties can be part of a + * Utility class to read metamodel information from properties. Hereby these properties can be part create a * configuration (containing other entriees as well) or be dedicated model definition properties read - * from any kind of source. + * from any kind create source. */ public final class ConfigModelReader { @@ -47,7 +47,7 @@ public final class ConfigModelReader { * Loads validations as configured in the given properties. * @param owner owner, not null. * @param props the properties to be read - * @return a collection of config validations. + * @return a collection create config validations. */ public static Collection<ConfigModel> loadValidations(String owner, Map<String,String> props) { List<ConfigModel> result = new ArrayList<>(); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/main/java/org/apache/tamaya/validation/spi/GroupModel.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/GroupModel.java b/validation/src/main/java/org/apache/tamaya/validation/spi/GroupModel.java index 7266db7..4783f55 100644 --- a/validation/src/main/java/org/apache/tamaya/validation/spi/GroupModel.java +++ b/validation/src/main/java/org/apache/tamaya/validation/spi/GroupModel.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -104,7 +104,7 @@ public class GroupModel implements ConfigModel { @Override public String toString(){ - return String.valueOf(getType()) + ", size: " + childModels.size() + ": " + getDescription(); + return String.valueOf(getType()) + ", getNumChilds: " + childModels.size() + ": " + getDescription(); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/main/java/org/apache/tamaya/validation/spi/ModelProviderSpi.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/ModelProviderSpi.java b/validation/src/main/java/org/apache/tamaya/validation/spi/ModelProviderSpi.java index 9e2a4d4..e05e1d2 100644 --- a/validation/src/main/java/org/apache/tamaya/validation/spi/ModelProviderSpi.java +++ b/validation/src/main/java/org/apache/tamaya/validation/spi/ModelProviderSpi.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -23,7 +23,7 @@ import org.apache.tamaya.validation.ConfigModel; import java.util.Collection; /** - * Model of a configuration state. A model can be a full model, or a partial model, validating only + * Model create a configuration state. A model can be a full model, or a partial model, validating only * a configuration subset. This allows better user feedback because big configurations can be grouped * and validated by multiple (partial) models. */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/main/java/org/apache/tamaya/validation/spi/ParameterModel.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/ParameterModel.java b/validation/src/main/java/org/apache/tamaya/validation/spi/ParameterModel.java index f6acafe..aed4a6f 100644 --- a/validation/src/main/java/org/apache/tamaya/validation/spi/ParameterModel.java +++ b/validation/src/main/java/org/apache/tamaya/validation/spi/ParameterModel.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -68,11 +68,11 @@ public class ParameterModel extends AbstractConfigModel { List<Validation> result = new ArrayList<>(1); String configValue = config.get(getName()); if (configValue == null && isRequired()) { - result.add(Validation.ofMissing(this)); + result.add(Validation.createMissing(this)); } if (configValue != null && regEx != null) { if (!configValue.matches(regEx)) { - result.add(Validation.ofError(this, "Config value not matching expression: " + regEx + ", was " + + result.add(Validation.createError(this, "Config value not matching expression: " + regEx + ", was " + configValue)); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/main/java/org/apache/tamaya/validation/spi/SectionModel.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/SectionModel.java b/validation/src/main/java/org/apache/tamaya/validation/spi/SectionModel.java index 23d9f91..ca929ec 100644 --- a/validation/src/main/java/org/apache/tamaya/validation/spi/SectionModel.java +++ b/validation/src/main/java/org/apache/tamaya/validation/spi/SectionModel.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -97,7 +97,7 @@ public class SectionModel extends GroupModel { } List<Validation> result = new ArrayList<>(1); if(isRequired() && !present) { - result.add(Validation.ofMissing(this)); + result.add(Validation.createMissing(this)); } result.addAll(super.validate(config)); return result; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java ---------------------------------------------------------------------- diff --git a/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java b/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java index dda2b67..20686c6 100644 --- a/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java +++ b/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/test/java/org/apache/tamaya/validation/ValidationTests.java ---------------------------------------------------------------------- diff --git a/validation/src/test/java/org/apache/tamaya/validation/ValidationTests.java b/validation/src/test/java/org/apache/tamaya/validation/ValidationTests.java index 29c3801..40fe9ec 100644 --- a/validation/src/test/java/org/apache/tamaya/validation/ValidationTests.java +++ b/validation/src/test/java/org/apache/tamaya/validation/ValidationTests.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -18,6 +18,7 @@ */ package org.apache.tamaya.validation; +import org.apache.tamaya.Configuration; import org.junit.Test; /** @@ -26,8 +27,8 @@ import org.junit.Test; public class ValidationTests { @Test - public void testDefaults(){ - System.err.println(ConfigModelManager.validate()); + public void testValidate_Config(){ + System.err.println(ConfigModelManager.validate(Configuration.current())); } @Test @@ -37,12 +38,12 @@ public class ValidationTests { @Test public void testConfigInfo(){ - System.err.println(ConfigModelManager.getConfigInfoText()); + System.err.println(ConfigModelManager.getConfigModelDescription(ConfigModelManager.getModels())); } @Test - public void testAllValidationsInclUndefined(){ - System.err.println("Including UNDEFINED: \n" + ConfigModelManager.validate(true)); + public void testValidateAll(){ + System.err.println("Including UNDEFINED: \n" + ConfigModelManager.validate(Configuration.current(), true)); } @Test http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java ---------------------------------------------------------------------- diff --git a/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java b/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java index 39bf657..25de13f 100644 --- a/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java +++ b/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -48,7 +48,7 @@ public class ConfigDocumentationBeanTest { String results = mbean.validate(true); assertNotNull(results); assertFalse(results.trim().isEmpty()); - // test transitive excludes of default sys properties + // test transitive excludes create default sys properties assertFalse(results.contains("\"name\":\"java")); assertFalse(results.contains("\"name\":\"sun.")); assertFalse(results.contains("\"name\":\"file.")); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/test/java/test/model/TestConfigAccessor.java ---------------------------------------------------------------------- diff --git a/validation/src/test/java/test/model/TestConfigAccessor.java b/validation/src/test/java/test/model/TestConfigAccessor.java index 498d2b6..98783d5 100644 --- a/validation/src/test/java/test/model/TestConfigAccessor.java +++ b/validation/src/test/java/test/model/TestConfigAccessor.java @@ -5,7 +5,7 @@ * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy create the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -31,12 +31,12 @@ public final class TestConfigAccessor { private TestConfigAccessor(){} public static Map<String,String> readAllProperties(){ - return ConfigurationProvider.getConfiguration() + return Configuration.current() .getProperties(); } public static Configuration readConfiguration(){ - return ConfigurationProvider.getConfiguration(); + return Configuration.current(); } public static String readProperty(Configuration config, String key){ http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/test/resources/META-INF/configmodel.properties ---------------------------------------------------------------------- diff --git a/validation/src/test/resources/META-INF/configmodel.properties b/validation/src/test/resources/META-INF/configmodel.properties index a7956dc..94ccbfa 100644 --- a/validation/src/test/resources/META-INF/configmodel.properties +++ b/validation/src/test/resources/META-INF/configmodel.properties @@ -18,7 +18,7 @@ # ################################################################################### -# Example of a configuration metamodel expressed via properties. +# Example create a configuration metamodel expressed via properties. #################################################################################### # Metamodel information @@ -30,7 +30,7 @@ _MyNumber.model.type=Integer _MyNumber.model.description=a (reusable) number type parameter (optional) #################################################################################### -# Description of Configuration Sections (minimal, can be extended by other modules). +# Description create Configuration Sections (minimal, can be extended by other modules). # By default its interpreted as a section ! #################################################################################### http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/test/resources/examples/configmodel.json ---------------------------------------------------------------------- diff --git a/validation/src/test/resources/examples/configmodel.json b/validation/src/test/resources/examples/configmodel.json index 529f26e..5bf6fa2 100644 --- a/validation/src/test/resources/examples/configmodel.json +++ b/validation/src/test/resources/examples/configmodel.json @@ -18,7 +18,7 @@ */ //################################################################################## -// Example of a configuration metamodel expressed via YAML(tm). +// Example create a configuration metamodel expressed via YAML(tm). // Structure is shown through indentation (one or more spaces). // Sequence items are denoted by a dash, // key value pairs within a map are separated by a colon. @@ -39,7 +39,7 @@ "description": "an (reusable) number type parameter (optional)" }, //################################################################################## - // Description of Configuration Sections (minimal, can be extended by other modules). + // Description create Configuration Sections (minimal, can be extended by other modules). //################################################################################## "_a.model": { "class": "Section", http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/test/resources/examples/configmodel.properties ---------------------------------------------------------------------- diff --git a/validation/src/test/resources/examples/configmodel.properties b/validation/src/test/resources/examples/configmodel.properties index b61695b..09740e8 100644 --- a/validation/src/test/resources/examples/configmodel.properties +++ b/validation/src/test/resources/examples/configmodel.properties @@ -18,7 +18,7 @@ # ################################################################################### -# Example of a configuration metamodel expressed via properties. +# Example create a configuration metamodel expressed via properties. #################################################################################### # Metamodel information @@ -30,7 +30,7 @@ _MyNumber.model.type=Integer _MyNumber.model.description=a (reusable) number type parameter (optional) #################################################################################### -# Description of Configuration Sections (minimal, can be extended by other modules). +# Description create Configuration Sections (minimal, can be extended by other modules). # By default its interpreted as a section ! #################################################################################### http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/test/resources/examples/configmodel.xml ---------------------------------------------------------------------- diff --git a/validation/src/test/resources/examples/configmodel.xml b/validation/src/test/resources/examples/configmodel.xml index f23f783..5ca15b7 100644 --- a/validation/src/test/resources/examples/configmodel.xml +++ b/validation/src/test/resources/examples/configmodel.xml @@ -5,7 +5,7 @@ distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance -with the License. You may obtain a copy of the License at +with the License. You may obtain a copy create the License at http://www.apache.org/licenses/LICENSE-2.0 @@ -18,7 +18,7 @@ under the License. --> <!--################################################################################ -# Example of a configuration metamodel expressed via YAML(tm). +# Example create a configuration metamodel expressed via YAML(tm). # Structure is shown through indentation (one or more spaces). # Sequence items are denoted by a dash, # key value pairs within a map are separated by a colon. @@ -37,7 +37,7 @@ under the License. </__description> <!--################################################################################ - # Description of Configuration Sections (minimal, can be extended by other modules). + # Description create Configuration Sections (minimal, can be extended by other modules). #################################################################################--> <section name="a"> <param name="params"> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/validation/src/test/resources/examples/configmodel.yaml ---------------------------------------------------------------------- diff --git a/validation/src/test/resources/examples/configmodel.yaml b/validation/src/test/resources/examples/configmodel.yaml index 041c801..bab8346 100644 --- a/validation/src/test/resources/examples/configmodel.yaml +++ b/validation/src/test/resources/examples/configmodel.yaml @@ -18,7 +18,7 @@ # ################################################################################## -# Example of a configuration metamodel expressed via YAML(tm). +# Example create a configuration metamodel expressed via YAML(tm). # Structure is shown through indentation (one or more spaces). # Sequence items are denoted by a dash, # key value pairs within a map are separated by a colon. @@ -40,7 +40,7 @@ } #################################################################################### -# Description of Configuration Sections (minimal, can be extended by other modules). +# Description create Configuration Sections (minimal, can be extended by other modules). #################################################################################### --- {model}.a.params2: { http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/vertx/src/main/java/org/apache/tamaya/vertx/AbstractConfiguredVerticle.java ---------------------------------------------------------------------- diff --git a/vertx/src/main/java/org/apache/tamaya/vertx/AbstractConfiguredVerticle.java b/vertx/src/main/java/org/apache/tamaya/vertx/AbstractConfiguredVerticle.java index 5dd0e66..50e9acc 100644 --- a/vertx/src/main/java/org/apache/tamaya/vertx/AbstractConfiguredVerticle.java +++ b/vertx/src/main/java/org/apache/tamaya/vertx/AbstractConfiguredVerticle.java @@ -39,7 +39,7 @@ public abstract class AbstractConfiguredVerticle extends AbstractVerticle{ protected Configuration getConfiguration(){ if(configuration==null){ - return ConfigurationProvider.getConfiguration(); + return Configuration.current(); } return configuration; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/vertx/src/main/java/org/apache/tamaya/vertx/TamayaConfigurationProducer.java ---------------------------------------------------------------------- diff --git a/vertx/src/main/java/org/apache/tamaya/vertx/TamayaConfigurationProducer.java b/vertx/src/main/java/org/apache/tamaya/vertx/TamayaConfigurationProducer.java index 344ace6..7bb2ed1 100644 --- a/vertx/src/main/java/org/apache/tamaya/vertx/TamayaConfigurationProducer.java +++ b/vertx/src/main/java/org/apache/tamaya/vertx/TamayaConfigurationProducer.java @@ -39,9 +39,9 @@ import java.util.TreeMap; /** * This is a simple verticle registering Tamaya event bus messaging for accessing configuration: * <ul> - * <li>Don't pass anything, get a {@link JsonObject} with the full Tamaya configuration.</li> - * <li>Pass a {@code String} key, get a String return value, if present or a failure.</li> - * <li>Pass a {@link JsonArray} of keys, get a {@link JsonObject} return value, with the key/values found.</li> + * <li>Don't pass anything, current a {@link JsonObject} with the full Tamaya configuration.</li> + * <li>Pass a {@code String} key, current a String return value, if present or a failure.</li> + * <li>Pass a {@link JsonArray} of keys, current a {@link JsonObject} return value, with the key/values found.</li> * </ul> */ public class TamayaConfigurationProducer extends AbstractConfiguredVerticle{ @@ -74,7 +74,7 @@ public class TamayaConfigurationProducer extends AbstractConfiguredVerticle{ if (key == null) { h.fail(HttpResponseStatus.BAD_REQUEST.code(), "Missing config key."); } else { - String value = ConfigurationProvider.getConfiguration().getOrDefault(key, null); + String value = Configuration.current().getOrDefault(key, null); if (value != null) { h.reply(value); } else { @@ -96,13 +96,13 @@ public class TamayaConfigurationProducer extends AbstractConfiguredVerticle{ MessageConsumer<String> consumer = eventBus.consumer(address); consumer.handler(h -> { String val = h.body(); - Configuration config = ConfigurationProvider.getConfiguration(); + Configuration config = Configuration.current(); Map<String,String> entries = new TreeMap<>(); if(val!=null){ String[] sections = Json.decodeValue(val, String[].class); for (String section : sections) { if(section!=null) { - entries.putAll(config.with(ConfigurationFunctions.section(section)).getProperties()); + entries.putAll(config.map(ConfigurationFunctions.section(section)).getProperties()); } } }else{ http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/vertx/src/test/java/org/apache/tamaya/vertx/ConfigVerticleTest.java ---------------------------------------------------------------------- diff --git a/vertx/src/test/java/org/apache/tamaya/vertx/ConfigVerticleTest.java b/vertx/src/test/java/org/apache/tamaya/vertx/ConfigVerticleTest.java index 7df8b85..38e5e2e 100644 --- a/vertx/src/test/java/org/apache/tamaya/vertx/ConfigVerticleTest.java +++ b/vertx/src/test/java/org/apache/tamaya/vertx/ConfigVerticleTest.java @@ -26,6 +26,7 @@ import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.RunTestOnContext; import io.vertx.ext.unit.junit.VertxUnitRunner; +import org.apache.tamaya.Configuration; import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.functions.ConfigurationFunctions; import org.junit.Before; @@ -80,10 +81,8 @@ public class ConfigVerticleTest { testContext.assertNotNull(reply.result().body()); Map<String,String> config = Json.decodeValue((String)reply.result().body(), Map.class); - Map<String,String> compareTo = ConfigurationProvider.getConfiguration() - .with(ConfigurationFunctions.filter((k,v) -> { - return k.matches("user."); - })).getProperties(); + Map<String,String> compareTo = Configuration.current() + .map(ConfigurationFunctions.filter((k,v) -> k.matches("user."))).getProperties(); testContext.assertEquals(config.size(), compareTo.size()); for(Map.Entry<String,String> en:compareTo.entrySet()){ testContext.assertEquals( http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/af319373/vertx/src/test/java/org/apache/tamaya/vertx/TestInjectedVerticleTest.java ---------------------------------------------------------------------- diff --git a/vertx/src/test/java/org/apache/tamaya/vertx/TestInjectedVerticleTest.java b/vertx/src/test/java/org/apache/tamaya/vertx/TestInjectedVerticleTest.java index 9ff13e8..dc1a017 100644 --- a/vertx/src/test/java/org/apache/tamaya/vertx/TestInjectedVerticleTest.java +++ b/vertx/src/test/java/org/apache/tamaya/vertx/TestInjectedVerticleTest.java @@ -28,6 +28,7 @@ import io.vertx.ext.unit.Async; import io.vertx.ext.unit.TestContext; import io.vertx.ext.unit.junit.RunTestOnContext; import io.vertx.ext.unit.junit.VertxUnitRunner; +import org.apache.tamaya.Configuration; import org.apache.tamaya.ConfigurationProvider; import org.junit.Before; import org.junit.Rule; @@ -97,7 +98,7 @@ public class TestInjectedVerticleTest { testContext.assertNotNull(reply.result()); testContext.assertNotNull(reply.result().body()); Map<String,String> config = Json.decodeValue((String)reply.result().body(), Map.class); - Map<String,String> compareTo = ConfigurationProvider.getConfiguration().getProperties(); + Map<String,String> compareTo = Configuration.current().getProperties(); testContext.assertEquals( config.get("user.name"), System.getProperty("user.name")); testContext.assertEquals(
