TAMAYA-318 Moved spi-support as API base implementation package to remove code duplicates.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/2d0ef4b9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/2d0ef4b9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/2d0ef4b9 Branch: refs/heads/master Commit: 2d0ef4b92643989af0efa220944b9428f2c1cbf9 Parents: bad5fea Author: Anatole Tresch <anat...@apache.org> Authored: Tue Nov 14 00:13:20 2017 +0100 Committer: Anatole Tresch <anat...@apache.org> Committed: Tue Nov 14 10:27:18 2017 +0100 ---------------------------------------------------------------------- .../resources/MyPathPropertySourceProvider.java | 2 +- .../events/FilePropertySourceProvider.java | 2 +- modules/events/pom.xml | 2 +- .../events/ChangeableGlobalPropertySource.java | 2 +- .../ChangeableThreadLocalPropertySource.java | 2 +- .../tamaya/events/FrozenPropertySourceTest.java | 2 +- .../tamaya/events/PropertySourceChangeTest.java | 6 +- .../ObservingPropertySourceProvider.java | 2 +- modules/features/pom.xml | 2 +- modules/filter/pom.xml | 2 +- .../tamaya/filter/ProgrammableFilterTest.java | 3 +- modules/formats/base/pom.xml | 2 +- .../MappedConfigurationDataPropertySource.java | 2 +- modules/functions/pom.xml | 2 +- .../functions/CombinedConfigurationTest.java | 11 +- .../functions/ConfigurationFunctionsTest.java | 4 +- .../functions/MappedConfigurationTest.java | 7 - modules/injection/cdi/pom.xml | 2 +- .../tamaya/cdi/ConfigurationProducer.java | 13 +- modules/jndi/pom.xml | 2 +- .../apache/tamaya/jndi/JNDIPropertySource.java | 2 +- .../microprofile/MicroprofileConfigBuilder.java | 4 +- .../MicroprofileDefaultProperties.java | 2 +- .../microprofile/MicroprofileAdapterTest.java | 10 +- .../MicroprofileConfigSourceProviderTest.java | 4 +- modules/mutable-config/pom.xml | 2 +- .../MutablePropertiesPropertySource.java | 4 +- .../MutableXmlPropertiesPropertySource.java | 4 +- modules/osgi/common/pom.xml | 2 +- .../OSGIConfigAdminPropertySource.java | 2 +- .../src/main/features/features.xml | 2 +- modules/osgi/updater/pom.xml | 2 +- modules/pom.xml | 1 - modules/spi-support/bnd.bnd | 26 - .../tamaya/spisupport/BasePropertySource.java | 163 ------- .../spisupport/BuildablePropertySource.java | 231 --------- .../BuildablePropertySourceProvider.java | 114 ----- .../tamaya/spisupport/CLIPropertySource.java | 137 ------ .../tamaya/spisupport/ConfigValueEvaluator.java | 48 -- .../tamaya/spisupport/ConfigurationBuilder.java | 334 ------------- .../spisupport/DefaultConfigValueEvaluator.java | 70 --- .../tamaya/spisupport/DefaultConfiguration.java | 251 ---------- .../spisupport/DefaultConfigurationBuilder.java | 229 --------- .../spisupport/DefaultConfigurationContext.java | 300 ------------ .../DefaultConfigurationContextBuilder.java | 408 ---------------- .../apache/tamaya/spisupport/EnumConverter.java | 68 --- .../spisupport/EnvironmentPropertySource.java | 182 ------- .../tamaya/spisupport/MapPropertySource.java | 102 ---- .../spisupport/PriorityServiceComparator.java | 71 --- .../PropertiesResourcePropertySource.java | 109 ----- .../spisupport/PropertyConverterManager.java | 469 ------------------- .../spisupport/PropertyFilterComparator.java | 72 --- .../tamaya/spisupport/PropertyFiltering.java | 124 ----- .../spisupport/PropertySourceComparator.java | 107 ----- .../tamaya/spisupport/RegexPropertyFilter.java | 84 ---- .../tamaya/spisupport/SimplePropertySource.java | 284 ----------- .../tamaya/spisupport/SystemPropertySource.java | 199 -------- .../java/org/apache/tamaya/spisupport/A.java | 29 -- .../java/org/apache/tamaya/spisupport/B.java | 29 -- .../spisupport/BasePropertySourceTest.java | 88 ---- .../BuildablePropertySourceProviderTest.java | 76 --- .../spisupport/BuildablePropertySourceTest.java | 88 ---- .../java/org/apache/tamaya/spisupport/C.java | 56 --- .../spisupport/CLIPropertySourceTest.java | 59 --- .../tamaya/spisupport/CTestConverter.java | 32 -- .../DefaultConfigurationContextTest.java | 177 ------- .../tamaya/spisupport/EnumConverterTest.java | 60 --- .../EnvironmentPropertySourceTest.java | 68 --- .../spisupport/MapPropertySourceTest.java | 77 --- .../PriorityServiceComparatorTest.java | 43 -- .../PropertiesFilePropertySourceTest.java | 60 --- .../PropertyConverterManagerTest.java | 180 ------- .../spisupport/RegexPropertyFilterTest.java | 70 --- .../spisupport/SimplePropertySourceTest.java | 86 ---- .../spisupport/SystemPropertySourceTest.java | 96 ---- .../spisupport/TestPropertyDefaultSource.java | 57 --- .../org.apache.tamaya.spi.PropertyConverter | 38 -- .../src/test/resources/invalid-properties.xml | 25 - .../src/test/resources/non-xml-properties.xml | 18 - .../test/resources/overrideOrdinal.properties | 25 - .../src/test/resources/testfile.properties | 22 - .../src/test/resources/valid-properties.xml | 25 - 82 files changed, 53 insertions(+), 5826 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/MyPathPropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/MyPathPropertySourceProvider.java b/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/MyPathPropertySourceProvider.java index b961121..0348157 100644 --- a/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/MyPathPropertySourceProvider.java +++ b/examples/01-resources-example/src/main/java/org/apache/tamaya/ext/examples/resources/MyPathPropertySourceProvider.java @@ -18,7 +18,7 @@ */ package org.apache.tamaya.ext.examples.resources; -import org.apache.tamaya.core.propertysource.SimplePropertySource; +import org.apache.tamaya.spisupport.propertysource.SimplePropertySource; import org.apache.tamaya.resource.AbstractPathPropertySourceProvider; import org.apache.tamaya.spi.PropertySource; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/examples/04-events-example/src/main/java/org/apache/tamaya/ext/examples/events/FilePropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/examples/04-events-example/src/main/java/org/apache/tamaya/ext/examples/events/FilePropertySourceProvider.java b/examples/04-events-example/src/main/java/org/apache/tamaya/ext/examples/events/FilePropertySourceProvider.java index 088ffe2..a15ad6e 100644 --- a/examples/04-events-example/src/main/java/org/apache/tamaya/ext/examples/events/FilePropertySourceProvider.java +++ b/examples/04-events-example/src/main/java/org/apache/tamaya/ext/examples/events/FilePropertySourceProvider.java @@ -20,7 +20,7 @@ package org.apache.tamaya.ext.examples.events; import org.apache.tamaya.ConfigException; -import org.apache.tamaya.core.propertysource.BasePropertySource; +import org.apache.tamaya.spisupport.propertysource.BasePropertySource; import org.apache.tamaya.resource.AbstractPathPropertySourceProvider; import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spi.PropertyValue; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/events/pom.xml ---------------------------------------------------------------------- diff --git a/modules/events/pom.xml b/modules/events/pom.xml index dd8bb41..aaa650f 100644 --- a/modules/events/pom.xml +++ b/modules/events/pom.xml @@ -44,7 +44,7 @@ under the License. <version>${project.version}</version> </dependency> <dependency> - <groupId>org.apache.tamaya.ext</groupId> + <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-spisupport</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java b/modules/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java index 180b36e..94a0a9d 100644 --- a/modules/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java +++ b/modules/events/src/test/java/org/apache/tamaya/events/ChangeableGlobalPropertySource.java @@ -18,7 +18,7 @@ */ package org.apache.tamaya.events; -import org.apache.tamaya.core.propertysource.BasePropertySource; +import org.apache.tamaya.spisupport.propertysource.BasePropertySource; import org.apache.tamaya.spi.PropertyValue; import java.util.Map; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java b/modules/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java index fe6f973..f8fd413 100644 --- a/modules/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java +++ b/modules/events/src/test/java/org/apache/tamaya/events/ChangeableThreadLocalPropertySource.java @@ -18,7 +18,7 @@ */ package org.apache.tamaya.events; -import org.apache.tamaya.core.propertysource.BasePropertySource; +import org.apache.tamaya.spisupport.propertysource.BasePropertySource; import org.apache.tamaya.spi.PropertyValue; import java.util.HashMap; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java ---------------------------------------------------------------------- diff --git a/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java b/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java index 88cee48..cdc70b8 100644 --- a/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java +++ b/modules/events/src/test/java/org/apache/tamaya/events/FrozenPropertySourceTest.java @@ -18,7 +18,7 @@ */ package org.apache.tamaya.events; -import org.apache.tamaya.core.propertysource.SystemPropertySource; +import org.apache.tamaya.spisupport.propertysource.SystemPropertySource; import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spi.PropertyValue; import org.apache.tamaya.spisupport.PropertySourceComparator; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/events/src/test/java/org/apache/tamaya/events/PropertySourceChangeTest.java ---------------------------------------------------------------------- diff --git a/modules/events/src/test/java/org/apache/tamaya/events/PropertySourceChangeTest.java b/modules/events/src/test/java/org/apache/tamaya/events/PropertySourceChangeTest.java index a8b230e..a1a9200 100644 --- a/modules/events/src/test/java/org/apache/tamaya/events/PropertySourceChangeTest.java +++ b/modules/events/src/test/java/org/apache/tamaya/events/PropertySourceChangeTest.java @@ -18,9 +18,9 @@ */ package org.apache.tamaya.events; -import org.apache.tamaya.core.propertysource.EnvironmentPropertySource; -import org.apache.tamaya.core.propertysource.SimplePropertySource; -import org.apache.tamaya.core.propertysource.SystemPropertySource; +import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource; +import org.apache.tamaya.spisupport.propertysource.SimplePropertySource; +import org.apache.tamaya.spisupport.propertysource.SystemPropertySource; import org.apache.tamaya.spi.PropertySource; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/events/src/test/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/modules/events/src/test/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java b/modules/events/src/test/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java index 7a60ea8..c821d43 100644 --- a/modules/events/src/test/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java +++ b/modules/events/src/test/java/org/apache/tamaya/events/folderobserver/ObservingPropertySourceProvider.java @@ -43,7 +43,7 @@ import org.apache.tamaya.ConfigException; import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spi.PropertySourceProvider; import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spisupport.BasePropertySource; +import org.apache.tamaya.spisupport.propertysource.BasePropertySource; /** * This implementation runs in a folder taking up all files compatible with the given http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/features/pom.xml ---------------------------------------------------------------------- diff --git a/modules/features/pom.xml b/modules/features/pom.xml index 6f15c0f..db616aa 100644 --- a/modules/features/pom.xml +++ b/modules/features/pom.xml @@ -108,7 +108,7 @@ under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.tamaya.ext</groupId> + <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-spisupport</artifactId> <version>${project.version}</version> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/filter/pom.xml ---------------------------------------------------------------------- diff --git a/modules/filter/pom.xml b/modules/filter/pom.xml index c19d4a2..88ebfa6 100644 --- a/modules/filter/pom.xml +++ b/modules/filter/pom.xml @@ -54,7 +54,7 @@ under the License. <artifactId>junit</artifactId> </dependency> <dependency> - <groupId>org.apache.tamaya.ext</groupId> + <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-spisupport</artifactId> <version>${project.version}</version> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java ---------------------------------------------------------------------- diff --git a/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java b/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java index f886ba0..9b25bb6 100644 --- a/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java +++ b/modules/filter/src/test/java/org/apache/tamaya/filter/ProgrammableFilterTest.java @@ -21,8 +21,7 @@ package org.apache.tamaya.filter; import org.apache.tamaya.spi.ConfigurationContext; import org.apache.tamaya.spi.PropertyFilter; import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spisupport.DefaultConfigurationContext; -import org.apache.tamaya.spisupport.DefaultConfigurationContextBuilder; +import org.apache.tamaya.core.internal.DefaultConfigurationContextBuilder; import org.apache.tamaya.spisupport.RegexPropertyFilter; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/formats/base/pom.xml ---------------------------------------------------------------------- diff --git a/modules/formats/base/pom.xml b/modules/formats/base/pom.xml index aa2c660..a2007ce 100644 --- a/modules/formats/base/pom.xml +++ b/modules/formats/base/pom.xml @@ -45,7 +45,7 @@ under the License. <version>${project.version}</version> </dependency> <dependency> - <groupId>org.apache.tamaya.ext</groupId> + <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-spisupport</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/formats/base/src/main/java/org/apache/tamaya/format/MappedConfigurationDataPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/formats/base/src/main/java/org/apache/tamaya/format/MappedConfigurationDataPropertySource.java b/modules/formats/base/src/main/java/org/apache/tamaya/format/MappedConfigurationDataPropertySource.java index 743f8cd..5bd6444 100644 --- a/modules/formats/base/src/main/java/org/apache/tamaya/format/MappedConfigurationDataPropertySource.java +++ b/modules/formats/base/src/main/java/org/apache/tamaya/format/MappedConfigurationDataPropertySource.java @@ -20,7 +20,7 @@ package org.apache.tamaya.format; import org.apache.tamaya.functions.Supplier; import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spisupport.BasePropertySource; +import org.apache.tamaya.spisupport.propertysource.BasePropertySource; import java.util.HashMap; import java.util.Map; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/functions/pom.xml ---------------------------------------------------------------------- diff --git a/modules/functions/pom.xml b/modules/functions/pom.xml index 957f3a3..05b38a5 100644 --- a/modules/functions/pom.xml +++ b/modules/functions/pom.xml @@ -46,7 +46,7 @@ under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.apache.tamaya.ext</groupId> + <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-spisupport</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/functions/src/test/java/org/apache/tamaya/functions/CombinedConfigurationTest.java ---------------------------------------------------------------------- diff --git a/modules/functions/src/test/java/org/apache/tamaya/functions/CombinedConfigurationTest.java b/modules/functions/src/test/java/org/apache/tamaya/functions/CombinedConfigurationTest.java index 04c6573..bb65d69 100644 --- a/modules/functions/src/test/java/org/apache/tamaya/functions/CombinedConfigurationTest.java +++ b/modules/functions/src/test/java/org/apache/tamaya/functions/CombinedConfigurationTest.java @@ -23,23 +23,16 @@ import org.apache.tamaya.ConfigQuery; import org.apache.tamaya.Configuration; import org.apache.tamaya.TypeLiteral; import org.apache.tamaya.spi.ConfigurationContext; -import org.apache.tamaya.spi.ConfigurationContextBuilder; import org.apache.tamaya.spisupport.DefaultConfiguration; -import org.apache.tamaya.spisupport.DefaultConfigurationContext; -import org.apache.tamaya.spisupport.DefaultConfigurationContextBuilder; -import org.apache.tamaya.spisupport.SimplePropertySource; +import org.apache.tamaya.core.internal.DefaultConfigurationContextBuilder; +import org.apache.tamaya.spisupport.propertysource.SimplePropertySource; import org.assertj.core.api.ThrowableAssert; import org.junit.Test; import org.mockito.Mockito; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import java.lang.reflect.Method; -import java.lang.reflect.Type; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import java.util.TreeMap; import static java.util.Arrays.asList; import static java.util.Collections.singletonMap; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java ---------------------------------------------------------------------- diff --git a/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java b/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java index 5850eb4..99cb944 100644 --- a/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java +++ b/modules/functions/src/test/java/org/apache/tamaya/functions/ConfigurationFunctionsTest.java @@ -20,8 +20,8 @@ package org.apache.tamaya.functions; import org.apache.tamaya.Configuration; import org.apache.tamaya.ConfigurationProvider; -import org.apache.tamaya.core.propertysource.EnvironmentPropertySource; -import org.apache.tamaya.core.propertysource.SystemPropertySource; +import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource; +import org.apache.tamaya.spisupport.propertysource.SystemPropertySource; import org.apache.tamaya.spi.ConfigurationContextBuilder; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/functions/src/test/java/org/apache/tamaya/functions/MappedConfigurationTest.java ---------------------------------------------------------------------- diff --git a/modules/functions/src/test/java/org/apache/tamaya/functions/MappedConfigurationTest.java b/modules/functions/src/test/java/org/apache/tamaya/functions/MappedConfigurationTest.java index c31077a..2a470a2 100644 --- a/modules/functions/src/test/java/org/apache/tamaya/functions/MappedConfigurationTest.java +++ b/modules/functions/src/test/java/org/apache/tamaya/functions/MappedConfigurationTest.java @@ -18,15 +18,8 @@ */ package org.apache.tamaya.functions; -import org.apache.tamaya.Configuration; -import org.apache.tamaya.spi.ConfigurationContext; -import org.apache.tamaya.spisupport.DefaultConfigurationContext; import org.junit.Test; -import org.mockito.Matchers; -import org.mockito.Mockito; -import org.mockito.internal.matchers.Null; -import static org.junit.Assert.*; import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doCallRealMethod; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/injection/cdi/pom.xml ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/pom.xml b/modules/injection/cdi/pom.xml index de1e318..e1e59a5 100644 --- a/modules/injection/cdi/pom.xml +++ b/modules/injection/cdi/pom.xml @@ -105,7 +105,7 @@ under the License. <scope>provided</scope> </dependency> <dependency> - <groupId>org.apache.tamaya.ext</groupId> + <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-spisupport</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/injection/cdi/src/main/java/org/apache/tamaya/cdi/ConfigurationProducer.java ---------------------------------------------------------------------- diff --git a/modules/injection/cdi/src/main/java/org/apache/tamaya/cdi/ConfigurationProducer.java b/modules/injection/cdi/src/main/java/org/apache/tamaya/cdi/ConfigurationProducer.java index ea6a81c..279f04b 100644 --- a/modules/injection/cdi/src/main/java/org/apache/tamaya/cdi/ConfigurationProducer.java +++ b/modules/injection/cdi/src/main/java/org/apache/tamaya/cdi/ConfigurationProducer.java @@ -30,6 +30,7 @@ import javax.enterprise.inject.spi.InjectionPoint; import javax.inject.Provider; import java.lang.reflect.*; import java.util.List; +import java.util.Optional; import java.util.logging.Level; import java.util.logging.Logger; @@ -147,12 +148,17 @@ public class ConfigurationProducer { return textValue; } Object value = null; + ParameterizedType pt = null; Type toType = injectionPoint.getAnnotated().getBaseType(); if(toType instanceof ParameterizedType){ - ParameterizedType pt = (ParameterizedType)toType; - if(Provider.class.equals(pt.getRawType()) || Instance.class.equals(pt.getRawType())){ + pt = (ParameterizedType)toType; + if(Provider.class.equals(pt.getRawType()) || Instance.class.equals(pt.getRawType()) + || Optional.class.equals(pt.getRawType())){ toType = pt.getActualTypeArguments()[0]; } + if(toType.equals(String.class)){ + value = textValue; + } } List<PropertyConverter<Object>> converters = ConfigurationProvider.getConfiguration().getContext() .getPropertyConverters(TypeLiteral.of(toType)); @@ -169,6 +175,9 @@ public class ConfigurationProducer { injectionPoint, e); } } + if(pt != null && Optional.class.equals(pt.getRawType())){ + return Optional.ofNullable(value); + } return value; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/jndi/pom.xml ---------------------------------------------------------------------- diff --git a/modules/jndi/pom.xml b/modules/jndi/pom.xml index 3e6c46a..805729b 100644 --- a/modules/jndi/pom.xml +++ b/modules/jndi/pom.xml @@ -54,7 +54,7 @@ under the License. <artifactId>junit</artifactId> </dependency> <dependency> - <groupId>org.apache.tamaya.ext</groupId> + <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-spisupport</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/jndi/src/main/java/org/apache/tamaya/jndi/JNDIPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/jndi/src/main/java/org/apache/tamaya/jndi/JNDIPropertySource.java b/modules/jndi/src/main/java/org/apache/tamaya/jndi/JNDIPropertySource.java index 00ad746..d2b549b 100644 --- a/modules/jndi/src/main/java/org/apache/tamaya/jndi/JNDIPropertySource.java +++ b/modules/jndi/src/main/java/org/apache/tamaya/jndi/JNDIPropertySource.java @@ -33,7 +33,7 @@ import javax.naming.NamingException; import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spisupport.BasePropertySource; +import org.apache.tamaya.spisupport.propertysource.BasePropertySource; import org.osgi.service.component.annotations.Component; /** http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConfigBuilder.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConfigBuilder.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConfigBuilder.java index 896311c..82209c3 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConfigBuilder.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConfigBuilder.java @@ -22,9 +22,9 @@ import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.TypeLiteral; import org.apache.tamaya.spi.ConfigurationContextBuilder; import org.apache.tamaya.spi.ServiceContextManager; -import org.apache.tamaya.spisupport.EnvironmentPropertySource; +import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource; import org.apache.tamaya.spisupport.PropertySourceComparator; -import org.apache.tamaya.spisupport.SystemPropertySource; +import org.apache.tamaya.spisupport.propertysource.SystemPropertySource; import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.spi.ConfigBuilder; import org.eclipse.microprofile.config.spi.ConfigSource; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileDefaultProperties.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileDefaultProperties.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileDefaultProperties.java index cfe06bd..b20dc8f 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileDefaultProperties.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileDefaultProperties.java @@ -18,7 +18,7 @@ */ package org.apache.tamaya.microprofile; -import org.apache.tamaya.spisupport.PropertiesResourcePropertySource; +import org.apache.tamaya.spisupport.propertysource.PropertiesResourcePropertySource; /** http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileAdapterTest.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileAdapterTest.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileAdapterTest.java index d227b42..8fea044 100644 --- a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileAdapterTest.java +++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileAdapterTest.java @@ -18,11 +18,12 @@ */ package org.apache.tamaya.microprofile; -import org.apache.tamaya.*; -import org.apache.tamaya.spi.ConfigurationContext; +import org.apache.tamaya.Configuration; +import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.spi.PropertyConverter; import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spi.PropertyValue; +import org.apache.tamaya.spisupport.propertysource.BuildablePropertySource; import org.apache.tamaya.spisupport.BuildablePropertySource; import org.assertj.core.api.Assertions; import org.eclipse.microprofile.config.Config; @@ -32,7 +33,10 @@ import org.eclipse.microprofile.config.spi.ConfigSource; import org.eclipse.microprofile.config.spi.Converter; import org.junit.Test; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static org.junit.Assert.*; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigSourceProviderTest.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigSourceProviderTest.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigSourceProviderTest.java index c62b390..ab792aa 100644 --- a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigSourceProviderTest.java +++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/MicroprofileConfigSourceProviderTest.java @@ -18,8 +18,8 @@ */ package org.apache.tamaya.microprofile; -import org.apache.tamaya.spisupport.BuildablePropertySource; -import org.apache.tamaya.spisupport.BuildablePropertySourceProvider; +import org.apache.tamaya.spisupport.propertysource.BuildablePropertySource; +import org.apache.tamaya.spisupport.propertysource.BuildablePropertySourceProvider; import org.eclipse.microprofile.config.spi.ConfigSource; import org.junit.Test; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/mutable-config/pom.xml ---------------------------------------------------------------------- diff --git a/modules/mutable-config/pom.xml b/modules/mutable-config/pom.xml index ab467cf..ef74d57 100644 --- a/modules/mutable-config/pom.xml +++ b/modules/mutable-config/pom.xml @@ -39,7 +39,7 @@ under the License. <version>${tamaya-apicore.version}</version> </dependency> <dependency> - <groupId>org.apache.tamaya.ext</groupId> + <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-spisupport</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutablePropertiesPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutablePropertiesPropertySource.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutablePropertiesPropertySource.java index 39b840c..659dab2 100644 --- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutablePropertiesPropertySource.java +++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutablePropertiesPropertySource.java @@ -22,8 +22,7 @@ import org.apache.tamaya.ConfigException; import org.apache.tamaya.mutableconfig.ConfigChangeRequest; import org.apache.tamaya.mutableconfig.spi.MutablePropertySource; import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spi.PropertyValueBuilder; -import org.apache.tamaya.spisupport.BasePropertySource; +import org.apache.tamaya.spisupport.propertysource.BasePropertySource; import java.io.BufferedOutputStream; import java.io.File; @@ -31,7 +30,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.Map; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutableXmlPropertiesPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutableXmlPropertiesPropertySource.java b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutableXmlPropertiesPropertySource.java index 96ac691..bcba53a 100644 --- a/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutableXmlPropertiesPropertySource.java +++ b/modules/mutable-config/src/main/java/org/apache/tamaya/mutableconfig/propertysources/MutableXmlPropertiesPropertySource.java @@ -22,8 +22,7 @@ import org.apache.tamaya.ConfigException; import org.apache.tamaya.mutableconfig.ConfigChangeRequest; import org.apache.tamaya.mutableconfig.spi.MutablePropertySource; import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spi.PropertyValueBuilder; -import org.apache.tamaya.spisupport.BasePropertySource; +import org.apache.tamaya.spisupport.propertysource.BasePropertySource; import java.io.BufferedOutputStream; import java.io.File; @@ -31,7 +30,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.Map; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/osgi/common/pom.xml ---------------------------------------------------------------------- diff --git a/modules/osgi/common/pom.xml b/modules/osgi/common/pom.xml index 622907b..57c56c3 100644 --- a/modules/osgi/common/pom.xml +++ b/modules/osgi/common/pom.xml @@ -67,7 +67,7 @@ <version>${project.parent.version}</version> </dependency> <dependency> - <groupId>org.apache.tamaya.ext</groupId> + <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-spisupport</artifactId> <version>${project.parent.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java index 529468e..6c5b00a 100644 --- a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java +++ b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySource.java @@ -19,7 +19,7 @@ package org.apache.tamaya.osgi.injection; import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spisupport.BasePropertySource; +import org.apache.tamaya.spisupport.propertysource.BasePropertySource; import org.osgi.service.cm.Configuration; import org.osgi.service.cm.ConfigurationAdmin; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/osgi/karaf-features/src/main/features/features.xml ---------------------------------------------------------------------- diff --git a/modules/osgi/karaf-features/src/main/features/features.xml b/modules/osgi/karaf-features/src/main/features/features.xml index 20c5ee3..34949b7 100644 --- a/modules/osgi/karaf-features/src/main/features/features.xml +++ b/modules/osgi/karaf-features/src/main/features/features.xml @@ -20,7 +20,7 @@ limitations under the License. <features name="org-apache-tamaya-configadmin" version="0.4-incubating"> <bundle>mvn:org.apache.tamaya.ext/tamaya-osgi_alpha/0.4-incubating/jar</bundle> <bundle>mvn:org.apache.tamaya.ext/tamaya-functions/0.4-incubating/jar</bundle> - <bundle>mvn:org.apache.tamaya.ext/tamaya-spisupport/0.4-incubating/jar</bundle> + <bundle>mvn:org.apache.tamaya/tamaya-spisupport/0.4-incubating/jar</bundle> <bundle>mvn:org.apache.tamaya.ext/tamaya-osgi-karaf_alpha/0.4-incubating/jar</bundle> <features name="org-apache-tamaya-minimal" version="0.4-incubating"> <feature name="org-apache-tamaya-api" version="0.4-incubating"> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/osgi/updater/pom.xml ---------------------------------------------------------------------- diff --git a/modules/osgi/updater/pom.xml b/modules/osgi/updater/pom.xml index 18d5370..2819239 100644 --- a/modules/osgi/updater/pom.xml +++ b/modules/osgi/updater/pom.xml @@ -58,7 +58,7 @@ <version>${project.parent.version}</version> </dependency> <dependency> - <groupId>org.apache.tamaya.ext</groupId> + <groupId>org.apache.tamaya</groupId> <artifactId>tamaya-spisupport</artifactId> <version>${project.parent.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/pom.xml ---------------------------------------------------------------------- diff --git a/modules/pom.xml b/modules/pom.xml index f5d9ffc..25a4541 100644 --- a/modules/pom.xml +++ b/modules/pom.xml @@ -34,7 +34,6 @@ under the License. <modules> <module>features</module> <module>functions</module> - <module>spi-support</module> <module>optional</module> <module>events</module> <module>filter</module> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/spi-support/bnd.bnd ---------------------------------------------------------------------- diff --git a/modules/spi-support/bnd.bnd b/modules/spi-support/bnd.bnd deleted file mode 100644 index 1ce81a3..0000000 --- a/modules/spi-support/bnd.bnd +++ /dev/null @@ -1,26 +0,0 @@ --buildpath: \ - osgi.annotation; version=6.0.0,\ - osgi.core; version=6.0,\ - osgi.cmpn; version=6.0 - --testpath: \ - ${junit} - -javac.source: 1.8 -javac.target: 1.8 - -Bundle-Version: ${version}.${tstamp} -Bundle-Name: Apache Tamaya - SPI Support -Bundle-SymbolicName: org.apache.tamaya.spisupport -Bundle-Description: Apacha Tamaya Config - SPI Support -Bundle-Category: Implementation -Bundle-Copyright: (C) Apache Foundation -Bundle-License: Apache Licence version 2 -Bundle-Vendor: Apache Software Foundation -Bundle-ContactAddress: dev-tam...@incubator.apache.org -Bundle-DocURL: http://tamaya.apache.org -Export-Package: \ - org.apache.tamaya.spisupport -Import-Package: \ - org.apache.tamaya,\ - org.apache.tamaya.spi http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java ---------------------------------------------------------------------- diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java deleted file mode 100644 index 14c3764..0000000 --- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BasePropertySource.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.spisupport; - -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spi.PropertyValueBuilder; - -import java.util.Map; -import java.util.Objects; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Abstract {@link org.apache.tamaya.spi.PropertySource} that allows to set a default ordinal that will be used, if no - * ordinal is provided with the config. - */ -public abstract class BasePropertySource implements PropertySource{ - /** default ordinal that will be used, if no ordinal is provided with the config. */ - private int defaultOrdinal; - /** Used if the ordinal has been set explicitly. */ - private volatile Integer ordinal; - /** The name of the property source. */ - private String name; - - /** - * Constructor. - * @param name the (unique) property source name, not null. - */ - protected BasePropertySource(String name){ - this.name = Objects.requireNonNull(name); - this.defaultOrdinal = 0; - } - - /** - * Constructor. - * @param defaultOrdinal default ordinal that will be used, if no ordinal is provided with the config. - */ - protected BasePropertySource(int defaultOrdinal){ - this.name = getClass().getSimpleName(); - this.defaultOrdinal = defaultOrdinal; - } - - /** - * Constructor. - * @param name the (unique) property source name, not null. - * @param defaultOrdinal default ordinal that will be used, if no ordinal is provided with the config. - */ - protected BasePropertySource(String name, int defaultOrdinal){ - this.name = Objects.requireNonNull(name); - this.defaultOrdinal = defaultOrdinal; - } - - - /** - * Constructor, using a default ordinal of 0. - */ - protected BasePropertySource(){ - this(0); - } - - @Override - public String getName() { - return name; - } - - /** - * Sets the property source's (unique) name. - * @param name the name, not null. - */ - public void setName(String name){ - this.name = Objects.requireNonNull(name); - } - - /** - * Allows to set the ordinal of this property source explcitly. This will override any evaluated - * ordinal, or default ordinal. To reset an explcit ordinal call {@code setOrdinal(null);}. - * @param ordinal the explicit ordinal, or null. - */ - public void setOrdinal(Integer ordinal){ - this.ordinal = ordinal; - } - - /** - * Allows to set the ordinal of this property source explcitly. This will override any evaluated - * ordinal, or default ordinal. To reset an explcit ordinal call {@code setOrdinal(null);}. - * @param defaultOrdinal the default ordinal, or null. - */ - public void setDefaultOrdinal(Integer defaultOrdinal){ - this.defaultOrdinal = defaultOrdinal; - } - - public int getOrdinal() { - Integer ordinal = this.ordinal; - if(ordinal!=null){ - Logger.getLogger(getClass().getName()).finest( - "Using explicit ordinal '"+ordinal+"' for property source: " + getName()); - return ordinal; - } - PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL); - if(configuredOrdinal!=null){ - try { - return Integer.parseInt(configuredOrdinal.getValue()); - } catch (Exception e) { - Logger.getLogger(getClass().getName()).log(Level.WARNING, - "Configured Ordinal is not an int number: " + configuredOrdinal, e); - } - } - return getDefaultOrdinal(); - } - - /** - * Returns the default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value. - * @return the default ordinal used, by default 0. - */ - public int getDefaultOrdinal(){ - return defaultOrdinal; - } - - @Override - public PropertyValue get(String key) { - Map<String,PropertyValue> properties = getProperties(); - PropertyValue val = properties.get(key); - if(val==null){ - return null; - } - return val; - } - - @Override - public boolean isScannable(){ - return true; - } - - @Override - public String toString() { - return getClass().getSimpleName() + "{" + - toStringValues() + - '}'; - } - - protected String toStringValues() { - return " defaultOrdinal=" + defaultOrdinal + '\n' + - " ordinal=" + ordinal + '\n' + - " name='" + name + '\'' + '\n'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BuildablePropertySource.java ---------------------------------------------------------------------- diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BuildablePropertySource.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BuildablePropertySource.java deleted file mode 100644 index b7b4129..0000000 --- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BuildablePropertySource.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.spisupport; - -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertyValue; - -import java.util.*; - -/** - * A Buildable property source. - */ -public class BuildablePropertySource implements PropertySource{ - - private int ordinal; - private String name = "PropertySource-"+UUID.randomUUID().toString(); - private Map<String,PropertyValue> properties = new HashMap<>(); - - @Override - public int getOrdinal() { - return ordinal; - } - - @Override - public String getName() { - return name; - } - - @Override - public PropertyValue get(String key) { - return properties.get(key); - } - - @Override - public Map<String, PropertyValue> getProperties() { - return Collections.unmodifiableMap(properties); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - BuildablePropertySource that = (BuildablePropertySource) o; - - return name.equals(that.name); - } - - @Override - public boolean isScannable() { - return true; - } - - @Override - public int hashCode() { - return name.hashCode(); - } - - @Override - public String toString() { - return "BuildablePropertySource{" + - "ordinal=" + ordinal + - ", name='" + name + '\'' + - ", properties=" + properties + - '}'; - } - - /** - * Builder builder. - * - * @return the builder - */ - public static Builder builder() { - return new Builder(); - } - - - /** - * The type Builder. - */ - public static final class Builder { - private int ordinal; - private String source = "<on-the-fly-build>"; - private String name = "PropertySource-"+ UUID.randomUUID().toString(); - private Map<String,PropertyValue> properties = new HashMap<>(); - - private Builder() { - } - - /** - * With ordinal builder. - * - * @param ordinal the ordinal - * @return the builder - */ - public Builder withOrdinal(int ordinal) { - this.ordinal = ordinal; - return this; - } - - /** - * With source builder. - * - * @param source the source - * @return the builder - */ - public Builder withSource(String source) { - this.source = Objects.requireNonNull(source); - return this; - } - - /** - * With name builder. - * - * @param name the name - * @return the builder - */ - public Builder withName(String name) { - this.name = Objects.requireNonNull(name); - return this; - } - - /** - * With simple property builder. - * - * @param key the key - * @param value the value - * @return the builder - */ - public Builder withSimpleProperty(String key, String value) { - return withProperties(PropertyValue.of(key, value, this.source)); - } - - /** - * With simple property builder. - * - * @param key the key - * @param value the value - * @param source the source - * @return the builder - */ - public Builder withSimpleProperty(String key, String value, String source) { - return withProperties(PropertyValue.of(key, value, source)); - } - - /** - * With properties builder. - * - * @param values the values - * @return the builder - */ - public Builder withProperties(PropertyValue... values) { - for(PropertyValue val:values){ - this.properties.put(val.getKey(), val); - } - return this; - } - - /** - * With properties builder. - * - * @param properties the properties - * @return the builder - */ - public Builder withProperties(Map<String, PropertyValue> properties) { - this.properties = Objects.requireNonNull(properties); - return this; - } - - /** - * With properties builder. - * - * @param properties the properties - * @param source the source - * @return the builder - */ - public Builder withProperties(Map<String, String> properties, String source) { - this.properties.putAll(PropertyValue.map(properties, source)); - return this; - } - - /** - * With simple properties builder. - * - * @param properties the properties - * @return the builder - */ - public Builder withSimpleProperties(Map<String, String> properties) { - this.properties.putAll(PropertyValue.map(properties, this.source)); - return this; - } - - /** - * But builder. - * - * @return the builder - */ - public Builder but() { - return builder().withOrdinal(ordinal).withName(name).withProperties(properties); - } - - /** - * Build buildable property source. - * - * @return the buildable property source - */ - public BuildablePropertySource build() { - BuildablePropertySource buildablePropertySource = new BuildablePropertySource(); - buildablePropertySource.name = this.name; - buildablePropertySource.properties = this.properties; - buildablePropertySource.ordinal = this.ordinal; - return buildablePropertySource; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BuildablePropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BuildablePropertySourceProvider.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BuildablePropertySourceProvider.java deleted file mode 100644 index 8341a44..0000000 --- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/BuildablePropertySourceProvider.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.spisupport; - -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertySourceProvider; - -import java.util.*; - -/** - * A Buildable property source. - */ -public class BuildablePropertySourceProvider implements PropertySourceProvider{ - - private List<PropertySource> sources = new ArrayList<>(); - - @Override - public Collection<PropertySource> getPropertySources() { - return Collections.unmodifiableCollection(sources); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - BuildablePropertySourceProvider that = (BuildablePropertySourceProvider) o; - - return sources.equals(that.sources); - } - - @Override - public int hashCode() { - return sources.hashCode(); - } - - @Override - public String toString() { - return "BuildablePropertySourceProvider{" + - "sources=" + sources + - '}'; - } - - /** - * Builder builder. - * - * @return the builder - */ - public static Builder builder() { - return new Builder(); - } - - - - - /** - * The type Builder. - */ - public static final class Builder { - private List<PropertySource> sources = new ArrayList<>(); - - private Builder() { - } - - /** - * With propertySources. - * - * @param propertySources the propertySources - * @return the builder - */ - public Builder withPropertySourcs(PropertySource... propertySources) { - this.sources.addAll(Arrays.asList(propertySources)); - return this; - } - - /** - * With property sources builder. - * - * @param sources the property sources - * @return the builder - */ - public Builder withPropertySourcs(Collection<PropertySource> sources) { - this.sources.addAll(sources); - return this; - } - - /** - * Build buildable property source. - * - * @return the buildable property source - */ - public BuildablePropertySourceProvider build() { - BuildablePropertySourceProvider buildablePropertySource = new BuildablePropertySourceProvider(); - buildablePropertySource.sources.addAll(this.sources); - return buildablePropertySource; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/CLIPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/CLIPropertySource.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/CLIPropertySource.java deleted file mode 100644 index c74a8f3..0000000 --- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/CLIPropertySource.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.spisupport; - -import org.apache.tamaya.spi.PropertyValue; - -import java.util.*; - -/** - * PropertySource that allows to add the programs main arguments as configuration entries. Unix syntax using '--' and - * '-' params is supported. - */ -public class CLIPropertySource extends BasePropertySource{ - - /** The original main arguments. */ - private static String[] args = new String[0]; - - /** The map of parsed main arguments. */ - private static Map<String,PropertyValue> mainArgs; - - /** Initializes the initial state. */ - static{ - initMainArgs(args); - } - - /** - * Creates a new instance. - */ - public CLIPropertySource(){ - this((String[])null); - } - - /** - * Creates a new instance, allows optionally to pass the main arguments. - * @param args the args, or null. - */ - public CLIPropertySource(String... args){ - super("CLI"); - if(args!=null){ - initMainArgs(args); - } - } - - /** - * Creates a new instance, allows optionally to pass the main arguments. - * @param args the args, or null. - * @param ordinal the ordinal to be applied. - */ - public CLIPropertySource(int ordinal, String... args){ - if(args!=null){ - initMainArgs(args); - } - setOrdinal(ordinal); - } - - - - /** - * Configure the main arguments, hereby parsing and mapping the main arguments into - * configuration propertiesi as key-value pairs. - * @param args the main arguments, not null. - */ - public static void initMainArgs(String... args){ - CLIPropertySource.args = Objects.requireNonNull(args); - // TODO is there a way to figure out the args? - String argsProp = System.getProperty("main.args"); - if(argsProp!=null){ - CLIPropertySource.args = argsProp.split("\\s"); - } - Map<String,String> result = null; - if(CLIPropertySource.args==null){ - result = Collections.emptyMap(); - }else{ - result = new HashMap<>(); - String prefix = System.getProperty("main.args.prefix"); - if(prefix==null){ - prefix=""; - } - String key = null; - for(String arg:CLIPropertySource.args){ - if(arg.startsWith("--")){ - arg = arg.substring(2); - int index = arg.indexOf("="); - if(index>0){ - key = arg.substring(0,index).trim(); - result.put(prefix+key, arg.substring(index+1).trim()); - key = null; - }else{ - result.put(prefix+arg, arg); - } - }else if(arg.startsWith("-")){ - key = arg.substring(1); - }else{ - if(key!=null){ - result.put(prefix+key, arg); - key = null; - }else{ - result.put(prefix+arg, arg); - } - } - } - } - Map<String,PropertyValue> finalProps = new HashMap<>(); - for(Map.Entry<String,String> en:result.entrySet()) { - finalProps.put(en.getKey(), - PropertyValue.of(en.getKey(), en.getValue(), "main-args")); - } - CLIPropertySource.mainArgs = Collections.unmodifiableMap(finalProps); - } - - @Override - public Map<String, PropertyValue> getProperties() { - return Collections.unmodifiableMap(mainArgs); - } - - @Override - protected String toStringValues() { - return super.toStringValues() + - " args=" + Arrays.toString(args) + '\n'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java ---------------------------------------------------------------------- diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java deleted file mode 100644 index 92fd614..0000000 --- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigValueEvaluator.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.spisupport; - -import org.apache.tamaya.spi.ConfigurationContext; -import org.apache.tamaya.spi.PropertyValue; - -import java.util.Map; - - -/** - * Component SPI which encapsulates the evaluation of a single or full <b>raw</b>value - * for a {@link ConfigurationContext}. - */ -public interface ConfigValueEvaluator { - - /** - * Evaluates single value using a {@link ConfigurationContext}. - * @param key the config key, not null. - * @param context the context, not null. - * @return the value, or null. - */ - PropertyValue evaluteRawValue(String key, ConfigurationContext context); - - /** - * Evaluates all property values from a {@link ConfigurationContext}. - * @param context the context, not null. - * @return the value, or null. - */ - Map<String, PropertyValue> evaluateRawValues(ConfigurationContext context); - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigurationBuilder.java ---------------------------------------------------------------------- diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigurationBuilder.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigurationBuilder.java deleted file mode 100644 index be2978b..0000000 --- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/ConfigurationBuilder.java +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.spisupport; - - - -import org.apache.tamaya.Configuration; -import org.apache.tamaya.TypeLiteral; -import org.apache.tamaya.spi.*; - -import java.util.Collection; -import java.util.Comparator; -import java.util.List; -import java.util.Map; - -/** - * A builder for creating new or adapting instances of {@link Configuration}. - * Builders can be obtained in exactly two ways: - * <ol> - * <li>By accessing a preinitialized builder from an existing {@link Configuration}, - * by calling {@link org.apache.tamaya.Configuration#toBuilder()}.</li> - * <li>By accessing an empty builder instance from - * {@link org.apache.tamaya.ConfigurationProvider#getConfigurationBuilder()}.</li> - * </ol> - */ -public interface ConfigurationBuilder { - - /** - * Init this builder instance with the given {@link ConfigurationContext} instance. This - * method will use any existing property sources, filters, converters and the combination - * policy of the given {@link ConfigurationContext} and initialize the current builder - * with them. - * - * @param context the {@link ConfigurationContext} instance to be used, not {@code null}. - * @return this builder, for chaining, never null. - */ - ConfigurationBuilder setContext(ConfigurationContext context); - - /** - * This method can be used for adding {@link PropertySource}s. - * Hereby the property source is added to the tail of property sources with - * lowest priority regardless of its current ordinal value. To sort the property - * sources based on their ordinals call {@link #sortPropertySources}. - * - * @param propertySources the PropertySources to add - * @return this builder, for chaining, never null. - * @throws IllegalArgumentException If a property source with a given name already - * exists. - */ - ConfigurationBuilder addPropertySources(PropertySource... propertySources); - - /** - * This method can be used for programmatically adding {@link PropertySource}s. - * Hereby the property source is added to the tail of property sources with - * lowest priority regardless of its current ordinal value. To sort the property - * sources based on their ordinals call {@link #sortPropertySources}. - * - * @param propertySources the PropertySources to add - * @return this builder, for chaining, never null. - * @throws IllegalArgumentException If a property source with a given name already - * exists. - */ - ConfigurationBuilder addPropertySources(Collection<PropertySource> propertySources); - - /** - * Add all registered (default) property sources to the context built. The sources are ordered - * based on their ordinal values and added to the chain of property sources with - * higher priority. - * @return this builder, for chaining, never null. - */ - ConfigurationBuilder addDefaultPropertySources(); - - /** - * Removes the given property sources, if existing. The existing order of property - * sources is preserved. - * - * @param propertySources the property sources to remove, not {@code null}. - * @return the builder for chaining. - */ - ConfigurationBuilder removePropertySources(PropertySource... propertySources); - - /** - * Removes the given property sources, if existing. The existing order of property - * sources is preserved. - * - * @param propertySources the property sources to remove, not {@code null}. - * @return the builder for chaining. - */ - ConfigurationBuilder removePropertySources(Collection<PropertySource> propertySources); - - /** - * Access the current chain of property sources. Items at the end of the list have - * precedence/more significance. - * - * @return the property source chain, never {@code null}. - */ - List<PropertySource> getPropertySources(); - - /** - * Access the current chain of property filters. Items at the end of the list have - * precedence/more significance. - * - * @return the property source chain, never {@code null}. - */ - List<PropertyFilter> getPropertyFilters(); - - /** - * Access the current registered property converters. - * - * @return the current registered property converters. - */ - Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> getPropertyConverter(); - - /** - * Increases the priority of the given property source, by moving it towards the end - * of the chain of property sources. If the property source given is already at the end - * this method has no effect. This operation does not change any ordinal values. - * - * @param propertySource the property source to be incresed regarding its significance. - * @return the builder for chaining. - * @throws IllegalArgumentException If no such property source exists in the current - * chain. - */ - ConfigurationBuilder increasePriority(PropertySource propertySource); - - /** - * Decreases the priority of the given property source, by moving it towards the start - * of the chain of property sources. If the property source given is already the first - * this method has no effect. This operation does not change any ordinal values. - * - * @param propertySource the property source to be decresed regarding its significance. - * @return the builder for chaining. - * @throws IllegalArgumentException If no such property source exists in the current - * chain. - */ - ConfigurationBuilder decreasePriority(PropertySource propertySource); - - /** - * Increases the priority of the given property source to be maximal, by moving it to - * the tail of the of property source chain. If the property source given is - * already the last item this method has no effect. This operation does not change - * any ordinal values. - * - * @param propertySource the property source to be maximized regarding its significance. - * @return the builder for chaining. - * @throws IllegalArgumentException If no such property source exists in the current - * chain. - */ - ConfigurationBuilder highestPriority(PropertySource propertySource); - - /** - * Decreases the priority of the given property source to be minimal, by moving it to - * the start of the chain of property source chain. If the property source given is - * already the first item this method has no effect. This operation does not change - * any ordinal values. - * - * @param propertySource the property source to be minimized regarding its significance. - * @return the builder for chaining. - * @throws IllegalArgumentException If no such property source exists in the current - * chain. - */ - ConfigurationBuilder lowestPriority(PropertySource propertySource); - - /** - * Adds the given PropertyFilter instances, hereby the instances are added - * to the end of the list with highest priority. The ordering of existing - * property filters remains unchanged. To sort the property - * filters call {@link #sortPropertyFilter}. - * - * @param filters the filters to add - * @return this builder, for chaining, never null. - */ - ConfigurationBuilder addPropertyFilters(PropertyFilter... filters); - - /** - * Adds the given PropertyFilter instances, hereby the instances are added - * to the end of the list with highest priority. The ordering of existing - * property filters remains unchanged. To sort the property - * filters call {@link #sortPropertyFilter}. - * - * @param filters the filters to add - * @return this builder, for chaining, never null. - */ - ConfigurationBuilder addPropertyFilters(Collection<PropertyFilter> filters); - - /** - * Add all registered (default) property filters to the context built. - * @return this builder, for chaining, never null. - */ - ConfigurationBuilder addDefaultPropertyFilters(); - - - /** - * Removes the given PropertyFilter instances, if existing. The order of the remaining - * filters is preserved. - * - * @param filters the filter to remove - * @return this builder, for chaining, never null. - */ - ConfigurationBuilder removePropertyFilters(PropertyFilter... filters); - - /** - * Removes the given PropertyFilter instances, if existing. The order of the remaining - * filters is preserved. - * - * @param filters the filter to remove - * @return this builder, for chaining, never null. - */ - ConfigurationBuilder removePropertyFilters(Collection<PropertyFilter> filters); - - /** - * This method can be used for adding {@link PropertyConverter}s. - * Converters are added at the end after any existing converters. - * For converters already registered for the current target type the - * method has no effect. - * - * @param typeToConvert the type for which the converter is for - * @param propertyConverters the PropertyConverters to add for this type - * @param <T> the target type. - * @return this builder, for chaining, never null. - */ - <T> ConfigurationBuilder addPropertyConverters(TypeLiteral<T> typeToConvert, - PropertyConverter<T>... propertyConverters); - - /** - * This method can be used for adding {@link PropertyConverter}s. - * Converters are added at the end after any existing converters. - * For converters already registered for the current target type the - * method has no effect. - * - * @param typeToConvert the type for which the converter is for - * @param propertyConverters the PropertyConverters to add for this type - * @param <T> the target type. - * @return this builder, for chaining, never null. - */ - <T> ConfigurationBuilder addPropertyConverters(TypeLiteral<T> typeToConvert, - Collection<PropertyConverter<T>> propertyConverters); - - /** - * Add all registered (default) property converters to the context built. - * @return this builder, for chaining, never null. - */ - ConfigurationBuilder addDefaultPropertyConverters(); - - /** - * Removes the given PropertyConverter instances for the given type, - * if existing. - * - * @param typeToConvert the type which the converter is for - * @param propertyConverters the converter to remove - * @param <T> the target type. - * @return this builder, for chaining, never null. - */ - <T> ConfigurationBuilder removePropertyConverters(TypeLiteral<T> typeToConvert, - PropertyConverter<T>... propertyConverters); - - /** - * Removes the given PropertyConverter instances for the given type, - * if existing. - * - * @param typeToConvert the type which the converter is for - * @param propertyConverters the converter to remove - * @param <T> the target type. - * @return this builder, for chaining, never null. - */ - <T> ConfigurationBuilder removePropertyConverters(TypeLiteral<T> typeToConvert, - Collection<PropertyConverter<T>> propertyConverters); - - /** - * Removes all converters for the given type, which actually renders a given type - * unsupported for type conversion. - * - * @param typeToConvert the type which the converter is for - * @return this builder, for chaining, never null. - */ - ConfigurationBuilder removePropertyConverters(TypeLiteral<?> typeToConvert); - - /** - * Sorts the current registered property sources using the given comparator. - * - * NOTE: property sources at the beginning have minimal significance. - * - * @param comparator the comparator to be used, not {@code null}. - * @return this instance for chaining. - */ - ConfigurationBuilder sortPropertySources(Comparator<PropertySource> comparator); - - /** - * Sorts the current registered property filters using the given comparator. - * - * NOTE: property filters at the beginning have minimal significance. - * - * @param comparator the comparator to be used, not {@code null}. - * @return this instance for chaining. - */ - ConfigurationBuilder sortPropertyFilter(Comparator<PropertyFilter> comparator); - - /** - * Sets the {@link PropertyValueCombinationPolicy} used to evaluate the final - * property values. - * - * @param policy the {@link PropertyValueCombinationPolicy} used, not {@code null}. - * @return this builder, for chaining, never null. - */ - ConfigurationBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy policy); - - /** - * Builds a new {@link Configuration} based on the data in this builder. The ordering of property - * sources and property filters is not changed, regardless of their ordinals. For ensure a certain - * ordering/significance call {@link #sortPropertyFilter(Comparator)} and/or {@link #sortPropertySources(Comparator)} - * before building the context. - * - * @return the final configuration. - */ - Configuration build(); - -} - http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/2d0ef4b9/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluator.java ---------------------------------------------------------------------- diff --git a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluator.java b/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluator.java deleted file mode 100644 index cdfcfdc..0000000 --- a/modules/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultConfigValueEvaluator.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.spisupport; - -import org.apache.tamaya.spi.ConfigurationContext; -import org.apache.tamaya.spi.PropertyFilter; -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertyValue; - -import java.util.HashMap; -import java.util.Map; - - -/** - * Implementation of the Configuration API. This class uses the current {@link ConfigurationContext} to evaluate the - * chain of {@link PropertySource} and {@link PropertyFilter} - * instance to evaluate the current Configuration. - */ -public class DefaultConfigValueEvaluator implements ConfigValueEvaluator{ - - @Override - public PropertyValue evaluteRawValue(String key, ConfigurationContext context) { - PropertyValue unfilteredValue = null; - for (PropertySource propertySource : context.getPropertySources()) { - unfilteredValue = context.getPropertyValueCombinationPolicy(). - collect(unfilteredValue, key, propertySource); - } - if(unfilteredValue==null || unfilteredValue.getValue()==null){ - return unfilteredValue; - } - return unfilteredValue; - } - - @Override - public Map<String, PropertyValue> evaluateRawValues(ConfigurationContext context) { - Map<String, PropertyValue> result = new HashMap<>(); - for (PropertySource propertySource : context.getPropertySources()) { - for (Map.Entry<String,PropertyValue> propEntry: propertySource.getProperties().entrySet()) { - PropertyValue unfilteredValue = result.get(propEntry.getKey()); - unfilteredValue = context.getPropertyValueCombinationPolicy(). - collect(unfilteredValue, propEntry.getKey(), propertySource); - if(unfilteredValue!=null){ - result.put(unfilteredValue.getKey(), unfilteredValue); - } - } - } - return result; - } - - @Override - public String toString() { - return "DefaultConfigEvaluator{}"; - } -}