http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/IntegrationTest.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/IntegrationTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/IntegrationTest.java index 5f875f2..7ae76af 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/IntegrationTest.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/IntegrationTest.java @@ -18,17 +18,16 @@ */ package org.apache.tamaya.metamodel.ext; -import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.apache.tamaya.TypeLiteral; import org.apache.tamaya.metamodel.CachedFilter; import org.apache.tamaya.metamodel.MetaConfiguration; import org.apache.tamaya.metamodel.MetaContext; -import org.apache.tamaya.spi.PropertyConverter; -import org.apache.tamaya.spi.PropertyFilter; -import org.apache.tamaya.spi.PropertySource; +import org.apache.tamaya.spi.*; import org.junit.Test; +import javax.config.Config; +import javax.config.ConfigProvider; +import javax.config.spi.ConfigSource; +import javax.config.spi.Converter; import java.net.URL; import java.util.List; @@ -41,27 +40,32 @@ public class IntegrationTest { @Test public void checkSystemLoads(){ - assertNotNull(ConfigurationProvider.getConfiguration()); - System.out.println(ConfigurationProvider.getConfiguration()); + assertNotNull(ConfigProvider.getConfig()); + System.out.println(ConfigProvider.getConfig()); } @Test public void testEmptyConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/empty-config.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/empty-config.xml")); assertNotNull(config); - assertTrue(config.getProperties().isEmpty()); - assertTrue(config.getContext().getPropertySources().isEmpty()); - assertTrue(config.getContext().getPropertyConverters().isEmpty()); - assertTrue(config.getContext().getPropertyFilters().isEmpty()); + assertTrue(!config.getPropertyNames().iterator().hasNext()); + assertTrue(!config.getConfigSources().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertTrue(context.getConverters().isEmpty()); + assertTrue(context.getFilters().isEmpty()); + } } @Test public void testMetaContextConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/context-test.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/context-test.xml")); assertNotNull(config); - assertTrue(config.getProperties().isEmpty()); - assertTrue(config.getContext().getPropertyConverters().isEmpty()); - assertTrue(config.getContext().getPropertyFilters().isEmpty()); + assertFalse(config.getPropertyNames().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertTrue(context.getFilters().isEmpty()); + } MetaContext ctx = MetaContext.getInstance(); assertFalse(ctx.getProperties().isEmpty()); assertEquals(ctx.getId(), ctx.getProperty("_id")); @@ -73,118 +77,127 @@ public class IntegrationTest { @Test public void testDefaultConvertersConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/default-propertyconverters-test.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/default-propertyconverters-test.xml")); assertNotNull(config); - assertTrue(config.getContext().getPropertySources().isEmpty()); - assertTrue(config.getProperties().isEmpty()); - assertFalse(config.getContext().getPropertyConverters().isEmpty()); - assertTrue(config.getContext().getPropertyFilters().isEmpty()); - assertEquals(config.getContext(), - ConfigurationProvider.getConfigurationContextBuilder() - .addDefaultPropertyConverters() - .build()); - + assertFalse(config.getConfigSources().iterator().hasNext()); + assertFalse(config.getPropertyNames().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertFalse(context.getConverters().isEmpty()); + assertTrue(context.getFilters().isEmpty()); + } } @Test public void testDefaultPropertySourcesConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/default-propertysources-test.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/default-propertysources-test.xml")); assertNotNull(config); - assertFalse(config.getProperties().isEmpty()); - assertFalse(config.getContext().getPropertySources().isEmpty()); - assertTrue(config.getContext().getPropertyConverters().isEmpty()); - assertTrue(config.getContext().getPropertyFilters().isEmpty()); - assertEquals(config.getContext(), - ConfigurationProvider.getConfigurationContextBuilder() - .addDefaultPropertySources() - .build()); - + assertTrue(config.getPropertyNames().iterator().hasNext()); + assertTrue(config.getConfigSources().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertTrue(context.getConverters().isEmpty()); + assertTrue(context.getFilters().isEmpty()); + } } @Test public void testDefaultPropertyFiltersConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/default-propertyfilters-test.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/default-propertyfilters-test.xml")); assertNotNull(config); - assertTrue(config.getProperties().isEmpty()); - assertTrue(config.getContext().getPropertySources().isEmpty()); - assertTrue(config.getContext().getPropertyConverters().isEmpty()); - assertFalse(config.getContext().getPropertyFilters().isEmpty()); - assertEquals(config.getContext(), - ConfigurationProvider.getConfigurationContextBuilder() - .addDefaultPropertyFilters() - .build()); - + assertFalse(config.getPropertyNames().iterator().hasNext()); + assertFalse(config.getConfigSources().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertTrue(context.getConverters().isEmpty()); + assertFalse(context.getFilters().isEmpty()); + } } @Test public void testPropertyFiltersConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertyfilters-test.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertyfilters-test.xml")); assertNotNull(config); - assertTrue(config.getProperties().isEmpty()); - assertTrue(config.getContext().getPropertySources().isEmpty()); - assertTrue(config.getContext().getPropertyConverters().isEmpty()); - assertFalse(config.getContext().getPropertyFilters().isEmpty()); - assertEquals(1, config.getContext().getPropertyFilters().size()); - assertTrue(config.getContext().getPropertyFilters().get(0) instanceof CachedFilter); + assertFalse(config.getPropertyNames().iterator().hasNext()); + assertFalse(config.getConfigSources().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertTrue(context.getConverters().isEmpty()); + assertFalse(context.getFilters().isEmpty()); + assertEquals(1, context.getFilters().size()); + assertTrue(context.getFilters().get(0) instanceof CachedFilter); + } } @Test public void testPropertyConvertersConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertyconverters-test.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertyconverters-test.xml")); assertNotNull(config); - assertTrue(config.getProperties().isEmpty()); - assertTrue(config.getContext().getPropertySources().isEmpty()); - assertFalse(config.getContext().getPropertyConverters().isEmpty()); - assertTrue(config.getContext().getPropertyFilters().isEmpty()); - assertEquals(1, config.getContext().getPropertyConverters().size()); - List<PropertyConverter<Object>> converters = config.getContext().getPropertyConverters(TypeLiteral.of(String.class)); - assertTrue(converters.get(0).getClass().equals(MyConverter.class)); + assertFalse(config.getPropertyNames().iterator().hasNext()); + assertFalse(config.getConfigSources().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertFalse(context.getConverters().isEmpty()); + assertTrue(context.getFilters().isEmpty()); + assertEquals(1, context.getConverters().size()); + List<Converter> converters = context.getConverters(String.class); + assertTrue(converters.get(0).getClass().equals(MyConverter.class)); + } } @Test public void testPropertySourcesConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertysources-test.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertysources-test.xml")); assertNotNull(config); - assertFalse(config.getProperties().isEmpty()); - assertFalse(config.getContext().getPropertySources().isEmpty()); - assertTrue(config.getContext().getPropertyConverters().isEmpty()); - assertTrue(config.getContext().getPropertyFilters().isEmpty()); - assertEquals(2, config.getContext().getPropertySources().size()); - assertTrue(config.getContext().getPropertySources().get(0) instanceof MyPropertySource); + assertTrue(config.getPropertyNames().iterator().hasNext()); + assertTrue(config.getConfigSources().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertTrue(context.getConverters().isEmpty()); + assertTrue(context.getFilters().isEmpty()); + assertEquals(2, context.getSources().size()); + assertTrue(context.getSources().get(0) instanceof MyConfigSource); + } } @Test public void testPropertyFilterConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertyfilter-config-test.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertyfilter-config-test.xml")); assertNotNull(config); - assertTrue(config.getProperties().isEmpty()); - assertTrue(config.getContext().getPropertySources().isEmpty()); - assertTrue(config.getContext().getPropertyConverters().isEmpty()); - assertFalse(config.getContext().getPropertyFilters().isEmpty()); - assertEquals(1, config.getContext().getPropertyFilters().size()); - PropertyFilter filter = config.getContext().getPropertyFilters().get(0); - assertNotNull(filter); - assertTrue(filter instanceof MyFilter); - MyFilter myFilter = (MyFilter)filter; - assertEquals("my-filter-name", myFilter.getName()); - assertEquals("attrValue1", myFilter.getAttrValue()); - assertEquals("elemValue1", myFilter.getElemValue()); - assertEquals("overrideValue2", myFilter.getOverrideValue()); + assertFalse(config.getPropertyNames().iterator().hasNext()); + assertFalse(config.getConfigSources().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertTrue(context.getConverters().isEmpty()); + assertFalse(context.getFilters().isEmpty()); + assertEquals(1, context.getFilters().size()); + Filter filter = context.getFilters().get(0); + assertNotNull(filter); + assertTrue(filter instanceof MyFilter); + MyFilter myFilter = (MyFilter)filter; + assertEquals("my-filter-name", myFilter.getName()); + assertEquals("attrValue1", myFilter.getAttrValue()); + assertEquals("elemValue1", myFilter.getElemValue()); + assertEquals("overrideValue2", myFilter.getOverrideValue()); + } } @Test public void testPropertySourceConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertysource-config-test.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertysource-config-test.xml")); assertNotNull(config); - assertTrue(config.getProperties().isEmpty()); - assertFalse(config.getContext().getPropertySources().isEmpty()); - assertTrue(config.getContext().getPropertyConverters().isEmpty()); - assertTrue(config.getContext().getPropertyFilters().isEmpty()); - assertEquals(1, config.getContext().getPropertySources().size()); - PropertySource ps = config.getContext().getPropertySources().get(0); + assertFalse(config.getPropertyNames().iterator().hasNext()); + assertTrue(config.getConfigSources().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertTrue(context.getConverters().isEmpty()); + assertTrue(context.getFilters().isEmpty()); + assertEquals(1, context.getSources().size()); + } + ConfigSource ps = config.getConfigSources().iterator().next(); assertNotNull(ps); - assertTrue(ps instanceof MyPropertySource); - MyPropertySource mySource = (MyPropertySource)ps; + assertTrue(ps instanceof MyConfigSource); + MyConfigSource mySource = (MyConfigSource)ps; assertEquals("my-source-name", mySource.getName2()); assertEquals("attrValue1", mySource.getAttrValue()); assertEquals("elemValue1", mySource.getElemValue()); @@ -193,22 +206,25 @@ public class IntegrationTest { @Test public void testPropertyConverterConfig(){ - Configuration config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertyconverter-config-test.xml")); + Config config = MetaConfiguration.createConfiguration(getConfig("IntegrationTests/propertyconverter-config-test.xml")); assertNotNull(config); - assertTrue(config.getProperties().isEmpty()); - assertTrue(config.getContext().getPropertySources().isEmpty()); - assertFalse(config.getContext().getPropertyConverters().isEmpty()); - assertTrue(config.getContext().getPropertyFilters().isEmpty()); - assertEquals(1, config.getContext().getPropertyConverters().size()); - PropertyConverter converter = config.getContext().getPropertyConverters().values().iterator() - .next().get(0); - assertNotNull(converter); - assertTrue(converter instanceof MyConverter); - MyConverter myConverter = (MyConverter)converter; - assertEquals("my-converter-name", myConverter.getName()); - assertEquals("attrValue1", myConverter.getAttrValue()); - assertEquals("elemValue1", myConverter.getElemValue()); - assertEquals("overrideValue2", myConverter.getOverrideValue()); + assertFalse(config.getPropertyNames().iterator().hasNext()); + assertFalse(config.getConfigSources().iterator().hasNext()); + if(config instanceof ConfigContextSupplier) { + ConfigContext context = ((ConfigContextSupplier) config).getConfigContext(); + assertFalse(context.getConverters().isEmpty()); + assertTrue(context.getFilters().isEmpty()); + assertEquals(1, context.getConverters().size()); + Converter converter = context.getConverters().values().iterator() + .next().get(0); + assertNotNull(converter); + assertTrue(converter instanceof MyConverter); + MyConverter myConverter = (MyConverter)converter; + assertEquals("my-converter-name", myConverter.getName()); + assertEquals("attrValue1", myConverter.getAttrValue()); + assertEquals("elemValue1", myConverter.getElemValue()); + assertEquals("overrideValue2", myConverter.getOverrideValue()); + } } private URL getConfig(String resource) {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConfigSource.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConfigSource.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConfigSource.java new file mode 100644 index 0000000..5be8c1e --- /dev/null +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConfigSource.java @@ -0,0 +1,72 @@ +/* + * 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.metamodel.ext; + + +import org.apache.tamaya.base.configsource.BaseConfigSource; + +import java.util.Collections; +import java.util.Map; + +/** + * Created by atsticks on 17.04.17. + */ +public class MyConfigSource extends BaseConfigSource { + + private String name2; + private String attrValue; + private String elemValue; + private String overrideValue; + + @Override + public Map<String, String> getProperties() { + return Collections.emptyMap(); + } + + public String getAttrValue() { + return attrValue; + } + + public MyConfigSource setAttrValue(String attrValue) { + this.attrValue = attrValue; + return this; + } + + public String getElemValue() { + return elemValue; + } + + public MyConfigSource setElemValue(String elemValue) { + this.elemValue = elemValue; + return this; + } + + public String getOverrideValue() { + return overrideValue; + } + + public MyConfigSource setOverrideValue(String overrideValue) { + this.overrideValue = overrideValue; + return this; + } + + public String getName2() { + return name2; + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConverter.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConverter.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConverter.java index 22f642c..d848861 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConverter.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyConverter.java @@ -18,13 +18,12 @@ */ package org.apache.tamaya.metamodel.ext; -import org.apache.tamaya.spi.ConversionContext; -import org.apache.tamaya.spi.PropertyConverter; +import javax.config.spi.Converter; /** * Created by atsticks on 17.04.17. */ -public class MyConverter implements PropertyConverter<String> { +public class MyConverter implements Converter<String> { private String name; private String attrValue; @@ -32,7 +31,7 @@ public class MyConverter implements PropertyConverter<String> { private String overrideValue; @Override - public String convert(String value, ConversionContext context) { + public String convert(String value) { return value; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyFilter.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyFilter.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyFilter.java index e6ab7e6..187a8d2 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyFilter.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyFilter.java @@ -18,6 +18,7 @@ */ package org.apache.tamaya.metamodel.ext; +import org.apache.tamaya.spi.Filter; import org.apache.tamaya.spi.FilterContext; import org.apache.tamaya.spi.PropertyFilter; import org.apache.tamaya.spi.PropertyValue; @@ -25,7 +26,7 @@ import org.apache.tamaya.spi.PropertyValue; /** * Created by atsticks on 17.04.17. */ -public class MyFilter implements PropertyFilter{ +public class MyFilter implements Filter{ private String name; private String attrValue; @@ -33,7 +34,7 @@ public class MyFilter implements PropertyFilter{ private String overrideValue; @Override - public PropertyValue filterProperty(PropertyValue value, FilterContext context) { + public String filterProperty(String key, String value) { return value; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyPropertySource.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyPropertySource.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyPropertySource.java deleted file mode 100644 index 106e0f6..0000000 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/ext/MyPropertySource.java +++ /dev/null @@ -1,73 +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.metamodel.ext; - - -import org.apache.tamaya.spi.PropertyValue; -import org.apache.tamaya.spisupport.propertysource.BasePropertySource; - -import java.util.Collections; -import java.util.Map; - -/** - * Created by atsticks on 17.04.17. - */ -public class MyPropertySource extends BasePropertySource { - - private String name2; - private String attrValue; - private String elemValue; - private String overrideValue; - - @Override - public Map<String, PropertyValue> getProperties() { - return Collections.emptyMap(); - } - - public String getAttrValue() { - return attrValue; - } - - public MyPropertySource setAttrValue(String attrValue) { - this.attrValue = attrValue; - return this; - } - - public String getElemValue() { - return elemValue; - } - - public MyPropertySource setElemValue(String elemValue) { - this.elemValue = elemValue; - return this; - } - - public String getOverrideValue() { - return overrideValue; - } - - public MyPropertySource setOverrideValue(String overrideValue) { - this.overrideValue = overrideValue; - return this; - } - - public String getName2() { - return name2; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/CLIArgumentsFactoryTest.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/CLIArgumentsFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/CLIArgumentsFactoryTest.java index bd73b11..ab48dd7 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/CLIArgumentsFactoryTest.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/CLIArgumentsFactoryTest.java @@ -18,10 +18,12 @@ */ package org.apache.tamaya.metamodel.internal.factories; +import org.apache.tamaya.base.configsource.CLIConfigSource; import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spisupport.propertysource.CLIPropertySource; import org.junit.Test; +import javax.config.spi.ConfigSource; import java.util.Collections; import static org.junit.Assert.*; @@ -41,14 +43,14 @@ public class CLIArgumentsFactoryTest { @Test public void create() throws Exception { - PropertySource ps = f.create(Collections.EMPTY_MAP); + ConfigSource ps = f.create(Collections.EMPTY_MAP); assertNotNull(ps); - assertTrue(ps instanceof CLIPropertySource); + assertTrue(ps instanceof CLIConfigSource); } @Test public void getType() throws Exception { - assertEquals(PropertySource.class, f.getType()); + assertEquals(ConfigSource.class, f.getType()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/EnvPropertiesFactoryTest.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/EnvPropertiesFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/EnvPropertiesFactoryTest.java index 5193df7..7197693 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/EnvPropertiesFactoryTest.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/EnvPropertiesFactoryTest.java @@ -18,10 +18,12 @@ */ package org.apache.tamaya.metamodel.internal.factories; +import org.apache.tamaya.base.configsource.EnvironmentConfigSource; import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource; import org.apache.tamaya.spi.PropertySource; import org.junit.Test; +import javax.config.spi.ConfigSource; import java.util.Collections; import static org.junit.Assert.*; @@ -41,14 +43,14 @@ public class EnvPropertiesFactoryTest { @Test public void create() throws Exception { - PropertySource ps = f.create(Collections.EMPTY_MAP); + ConfigSource ps = f.create(Collections.EMPTY_MAP); assertNotNull(ps); - assertTrue(ps instanceof EnvironmentPropertySource); + assertTrue(ps instanceof EnvironmentConfigSource); } @Test public void getType() throws Exception { - assertEquals(PropertySource.class, f.getType()); + assertEquals(ConfigSource.class, f.getType()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/FilePropertySourceFactoryTest.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/FilePropertySourceFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/FilePropertySourceFactoryTest.java index d91d279..50d4e05 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/FilePropertySourceFactoryTest.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/FilePropertySourceFactoryTest.java @@ -21,6 +21,7 @@ package org.apache.tamaya.metamodel.internal.factories; import org.apache.tamaya.spi.PropertySource; import org.junit.Test; +import javax.config.spi.ConfigSource; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -44,20 +45,20 @@ public class FilePropertySourceFactoryTest { public void create() throws Exception { Map<String,String> params = new HashMap<>(); params.put("location", "src/test/resources/GLOBAL.properties"); - PropertySource ps = f.create(params); + ConfigSource ps = f.create(params); assertNotNull(ps); } @Test public void create_Error() throws Exception { Map<String,String> params = new HashMap<>(); - PropertySource ps = f.create(Collections.<String, String>emptyMap()); + ConfigSource ps = f.create(Collections.<String, String>emptyMap()); assertNull("Should throw error for missing location.", ps); } @Test public void getType() throws Exception { - assertEquals(PropertySource.class, f.getType()); + assertEquals(ConfigSource.class, f.getType()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceFactoryTest.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceFactoryTest.java index bd6ee93..7cac13f 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceFactoryTest.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceFactoryTest.java @@ -21,6 +21,7 @@ package org.apache.tamaya.metamodel.internal.factories; import org.apache.tamaya.spi.PropertySource; import org.junit.Test; +import javax.config.spi.ConfigSource; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -33,7 +34,7 @@ import static org.junit.Assert.*; */ public class ResourcePropertySourceFactoryTest { - private static ResourcePropertySourceFactory f = new ResourcePropertySourceFactory(); + private static ResourceConfigSourceFactory f = new ResourceConfigSourceFactory(); @Test public void getName() throws Exception { @@ -44,20 +45,20 @@ public class ResourcePropertySourceFactoryTest { public void create() throws Exception { Map<String,String> params = new HashMap<>(); params.put("location", "GLOBAL.properties"); - PropertySource ps = f.create(params); + ConfigSource ps = f.create(params); assertNotNull(ps); } @Test public void create_Error() throws Exception { Map<String,String> params = new HashMap<>(); - PropertySource ps = f.create(Collections.<String, String>emptyMap()); + ConfigSource ps = f.create(Collections.<String, String>emptyMap()); assertNull("Should return null for missing location.", ps); } @Test public void getType() throws Exception { - assertEquals(PropertySource.class, f.getType()); + assertEquals(ConfigSource.class, f.getType()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactoryTest.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactoryTest.java index edc0d95..b7f7cee 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactoryTest.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/ResourcePropertySourceProviderFactoryTest.java @@ -18,10 +18,10 @@ */ package org.apache.tamaya.metamodel.internal.factories; -import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spi.PropertySourceProvider; import org.junit.Test; +import javax.config.spi.ConfigSourceProvider; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -45,20 +45,20 @@ public class ResourcePropertySourceProviderFactoryTest { public void create() throws Exception { Map<String,String> params = new HashMap<>(); params.put("location", "GLOBAL.properties"); - PropertySourceProvider prov = f.create(params); + ConfigSourceProvider prov = f.create(params); assertNotNull(prov); } @Test public void create_Error() throws Exception { Map<String,String> params = new HashMap<>(); - PropertySourceProvider prov = f.create(Collections.<String, String>emptyMap()); + ConfigSourceProvider prov = f.create(Collections.<String, String>emptyMap()); assertNull("Should return null for missing location.", prov); } @Test public void getType() throws Exception { - assertEquals(PropertySourceProvider.class, f.getType()); + assertEquals(ConfigSourceProvider.class, f.getType()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/SysPropertiesFactoryTest.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/SysPropertiesFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/SysPropertiesFactoryTest.java index 5d21811..c054c4e 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/SysPropertiesFactoryTest.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/SysPropertiesFactoryTest.java @@ -18,10 +18,12 @@ */ package org.apache.tamaya.metamodel.internal.factories; +import org.apache.tamaya.base.configsource.SystemConfigSource; import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spisupport.propertysource.SystemPropertySource; import org.junit.Test; +import javax.config.spi.ConfigSource; import java.util.Collections; import static org.junit.Assert.*; @@ -41,14 +43,14 @@ public class SysPropertiesFactoryTest { @Test public void create() throws Exception { - PropertySource ps = f.create(Collections.EMPTY_MAP); + ConfigSource ps = f.create(Collections.EMPTY_MAP); assertNotNull(ps); - assertTrue(ps instanceof SystemPropertySource); + assertTrue(ps instanceof SystemConfigSource); } @Test public void getType() throws Exception { - assertEquals(PropertySource.class, f.getType()); + assertEquals(ConfigSource.class, f.getType()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactoryTest.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactoryTest.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactoryTest.java index f316417..6b9e7f4 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactoryTest.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/factories/URLPropertySourceFactoryTest.java @@ -21,6 +21,7 @@ package org.apache.tamaya.metamodel.internal.factories; import org.apache.tamaya.spi.PropertySource; import org.junit.Test; +import javax.config.spi.ConfigSource; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -33,7 +34,7 @@ import static org.junit.Assert.*; */ public class URLPropertySourceFactoryTest { - private static URLPropertySourceFactory f = new URLPropertySourceFactory(); + private static URLConfigSourceFactory f = new URLConfigSourceFactory(); @Test public void getName() throws Exception { @@ -44,20 +45,20 @@ public class URLPropertySourceFactoryTest { public void create() throws Exception { Map<String,String> params = new HashMap<>(); params.put("location", "http://apache.org"); - PropertySource ps = f.create(params); + ConfigSource ps = f.create(params); assertNotNull(ps); } @Test public void create_Error() throws Exception { Map<String,String> params = new HashMap<>(); - PropertySource ps = f.create(Collections.<String, String>emptyMap()); + ConfigSource ps = f.create(Collections.<String, String>emptyMap()); assertNull("Should return null for missing location.", ps); } @Test public void getType() throws Exception { - assertEquals(PropertySource.class, f.getType()); + assertEquals(ConfigSource.class, f.getType()); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/LoggingReader.java ---------------------------------------------------------------------- diff --git a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/LoggingReader.java b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/LoggingReader.java index c0d67bc..1018a10 100644 --- a/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/LoggingReader.java +++ b/metamodel/src/test/java/org/apache/tamaya/metamodel/internal/resolver/LoggingReader.java @@ -18,16 +18,13 @@ */ package org.apache.tamaya.metamodel.internal.resolver; -import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; -import org.apache.tamaya.metamodel.MetaContext; import org.apache.tamaya.metamodel.spi.MetaConfigurationReader; -import org.apache.tamaya.spi.ConfigurationContext; -import org.apache.tamaya.spi.ConfigurationContextBuilder; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import javax.config.ConfigProvider; +import javax.config.spi.ConfigBuilder; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; @@ -44,13 +41,12 @@ public class LoggingReader implements MetaConfigurationReader{ private static final JavaResolver resolver = new JavaResolver(); @Override - public void read(final Document document, ConfigurationContextBuilder contextBuilder) { + public void read(final Document document, ConfigBuilder configBuilder) { new Timer(true).schedule(new TimerTask() { @Override public void run() { Map<String, Object> meta = new HashMap<>(); - meta.put("context", ConfigurationProvider.getConfiguration().getContext()); - meta.put("config", ConfigurationProvider.getConfiguration()); + meta.put("config", ConfigProvider.getConfig()); NodeList nodeList = document.getDocumentElement().getElementsByTagName("context"); for(int i=0;i<nodeList.getLength();i++){ Node node = nodeList.item(i); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/IntegrationTests/default-propertyconverters-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/default-propertyconverters-test.xml b/metamodel/src/test/resources/IntegrationTests/default-propertyconverters-test.xml index 91252cf..9d95058 100644 --- a/metamodel/src/test/resources/IntegrationTests/default-propertyconverters-test.xml +++ b/metamodel/src/test/resources/IntegrationTests/default-propertyconverters-test.xml @@ -22,10 +22,10 @@ <!-- Configuration definition. --> - <property-converters> + <converters> <!--<converter type="AllInOneConverter"/>--> <defaults/> - </property-converters> + </converters> </configuration> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/IntegrationTests/default-propertyfilters-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/default-propertyfilters-test.xml b/metamodel/src/test/resources/IntegrationTests/default-propertyfilters-test.xml index 199f04f..194ca5c 100644 --- a/metamodel/src/test/resources/IntegrationTests/default-propertyfilters-test.xml +++ b/metamodel/src/test/resources/IntegrationTests/default-propertyfilters-test.xml @@ -18,9 +18,9 @@ // --> <configuration> - <property-filters> + <filters> <defaults/> - </property-filters> + </filters> </configuration> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/IntegrationTests/default-propertysources-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/default-propertysources-test.xml b/metamodel/src/test/resources/IntegrationTests/default-propertysources-test.xml index a7270ec..550f6fe 100644 --- a/metamodel/src/test/resources/IntegrationTests/default-propertysources-test.xml +++ b/metamodel/src/test/resources/IntegrationTests/default-propertysources-test.xml @@ -21,9 +21,9 @@ <!-- Configuration definition. --> - <property-sources> + <sources> <defaults /> - </property-sources> + </sources> </configuration> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/IntegrationTests/propertyconverter-config-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/propertyconverter-config-test.xml b/metamodel/src/test/resources/IntegrationTests/propertyconverter-config-test.xml index 485ac8b..6104a52 100644 --- a/metamodel/src/test/resources/IntegrationTests/propertyconverter-config-test.xml +++ b/metamodel/src/test/resources/IntegrationTests/propertyconverter-config-test.xml @@ -18,7 +18,7 @@ // --> <configuration> - <property-converters> + <converters> <org.apache.tamaya.metamodel.ext.MyConverter targetType="java.lang.String" attrValue="attrValue1" overrideValue="overrideValue1"> @@ -26,7 +26,7 @@ <elemValue>elemValue1</elemValue> <overrideValue>overrideValue2</overrideValue> </org.apache.tamaya.metamodel.ext.MyConverter> - </property-converters> + </converters> </configuration> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/IntegrationTests/propertyconverters-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/propertyconverters-test.xml b/metamodel/src/test/resources/IntegrationTests/propertyconverters-test.xml index fe47b84..bbe192d 100644 --- a/metamodel/src/test/resources/IntegrationTests/propertyconverters-test.xml +++ b/metamodel/src/test/resources/IntegrationTests/propertyconverters-test.xml @@ -22,9 +22,9 @@ <!-- Configuration definition. --> - <property-converters> + <converters> <org.apache.tamaya.metamodel.ext.MyConverter targetType="java.lang.String"/> - </property-converters> + </converters> </configuration> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/IntegrationTests/propertyfilter-config-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/propertyfilter-config-test.xml b/metamodel/src/test/resources/IntegrationTests/propertyfilter-config-test.xml index 71c1b3a..a4e7fe1 100644 --- a/metamodel/src/test/resources/IntegrationTests/propertyfilter-config-test.xml +++ b/metamodel/src/test/resources/IntegrationTests/propertyfilter-config-test.xml @@ -18,13 +18,13 @@ // --> <configuration> - <property-filters> + <filters> <org.apache.tamaya.metamodel.ext.MyFilter attrValue="attrValue1" overrideValue="overrideValue1"> <name>my-filter-name</name> <elemValue>elemValue1</elemValue> <overrideValue>overrideValue2</overrideValue> </org.apache.tamaya.metamodel.ext.MyFilter> - </property-filters> + </filters> </configuration> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/IntegrationTests/propertyfilters-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/propertyfilters-test.xml b/metamodel/src/test/resources/IntegrationTests/propertyfilters-test.xml index c1f4ee4..2f07e15 100644 --- a/metamodel/src/test/resources/IntegrationTests/propertyfilters-test.xml +++ b/metamodel/src/test/resources/IntegrationTests/propertyfilters-test.xml @@ -18,9 +18,9 @@ // --> <configuration> - <property-filters> + <filters> <Cached timeout="30000" maxSize="300" matches="cached.*"/> - </property-filters> + </filters> </configuration> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/IntegrationTests/propertysource-config-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/propertysource-config-test.xml b/metamodel/src/test/resources/IntegrationTests/propertysource-config-test.xml index 28710d4..bcc3319 100644 --- a/metamodel/src/test/resources/IntegrationTests/propertysource-config-test.xml +++ b/metamodel/src/test/resources/IntegrationTests/propertysource-config-test.xml @@ -18,14 +18,14 @@ // --> <configuration> - <property-sources> - <org.apache.tamaya.metamodel.ext.MyPropertySource + <sources> + <org.apache.tamaya.metamodel.ext.MyConfigSource attrValue="attrValue1" overrideValue="overrideValue1"> <name2>my-source-name</name2> <elemValue>elemValue1</elemValue> <overrideValue>overrideValue2</overrideValue> - </org.apache.tamaya.metamodel.ext.MyPropertySource> - </property-sources> + </org.apache.tamaya.metamodel.ext.MyConfigSource> + </sources> </configuration> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/IntegrationTests/propertysources-test.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/IntegrationTests/propertysources-test.xml b/metamodel/src/test/resources/IntegrationTests/propertysources-test.xml index 831da19..4fc901e 100644 --- a/metamodel/src/test/resources/IntegrationTests/propertysources-test.xml +++ b/metamodel/src/test/resources/IntegrationTests/propertysources-test.xml @@ -17,9 +17,9 @@ // under the License. // --> <configuration> - <property-sources> - <org.apache.tamaya.metamodel.ext.MyPropertySource/> + <sources> + <org.apache.tamaya.metamodel.ext.MyConfigSource/> <sys-properties /> - </property-sources> + </sources> </configuration> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.Filter ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.Filter b/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.Filter new file mode 100644 index 0000000..80fa6c6 --- /dev/null +++ b/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.Filter @@ -0,0 +1,19 @@ +# +# 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. +# +org.apache.tamaya.metamodel.ImmutableFilter \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter deleted file mode 100644 index 80fa6c6..0000000 --- a/metamodel/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter +++ /dev/null @@ -1,19 +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. -# -org.apache.tamaya.metamodel.ImmutableFilter \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/metamodel/src/test/resources/tamaya-config.xml ---------------------------------------------------------------------- diff --git a/metamodel/src/test/resources/tamaya-config.xml b/metamodel/src/test/resources/tamaya-config.xml index d372249..296da5d 100644 --- a/metamodel/src/test/resources/tamaya-config.xml +++ b/metamodel/src/test/resources/tamaya-config.xml @@ -35,7 +35,7 @@ <!-- Configuration definition. --> - <property-sources> + <sources> <env-properties enabled="${context('stage')=='TEST' || context('stage')=='PTA' || context('stage')=='PROD'}"> <filters> <Map target="ENV."/> @@ -62,15 +62,15 @@ <Cached ttl="30 SECOND"/> </filters> </url> - </property-sources> - <property-filters> + </sources> + <filters> <Secured roles="admin,power-user" matches="*.secret" policy="HIDE"/> <Cached timeout="30000" maxSize="300" matches="cached.*"/> - </property-filters> - <property-converters> + </filters> + <converters> <!--<converter type="AllInOneConverter"/>--> - <default-converters/> - </property-converters> + <defaults/> + </converters> <log> "METACONTEXT: " + MetaContext.getInstance().getProperties() http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 5eac2bf..6588480 100644 --- a/pom.xml +++ b/pom.xml @@ -796,12 +796,13 @@ under the License. <module>etcd</module> <module>consul</module> <module>camel</module> - <module>propertysources</module> + <module>configsources</module> <!--<module>ui</module>--> <module>management</module> <module>metamodel</module> <module>uom</module> <module>vertx</module> + <module>meta</module> </modules> <profiles> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/propertysources/bnd.bnd ---------------------------------------------------------------------- diff --git a/propertysources/bnd.bnd b/propertysources/bnd.bnd deleted file mode 100644 index dae0996..0000000 --- a/propertysources/bnd.bnd +++ /dev/null @@ -1,27 +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 - More PropertySources -Bundle-SymbolicName: org.apache.tamaya.propertysources -Bundle-Description: Apacha Tamaya Configuration - Reusable PropertySources -Bundle-Category: Implementation -Bundle-Copyright: (C) Apache Foundation -Bundle-License: Apache Licence version 2 -Bundle-Vendor: Apache Software Foundation -Bundle-ContactAddress: [email protected] -Bundle-DocURL: http://tamaya.apache.org -Export-Package: \ - org.apache.tamaya.propertysources -Import-Package: \ - org.apache.tamaya,\ - org.apache.tamaya.spi,\ - org.apache.tamaya.spisupport http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/propertysources/pom.xml ---------------------------------------------------------------------- diff --git a/propertysources/pom.xml b/propertysources/pom.xml deleted file mode 100644 index ea23f00..0000000 --- a/propertysources/pom.xml +++ /dev/null @@ -1,61 +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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.tamaya.ext</groupId> - <artifactId>tamaya-sandbox</artifactId> - <version>0.4-incubating-SNAPSHOT</version> - <relativePath>..</relativePath> - </parent> - <artifactId>tamaya-propertysources_alpha</artifactId> - <name>Apache Tamaya Modules - PropertySources</name> - <description>A collection of simple property sources and property source providers.</description> - <packaging>jar</packaging> - - <dependencies> - <dependency> - <groupId>org.apache.tamaya</groupId> - <artifactId>tamaya-core</artifactId> - <version>${project.parent.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>java-hamcrest</artifactId> - </dependency> - <dependency> - <groupId>org.apache.tamaya.ext</groupId> - <artifactId>tamaya-resources</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.apache.tamaya.ext</groupId> - <artifactId>tamaya-formats</artifactId> - <version>${project.parent.version}</version> - </dependency> - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirConfigSourceProvider.java ---------------------------------------------------------------------- diff --git a/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirConfigSourceProvider.java b/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirConfigSourceProvider.java deleted file mode 100644 index 8da14ca..0000000 --- a/propertysources/src/main/java/org/apache/tamaya/propertysources/ConfigDirConfigSourceProvider.java +++ /dev/null @@ -1,82 +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.propertysources; - - -import org.apache.tamaya.format.ConfigurationData; -import org.apache.tamaya.format.ConfigurationFormats; -import org.apache.tamaya.format.MappedConfigurationDataConfigSource; -import org.apache.tamaya.resource.AbstractPathConfigSourceProvider; -import org.apache.tamaya.spi.PropertySource; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * A property provider implementation that tries to read all files in a directory as - * configuration. - */ -public class ConfigDirConfigSourceProvider extends AbstractPathConfigSourceProvider { - - public ConfigDirConfigSourceProvider() { - super(getConfigLocation()); - } - - private static String getConfigLocation() { - String location = System.getProperty("configdir"); - if (location == null) { - location = "./config"; - } - if (!location.endsWith("/")) { - location += "/"; - } - if (!location.startsWith("file:")) { - location = "file:" + location; - } - return location + "**/*.*"; - } - - @Override - protected Collection<PropertySource> getPropertySources(URL url) { - try { - ConfigurationData config = ConfigurationFormats.readConfigurationData(url); - if (config == null) { - Logger.getLogger(getClass().getName()).log(Level.INFO, - "Failed to read configuration from " + url); - return Collections.emptySet(); - } - return asCollection(new MappedConfigurationDataConfigSource(config)); - } catch (Exception e) { - Logger.getLogger(getClass().getName()).log(Level.SEVERE, - "Failed to read configuration from " + url, e); - return Collections.emptySet(); - } - } - - private Collection<PropertySource> asCollection(PropertySource propertySource) { - List<PropertySource> result = new ArrayList<>(1); - result.add(propertySource); - return result; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigConfigSourceProvider.java ---------------------------------------------------------------------- diff --git a/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigConfigSourceProvider.java b/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigConfigSourceProvider.java deleted file mode 100644 index 48fd563..0000000 --- a/propertysources/src/main/java/org/apache/tamaya/propertysources/MetainfConfigConfigSourceProvider.java +++ /dev/null @@ -1,63 +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.propertysources; - - -import org.apache.tamaya.format.ConfigurationData; -import org.apache.tamaya.format.ConfigurationFormats; -import org.apache.tamaya.format.MappedConfigurationDataConfigSource; -import org.apache.tamaya.resource.AbstractPathConfigSourceProvider; -import org.apache.tamaya.spi.PropertySource; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Property source provider that reads all resources from {@code META-INF/config/**} - * into configuration sources.. - */ -public class MetainfConfigConfigSourceProvider extends AbstractPathConfigSourceProvider { - - public MetainfConfigConfigSourceProvider() { - super("classpath:META-INF/config/**/*.*"); - } - - @Override - protected Collection<PropertySource> getPropertySources(URL url) { - try { - ConfigurationData config = ConfigurationFormats.readConfigurationData(url); - return asCollection(new MappedConfigurationDataConfigSource(config)); - } catch (Exception e) { - Logger.getLogger(getClass().getName()).log(Level.SEVERE, - "Failed to read configuration from " + url, e); - return Collections.emptySet(); - } - } - - private Collection<PropertySource> asCollection(PropertySource propertySource) { - List<PropertySource> result = new ArrayList<>(1); - result.add(propertySource); - return result; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/propertysources/src/main/java/org/apache/tamaya/propertysources/PropertySourceBuilder.java ---------------------------------------------------------------------- diff --git a/propertysources/src/main/java/org/apache/tamaya/propertysources/PropertySourceBuilder.java b/propertysources/src/main/java/org/apache/tamaya/propertysources/PropertySourceBuilder.java deleted file mode 100644 index 2b1f96b..0000000 --- a/propertysources/src/main/java/org/apache/tamaya/propertysources/PropertySourceBuilder.java +++ /dev/null @@ -1,122 +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.propertysources; - -import org.apache.tamaya.spisupport.propertysource.SimplePropertySource; -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertyValue; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -/** - * Simple builder for building a {@link org.apache.tamaya.spi.PropertySource}. - */ -public final class PropertySourceBuilder { - /** The ordinal to be used. */ - private int ordinal; - /** The name to be used. */ - private final String name; - /** The properties. */ - private final Map<String,String> properties = new HashMap<>(); - - /** private constructor. */ - private PropertySourceBuilder(String name){ - this.name = Objects.requireNonNull(name); - } - - /** - * Gets a new instance of a builder. - * @param name The name of the property source, not null. - * @return a new instance. - */ - public static PropertySourceBuilder of(String name){ - return new PropertySourceBuilder(name); - } - - /** - * Gets a new instance of a builder. - * @param name The name of the property source, not null. - * @return a new instance. - */ - public static PropertySourceBuilder from(String name){ - return new PropertySourceBuilder(name); - } - - /** - * Sets a new property key/value. - * @param key the property key, not null. - * @param value the property value, not null. - * @return the bulder for chaining. - */ - public PropertySourceBuilder put(String key, String value){ - this.properties.put(key, value); - return this; - } - - /** - * Put all the given key, values. - * @param values the new key/values, not null. - * @return the bulder for chaining. - */ - public PropertySourceBuilder putAll(Map<String, String> values){ - this.properties.putAll(values); - return this; - } - - /** - * Sets the ordinal to be used explicitly (instead evaluating it using {@code tamaya.ordinal}. - * @param ordinal the explicit ordinal to be used. - * @return the bulder for chaining. - */ - public PropertySourceBuilder withOrdinal(int ordinal){ - this.ordinal = ordinal; - return this; - } - - /** - * Puts all values from the given property source. - * @param propertySource the property source, not null. - * @return the bulder for chaining. - */ - public PropertySourceBuilder putAll(PropertySource propertySource){ - for(PropertyValue val:propertySource.getProperties().values()) { - this.properties.put(val.getKey(), val.getValue()); - } - return this; - } - - /** - * Creates a new immutable {@link org.apache.tamaya.spi.PropertySource} instance. - * @return a new immutable {@link org.apache.tamaya.spi.PropertySource} instance, never null. - */ - public PropertySource build(){ - return new SimplePropertySource(name, properties); - } - - @Override - public String toString() { - return "PropertySourceBuilder{" + - "ordinal=" + ordinal + - ", name='" + name + '\'' + - ", properties=" + properties + - '}'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/propertysources/src/test/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProviderTest.java ---------------------------------------------------------------------- diff --git a/propertysources/src/test/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProviderTest.java b/propertysources/src/test/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProviderTest.java deleted file mode 100644 index 541b404..0000000 --- a/propertysources/src/test/java/org/apache/tamaya/propertysources/MetainfConfigPropertySourceProviderTest.java +++ /dev/null @@ -1,37 +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.propertysources; - -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * Created by atsticks on 30.10.16. - */ -public class MetainfConfigPropertySourceProviderTest { - - @Test - public void getPropertySources_Default() throws Exception { - MetainfConfigConfigSourceProvider provider = new MetainfConfigConfigSourceProvider(); - assertNotNull(provider.getPropertySources()); - // TODO add test for containing property sources. - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java ---------------------------------------------------------------------- diff --git a/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java b/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java index de65fb7..354294a 100644 --- a/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java +++ b/remote/src/main/java/org/apache/tamaya/remote/BaseRemotePropertySource.java @@ -18,11 +18,10 @@ */ package org.apache.tamaya.remote; +import org.apache.tamaya.base.configsource.BaseConfigSource; import org.apache.tamaya.format.ConfigurationData; import org.apache.tamaya.format.ConfigurationFormat; import org.apache.tamaya.json.JSONFormat; -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertyValue; import java.io.InputStream; import java.net.URL; @@ -37,24 +36,21 @@ import java.util.logging.Logger; * Abstract base class for implementing a PropertySource that reads configuration data from a remote resource. It uses * by default the JSON format as defined by the JSON module. */ -public abstract class BaseRemotePropertySource implements PropertySource{ +public abstract class BaseRemotePropertySource extends BaseConfigSource{ private static final ConfigurationFormat DEFAULT_FORMAT = new JSONFormat(); private Map<String,String> properties = new HashMap<>(); protected BaseRemotePropertySource(){ + super(); + setName(getClass().getSimpleName()); reload(); } @Override - public String getName() { - return getClass().getSimpleName(); - } - - @Override - public Map<String, PropertyValue> getProperties() { - return PropertyValue.map(properties, getName()); + public Map<String, String> getProperties() { + return Collections.unmodifiableMap(properties); } /** @@ -114,35 +110,4 @@ public abstract class BaseRemotePropertySource implements PropertySource{ return Collections.emptyMap(); } - @Override - public boolean isScannable(){ - return true; - } - - @Override - public PropertyValue get(String key) { - return getProperties().get(key); - } - - public int getOrdinal(){ - 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 0; - } - } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/uom/pom.xml ---------------------------------------------------------------------- diff --git a/uom/pom.xml b/uom/pom.xml index 2103499..019d0b7 100644 --- a/uom/pom.xml +++ b/uom/pom.xml @@ -35,6 +35,11 @@ <version>${project.parent.version}</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.tamaya</groupId> + <artifactId>tamaya-base</artifactId> + <version>${project.parent.version}</version> + </dependency> <dependency> <groupId>junit</groupId> http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/uom/src/main/java/org/apache/tamaya/uom/UnitConverter.java ---------------------------------------------------------------------- diff --git a/uom/src/main/java/org/apache/tamaya/uom/UnitConverter.java b/uom/src/main/java/org/apache/tamaya/uom/UnitConverter.java index d1baa43..77ea3b8 100644 --- a/uom/src/main/java/org/apache/tamaya/uom/UnitConverter.java +++ b/uom/src/main/java/org/apache/tamaya/uom/UnitConverter.java @@ -18,8 +18,9 @@ */ package org.apache.tamaya.uom; -import org.apache.tamaya.spi.ConversionContext; -import org.apache.tamaya.spi.PropertyConverter; +import org.apache.tamaya.base.convert.ConversionContext; + +import javax.config.spi.Converter; import javax.measure.Unit; import javax.measure.format.UnitFormat; import javax.measure.spi.ServiceProvider; @@ -35,14 +36,17 @@ import static java.util.Objects.requireNonNull; * @author wkeil */ // TODO not sure, if this could clash with JSR 363's own UnitConverter, but unless that's used here, it might be OK -public class UnitConverter implements PropertyConverter<Unit> { +public class UnitConverter implements Converter<Unit> { private static final String PATTERN_REGEX = "(\\+|-)?\\d+"; private static final Pattern IS_INTEGER_VALUE = Pattern.compile(PATTERN_REGEX); @Override - public Unit convert(String value, ConversionContext context) { + public Unit convert(String value) { String trimmed = requireNonNull(value).trim(); - addSupportedFormats(context); + ConversionContext context = ConversionContext.getContext(); + if(context!=null) { + context.addSupportedFormats(UnitConverter.class, "All Units supported by JSR 363"); + } UnitFormat format = ServiceProvider.current().getUnitFormatService().getUnitFormat(); Unit result = null; @@ -58,7 +62,4 @@ public class UnitConverter implements PropertyConverter<Unit> { return result; } - private void addSupportedFormats(ConversionContext context) { - context.addSupportedFormats(UnitConverter.class, "All Units supported by JSR 363"); - } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/uom/src/main/resources/META-INF/services/javax.config.spi.Converter ---------------------------------------------------------------------- diff --git a/uom/src/main/resources/META-INF/services/javax.config.spi.Converter b/uom/src/main/resources/META-INF/services/javax.config.spi.Converter new file mode 100644 index 0000000..8ddb69f --- /dev/null +++ b/uom/src/main/resources/META-INF/services/javax.config.spi.Converter @@ -0,0 +1,19 @@ +# +# 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 current 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. +# +org.apache.tamaya.uom.UnitConverter http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/uom/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter ---------------------------------------------------------------------- diff --git a/uom/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter b/uom/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter deleted file mode 100644 index 8ddb69f..0000000 --- a/uom/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter +++ /dev/null @@ -1,19 +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 current 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. -# -org.apache.tamaya.uom.UnitConverter http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/uom/src/test/java/org/apache/tamaya/uom/UnitConverterTest.java ---------------------------------------------------------------------- diff --git a/uom/src/test/java/org/apache/tamaya/uom/UnitConverterTest.java b/uom/src/test/java/org/apache/tamaya/uom/UnitConverterTest.java index 6e64fb1..c809272 100644 --- a/uom/src/test/java/org/apache/tamaya/uom/UnitConverterTest.java +++ b/uom/src/test/java/org/apache/tamaya/uom/UnitConverterTest.java @@ -18,9 +18,7 @@ */ package org.apache.tamaya.uom; -import org.apache.tamaya.spi.ConversionContext; import org.junit.Test; -import org.mockito.Mockito; import tec.units.ri.unit.Units; @@ -36,9 +34,7 @@ public class UnitConverterTest { @Test public void canConvertUnitInformation() { - ConversionContext context = Mockito.mock(ConversionContext.class); - - Unit<?> unit = converter.convert("m", context); + Unit<?> unit = converter.convert("m"); assertThat("Converter failed to convert input value " + unit, notNullValue()); assertEquals(unit, Units.METRE); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/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 495c62f..f352670 100644 --- a/vertx/src/main/java/org/apache/tamaya/vertx/AbstractConfiguredVerticle.java +++ b/vertx/src/main/java/org/apache/tamaya/vertx/AbstractConfiguredVerticle.java @@ -19,30 +19,32 @@ package org.apache.tamaya.vertx; import io.vertx.core.AbstractVerticle; -import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.inject.ConfigurationInjection; +import javax.config.Config; +import javax.config.ConfigProvider; +import java.util.Optional; + /** * Base verticle class that adds some convenience methods for accessing configuration. * The class also performs configuration injection using {@link ConfigurationInjection}. */ public abstract class AbstractConfiguredVerticle extends AbstractVerticle{ - private Configuration configuration; + private Config configuration; public AbstractConfiguredVerticle() { configure(); } - public Configuration getConfiguration(){ + public Config getConfiguration(){ if(configuration==null){ - return ConfigurationProvider.getConfiguration(); + return ConfigProvider.getConfig(); } return configuration; } - public void setConfiguration(Configuration configuration){ + public void setConfiguration(Config configuration){ this.configuration = configuration; } @@ -50,27 +52,19 @@ public abstract class AbstractConfiguredVerticle extends AbstractVerticle{ ConfigurationInjection.getConfigurationInjector().configure(this, getConfiguration()); } - protected final String getConfigProperty(String key){ - return getConfiguration().get(key); + protected final String getConfigValue(String key){ + return getConfiguration().getValue(key, String.class); } - protected final String getConfigPropertyOrDefault(String key, String defaultValue){ - String val = getConfiguration().get(key); - if(val==null){ - return defaultValue; - } - return val; + protected final Optional<String> getOptionalConfigValue(String key){ + return getConfiguration().getOptionalValue(key, String.class); } - protected final <T> T getConfigProperty(String key, Class<T> type){ - return getConfiguration().get(key, type); + protected final <T> T getConfigValue(String key, Class<T> type){ + return getConfiguration().getValue(key, type); } - protected final <T> T getConfigPropertyOrDefault(String key, Class<T> type, T defaultValue){ - T val = getConfiguration().get(key, type); - if(val==null){ - return defaultValue; - } - return val; + protected final <T> Optional<T> getOptionalConfigValue(String key, Class<T> type){ + return getConfiguration().getOptionalValue(key, type); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/db6b909a/vertx/src/main/java/org/apache/tamaya/vertx/ConfigVerticle.java ---------------------------------------------------------------------- diff --git a/vertx/src/main/java/org/apache/tamaya/vertx/ConfigVerticle.java b/vertx/src/main/java/org/apache/tamaya/vertx/ConfigVerticle.java index 228aece..37cbcd3 100644 --- a/vertx/src/main/java/org/apache/tamaya/vertx/ConfigVerticle.java +++ b/vertx/src/main/java/org/apache/tamaya/vertx/ConfigVerticle.java @@ -22,23 +22,22 @@ import io.vertx.core.Handler; import io.vertx.core.eventbus.Message; import io.vertx.core.eventbus.MessageConsumer; import io.vertx.core.json.Json; -import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.functions.ConfigurationFunctions; import org.apache.tamaya.functions.PropertyMatcher; -import org.apache.tamaya.inject.api.Config; -import java.util.Map; +import javax.config.Config; +import javax.config.ConfigProvider; +import javax.config.inject.ConfigProperty; /** * Small configured verticle for testing Tamaya's vertx support. */ public class ConfigVerticle extends AbstractConfiguredVerticle{ - @Config(value = "tamaya.vertx.config.map", defaultValue = "CONFIG-MAP") + @ConfigProperty(name = "tamaya.vertx.config.map", defaultValue = "CONFIG-MAP") private String mapBusTarget; - @Config(value = "tamaya.vertx.config.value", defaultValue = "CONFIG-VAL") + @ConfigProperty(name = "tamaya.vertx.config.value", defaultValue = "CONFIG-VAL") private String valBusTarget; private MessageConsumer<String> mapBusListener; @@ -50,24 +49,24 @@ public class ConfigVerticle extends AbstractConfiguredVerticle{ mapBusListener.handler(new Handler<Message<String>>(){ @Override public void handle(final Message<String> message) { - Configuration config = ConfigurationProvider.getConfiguration(); - Map<String,String> cfg = config.with(ConfigurationFunctions.filter( + Config config = ConfigProvider.getConfig(); + Config cfg = ConfigurationFunctions.filter( new PropertyMatcher() { @Override public boolean test(String key, String value) { return key.matches(message.body()); } } - )).getProperties(); - message.reply(Json.encodePrettily(cfg)); + ).apply(config); + message.reply(Json.encodePrettily(ConfigurationFunctions.toMap(cfg))); } }); valBusListener = vertx.eventBus().consumer(valBusTarget); valBusListener.handler(new Handler<Message<String>>(){ @Override public void handle(final Message<String> message) { - Configuration config = ConfigurationProvider.getConfiguration(); - message.reply(config.get(message.body())); + Config config = ConfigProvider.getConfig(); + message.reply(config.getValue(message.body(), String.class)); } }); }
