TAMAYA-355 Enable mapping of lists and arrays into internal datastructures, reestablished conversion/filter context (backward compatible).
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/89e3dfac Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/89e3dfac Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/89e3dfac Branch: refs/heads/master Commit: 89e3dfac3708bb96a19c1bbae537de711d763e6e Parents: 36c32fc Author: Anatole Tresch <[email protected]> Authored: Sat Nov 3 21:27:51 2018 +0100 Committer: Anatole Tresch <[email protected]> Committed: Sat Nov 3 21:27:51 2018 +0100 ---------------------------------------------------------------------- .../tamaya/springexample/ColorConverter.java | 3 +- .../tamaya/events/FrozenConfiguration.java | 27 ++-- .../apache/tamaya/events/TestConfigView.java | 27 ++-- .../filter/ThreadBasedConfigurationFilter.java | 9 +- .../tamaya/filter/ThreadFilterContext.java | 5 +- .../filter/internal/DefaultMetadataFilter.java | 5 +- .../tamaya/filter/ConfigurationFilterTest.java | 11 +- .../tamaya/filter/ProgrammableFilterTest.java | 130 ++++++------------- .../MappedConfigurationDataPropertySource.java | 12 +- .../tamaya/format/formats/PropertiesFormat.java | 3 +- .../apache/tamaya/json/JSONPropertySource.java | 4 - .../apache/tamaya/yaml/YAMLPropertySource.java | 5 - .../tamaya/cdi/ConfigurationProducer.java | 67 +++++----- .../tamaya/inject/spi/BaseDynamicValue.java | 21 ++- .../tamaya/inject/internal/InjectionHelper.java | 22 +--- .../internal/DefaultDynamicValueTest.java | 3 +- .../microprofile/MicroprofileConverter.java | 7 +- .../microprofile/TamayaPropertyConverter.java | 3 +- .../cdi/MicroprofileConfigurationProducer.java | 2 +- .../converter/BooleanAsIntegerConverterFix.java | 5 +- .../converter/ProviderConverter.java | 33 ++--- .../microprofile/MicroprofileAdapterTest.java | 9 +- .../microprofile/TamayaPropertySourceTest.java | 7 - .../UppercasePropertyConverter.java | 3 +- .../tamaya/osgi/commands/ConfigCommands.java | 1 - .../OSGIConfigAdminPropertySource.java | 3 +- .../injection/OSGIConfigurationInjector.java | 6 +- .../OSGIConfigAdminPropertySourceTest.java | 5 - .../internal/ExpressionResolutionFilter.java | 2 +- 29 files changed, 162 insertions(+), 278 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/examples/05-spring-example/src/main/java/org/apache/tamaya/springexample/ColorConverter.java ---------------------------------------------------------------------- diff --git a/examples/05-spring-example/src/main/java/org/apache/tamaya/springexample/ColorConverter.java b/examples/05-spring-example/src/main/java/org/apache/tamaya/springexample/ColorConverter.java index d625949..ac945b7 100644 --- a/examples/05-spring-example/src/main/java/org/apache/tamaya/springexample/ColorConverter.java +++ b/examples/05-spring-example/src/main/java/org/apache/tamaya/springexample/ColorConverter.java @@ -15,6 +15,7 @@ */ package org.apache.tamaya.springexample; +import org.apache.tamaya.spi.ConversionContext; import org.apache.tamaya.spi.PropertyConverter; import java.awt.*; @@ -25,7 +26,7 @@ import java.awt.*; public class ColorConverter implements PropertyConverter<Color>{ @Override - public Color convert(String value) { + public Color convert(String value, ConversionContext ctx) { if(value.length()<7){ return null; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java ---------------------------------------------------------------------- diff --git a/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java b/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java index 45375ec..f53bc1c 100644 --- a/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java +++ b/modules/events/src/main/java/org/apache/tamaya/events/FrozenConfiguration.java @@ -118,25 +118,20 @@ public final class FrozenConfiguration implements Configuration, Serializable { List<PropertyConverter<T>> converters = getContext() .getPropertyConverters(type); ConversionContext context = new ConversionContext.Builder(this, key,type).build(); - try { - ConversionContext.set(context); - for (PropertyConverter<T> converter : converters) { - try { - T t = converter.convert(value); - if (t != null) { - return t; - } - } catch (Exception e) { - Logger.getLogger(getClass().getName()) - .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert createValue: " + value, - e); + for (PropertyConverter<T> converter : converters) { + try { + T t = converter.convert(value, context); + if (t != null) { + return t; } + } catch (Exception e) { + Logger.getLogger(getClass().getName()) + .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert createValue: " + value, + e); } - throw new ConfigException("Unparseable config createValue for type: " + type.getRawType().getName() + ": " + key - + ", supported formats: " + context.getSupportedFormats()); - }finally{ - ConversionContext.reset(); } + throw new ConfigException("Unparseable config createValue for type: " + type.getRawType().getName() + ": " + key + + ", supported formats: " + context.getSupportedFormats()); } return null; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java ---------------------------------------------------------------------- diff --git a/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java b/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java index d12c5d6..0e9c340 100644 --- a/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java +++ b/modules/events/src/test/java/org/apache/tamaya/events/TestConfigView.java @@ -125,25 +125,20 @@ public class TestConfigView implements ConfigOperator{ .getPropertyConverters(type); ConversionContext context = new ConversionContext.Builder( key,type).build(); - try { - ConversionContext.set(context); - for (PropertyConverter<T> converter : converters) { - try { - T t = converter.convert(value); - if (t != null) { - return t; - } - } catch (Exception e) { - Logger.getLogger(getClass().getName()) - .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert createValue: " - + value, e); + for (PropertyConverter<T> converter : converters) { + try { + T t = converter.convert(value, context); + if (t != null) { + return t; } + } catch (Exception e) { + Logger.getLogger(getClass().getName()) + .log(Level.FINEST, "PropertyConverter: " + converter + " failed to convert createValue: " + + value, e); } - throw new ConfigException("Unparseable config createValue for type: " + type.getRawType().getName() + ": " - + key + ", supportedFormats: " + context.getSupportedFormats()); - }finally{ - ConversionContext.reset(); } + throw new ConfigException("Unparseable config createValue for type: " + type.getRawType().getName() + ": " + + key + ", supportedFormats: " + context.getSupportedFormats()); } return null; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/filter/src/main/java/org/apache/tamaya/filter/ThreadBasedConfigurationFilter.java ---------------------------------------------------------------------- diff --git a/modules/filter/src/main/java/org/apache/tamaya/filter/ThreadBasedConfigurationFilter.java b/modules/filter/src/main/java/org/apache/tamaya/filter/ThreadBasedConfigurationFilter.java index 1ba2962..a0df361 100644 --- a/modules/filter/src/main/java/org/apache/tamaya/filter/ThreadBasedConfigurationFilter.java +++ b/modules/filter/src/main/java/org/apache/tamaya/filter/ThreadBasedConfigurationFilter.java @@ -111,15 +111,14 @@ public final class ThreadBasedConfigurationFilter implements PropertyFilter{ } @Override - public PropertyValue filterProperty(PropertyValue valueToBeFiltered) { - FilterContext context = FilterContext.get(); - if(context==null || context.isSinglePropertyScoped()){ + public PropertyValue filterProperty(PropertyValue valueToBeFiltered, FilterContext context) { + if(context.isSinglePropertyScoped()){ for(PropertyFilter pred: THREADED_VALUE_FILTERS.get().getFilters()){ - valueToBeFiltered = pred.filterProperty(valueToBeFiltered); + valueToBeFiltered = pred.filterProperty(valueToBeFiltered, context); } }else{ for(PropertyFilter pred: THREADED_MAP_FILTERS.get().getFilters()){ - valueToBeFiltered = pred.filterProperty(valueToBeFiltered); + valueToBeFiltered = pred.filterProperty(valueToBeFiltered, context); } } return valueToBeFiltered; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/filter/src/main/java/org/apache/tamaya/filter/ThreadFilterContext.java ---------------------------------------------------------------------- diff --git a/modules/filter/src/main/java/org/apache/tamaya/filter/ThreadFilterContext.java b/modules/filter/src/main/java/org/apache/tamaya/filter/ThreadFilterContext.java index 8d16572..1d71eeb 100644 --- a/modules/filter/src/main/java/org/apache/tamaya/filter/ThreadFilterContext.java +++ b/modules/filter/src/main/java/org/apache/tamaya/filter/ThreadFilterContext.java @@ -18,6 +18,7 @@ */ package org.apache.tamaya.filter; +import org.apache.tamaya.spi.FilterContext; import org.apache.tamaya.spi.PropertyFilter; import org.apache.tamaya.spi.PropertyValue; @@ -102,9 +103,9 @@ public final class ThreadFilterContext implements PropertyFilter{ } @Override - public PropertyValue filterProperty(PropertyValue valueToBeFiltered) { + public PropertyValue filterProperty(PropertyValue valueToBeFiltered, FilterContext context) { for(PropertyFilter filter:filters){ - valueToBeFiltered = filter.filterProperty(valueToBeFiltered); + valueToBeFiltered = filter.filterProperty(valueToBeFiltered, context); } return valueToBeFiltered; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java ---------------------------------------------------------------------- diff --git a/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java b/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java index 481b314..18bef0a 100644 --- a/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java +++ b/modules/filter/src/main/java/org/apache/tamaya/filter/internal/DefaultMetadataFilter.java @@ -28,9 +28,8 @@ import org.apache.tamaya.spi.FilterContext; */ public final class DefaultMetadataFilter implements PropertyFilter{ @Override - public PropertyValue filterProperty(PropertyValue valueToBeFiltered) { - FilterContext context = FilterContext.get(); - if(context==null || context.isSinglePropertyScoped()){ + public PropertyValue filterProperty(PropertyValue valueToBeFiltered, FilterContext context) { + if(context.isSinglePropertyScoped()){ // When accessing keys explicitly, do not hide anything. return valueToBeFiltered; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java ---------------------------------------------------------------------- diff --git a/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java b/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java index bf3b5f4..942487c 100644 --- a/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java +++ b/modules/filter/src/test/java/org/apache/tamaya/filter/ConfigurationFilterTest.java @@ -19,6 +19,7 @@ package org.apache.tamaya.filter; import org.apache.tamaya.Configuration; +import org.apache.tamaya.spi.FilterContext; import org.apache.tamaya.spi.PropertyFilter; import org.apache.tamaya.spi.PropertyValue; import org.junit.Test; @@ -44,7 +45,7 @@ public class ConfigurationFilterTest { assertNotNull(ThreadBasedConfigurationFilter.getSingleValueFilterContext()); PropertyFilter testFilter = new PropertyFilter() { @Override - public PropertyValue filterProperty(PropertyValue value) { + public PropertyValue filterProperty(PropertyValue value, FilterContext ctx) { return value.setValue(value.getKey() + ":testGetSingleFilters"); } }; @@ -60,7 +61,7 @@ public class ConfigurationFilterTest { assertNotNull(ThreadBasedConfigurationFilter.getSingleValueFilterContext()); PropertyFilter testFilter = new PropertyFilter() { @Override - public PropertyValue filterProperty(PropertyValue value) { + public PropertyValue filterProperty(PropertyValue value, FilterContext ctx) { return value.setValue(value.getKey() + ":testGetSingleFilters"); } }; @@ -76,7 +77,7 @@ public class ConfigurationFilterTest { assertNotNull(ThreadBasedConfigurationFilter.getMapFilterContext()); PropertyFilter testFilter = new PropertyFilter() { @Override - public PropertyValue filterProperty(PropertyValue value) { + public PropertyValue filterProperty(PropertyValue value, FilterContext ctx) { return value.setValue(value.getKey() + ":testGetMapFilters"); } }; @@ -92,7 +93,7 @@ public class ConfigurationFilterTest { assertNotNull(ThreadBasedConfigurationFilter.getMapFilterContext()); PropertyFilter testFilter = new PropertyFilter() { @Override - public PropertyValue filterProperty(PropertyValue value) { + public PropertyValue filterProperty(PropertyValue value, FilterContext ctx) { return value.setValue(value.getKey() + ":testGetMapFilters"); } }; @@ -108,7 +109,7 @@ public class ConfigurationFilterTest { assertNotNull(ThreadBasedConfigurationFilter.getSingleValueFilterContext()); PropertyFilter testFilter = new PropertyFilter() { @Override - public PropertyValue filterProperty(PropertyValue value) { + public PropertyValue filterProperty(PropertyValue value, FilterContext ctx) { return value.setValue(value.getKey() + ":testGetSingleFilters"); } }; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/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 5f7f790..d6fa711 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 @@ -49,39 +49,23 @@ public class ProgrammableFilterTest { FilterContext context1 = new FilterContext(test1Property, map, context); FilterContext context2 = new FilterContext(test2Property, map, context); FilterContext context3 = new FilterContext(test3Property, map, context); - try{ - FilterContext.set(context1); - assertEquals(filter.filterProperty(test1Property), test1Property); - FilterContext.set(context2); - assertEquals(filter.filterProperty(test2Property), test2Property); - FilterContext.set(context3); - assertEquals(filter.filterProperty(test3Property), test3Property); - RegexPropertyFilter regexFilter = new RegexPropertyFilter(); - regexFilter.setIncludes("test\\..*"); - filter.addFilter(regexFilter); - FilterContext.set(context1); - assertNull(filter.filterProperty(test1Property)); - FilterContext.set(context2); - assertNull(filter.filterProperty(test2Property)); - FilterContext.set(context3); - assertEquals(filter.filterProperty(test3Property), test3Property); - filter.removeFilter(0); - FilterContext.set(context1); - assertEquals(filter.filterProperty(test1Property), test1Property); - FilterContext.set(context2); - assertEquals(filter.filterProperty(test2Property), test2Property); - FilterContext.set(context3); - assertEquals(filter.filterProperty(test3Property), test3Property); - filter.addFilter(0, regexFilter); - FilterContext.set(context1); - assertNull(filter.filterProperty(test1Property)); - FilterContext.set(context2); - assertNull(filter.filterProperty(test2Property)); - FilterContext.set(context3); - assertEquals(filter.filterProperty(test3Property), test3Property); - }finally { - FilterContext.reset(); - } + assertEquals(filter.filterProperty(test1Property, context1), test1Property); + assertEquals(filter.filterProperty(test2Property, context2), test2Property); + assertEquals(filter.filterProperty(test3Property, context3), test3Property); + RegexPropertyFilter regexFilter = new RegexPropertyFilter(); + regexFilter.setIncludes("test\\..*"); + filter.addFilter(regexFilter); + assertNull(filter.filterProperty(test1Property, context1)); + assertNull(filter.filterProperty(test2Property, context2)); + assertEquals(filter.filterProperty(test3Property, context3), test3Property); + filter.removeFilter(0); + assertEquals(filter.filterProperty(test1Property, context1), test1Property); + assertEquals(filter.filterProperty(test2Property, context2), test2Property); + assertEquals(filter.filterProperty(test3Property, context3), test3Property); + filter.addFilter(0, regexFilter); + assertNull(filter.filterProperty(test1Property, context1)); + assertNull(filter.filterProperty(test2Property, context2)); + assertEquals(filter.filterProperty(test3Property, context3), test3Property); } @Test @@ -97,30 +81,17 @@ public class ProgrammableFilterTest { FilterContext context1 = new FilterContext(test1Property, context); FilterContext context2 = new FilterContext(test2Property, context); FilterContext context3 = new FilterContext(test3Property, context); - try{ - FilterContext.set(context1); - assertEquals(filter.filterProperty(test1Property), test1Property); - FilterContext.set(context2); - assertEquals(filter.filterProperty(test2Property), test2Property); - FilterContext.set(context3); - assertEquals(filter.filterProperty(test3Property), test3Property); - filter.addFilter(regexFilter); - FilterContext.set(context1); - assertEquals(filter.filterProperty(test1Property), test1Property); - FilterContext.set(context2); - assertNull(filter.filterProperty(test2Property)); - FilterContext.set(context3); - assertNull(filter.filterProperty(test3Property)); - filter.clearFilters(); - FilterContext.set(context1); - assertEquals(filter.filterProperty(test1Property), test1Property); - FilterContext.set(context2); - assertEquals(filter.filterProperty(test2Property), test2Property); - FilterContext.set(context3); - assertEquals(filter.filterProperty(test3Property), test3Property); - }finally { - FilterContext.reset(); - } + assertEquals(filter.filterProperty(test1Property, context1), test1Property); + assertEquals(filter.filterProperty(test2Property, context2), test2Property); + assertEquals(filter.filterProperty(test3Property, context3), test3Property); + filter.addFilter(regexFilter); + assertEquals(filter.filterProperty(test1Property, context1), test1Property); + assertNull(filter.filterProperty(test2Property, context2)); + assertNull(filter.filterProperty(test3Property, context3)); + filter.clearFilters(); + assertEquals(filter.filterProperty(test1Property, context1), test1Property); + assertEquals(filter.filterProperty(test2Property, context2), test2Property); + assertEquals(filter.filterProperty(test3Property, context3), test3Property); } @Test @@ -136,23 +107,10 @@ public class ProgrammableFilterTest { FilterContext context1 = new FilterContext(test1Property, map, context); FilterContext context2 = new FilterContext(test2Property, map, context); FilterContext context3 = new FilterContext(test3Property, map, context); - try{ - FilterContext.set(context1); - assertEquals(filter.filterProperty(test1Property), test1Property); - FilterContext.set(context2); - assertEquals(filter.filterProperty(test2Property), test2Property); - FilterContext.set(context3); - assertEquals(filter.filterProperty(test3Property), test3Property); - filter.setFilters(regexFilter); - FilterContext.set(context1); - assertEquals(filter.filterProperty(test3Property), test3Property); - FilterContext.set(context2); - assertNull(filter.filterProperty(test2Property)); - FilterContext.set(context3); - assertNull(filter.filterProperty(test1Property)); - }finally { - FilterContext.reset(); - } + assertEquals(filter.filterProperty(test1Property, context1), test1Property); + assertEquals(filter.filterProperty(test2Property, context2), test2Property); + assertEquals(filter.filterProperty(test3Property, context3), test3Property); + assertEquals(filter.filterProperty(test3Property, context1), test3Property); } @Test @@ -164,23 +122,13 @@ public class ProgrammableFilterTest { FilterContext context1 = new FilterContext(test1Property, context); FilterContext context2 = new FilterContext(test2Property, context); FilterContext context3 = new FilterContext(test3Property, context); - try { - FilterContext.set(context1); - assertEquals(filter.filterProperty(test1Property), test1Property); - FilterContext.set(context2); - assertEquals(filter.filterProperty(test2Property), test2Property); - FilterContext.set(context3); - assertEquals(filter.filterProperty(test3Property), test3Property); - filter.setFilters(Arrays.asList(new PropertyFilter[]{regexFilter})); - FilterContext.set(context1); - assertEquals(filter.filterProperty(test1Property), test1Property); - FilterContext.set(context2); - assertNull(filter.filterProperty(test2Property)); - FilterContext.set(context3); - assertNull(filter.filterProperty(test3Property)); - }finally { - FilterContext.reset(); - } + assertEquals(filter.filterProperty(test1Property, context1), test1Property); + assertEquals(filter.filterProperty(test2Property, context2), test2Property); + assertEquals(filter.filterProperty(test3Property, context3), test3Property); + filter.setFilters(Arrays.asList(new PropertyFilter[]{regexFilter})); + assertEquals(filter.filterProperty(test1Property, context1), test1Property); + assertNull(filter.filterProperty(test2Property, context2)); + assertNull(filter.filterProperty(test3Property, context3)); } @Test http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/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 2fff0ee..d63500a 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 @@ -101,13 +101,13 @@ public class MappedConfigurationDataPropertySource extends BasePropertySource { if(this.properties==null) { this.properties = new HashMap<>(); } - this.properties.put("_meta.propertysource."+getName()+"exception", - PropertyValue.of("_meta.propertysource."+getName()+"exception", - e.getLocalizedMessage(), + this.properties.put("[error]propertysource."+getName()+".exception", + PropertyValue.createValue("[meta]propertysource."+getName()+".exception", + e.getLocalizedMessage()).setMeta("source", data.getResource())); - this.properties.put("_meta.propertysource."+getName()+"exception", - PropertyValue.of("_meta.propertysource."+getName()+"state", - "ERROR", + this.properties.put("[error]propertysource."+getName()+".exception", + PropertyValue.createValue("[meta]propertysource."+getName()+".state", + "ERROR").setMeta("source", data.getResource())); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java ---------------------------------------------------------------------- diff --git a/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java b/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java index 615e447..458d31e 100644 --- a/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java +++ b/modules/formats/base/src/main/java/org/apache/tamaya/format/formats/PropertiesFormat.java @@ -55,7 +55,8 @@ public class PropertiesFormat implements ConfigurationFormat { p.load(inputStream); Set<PropertyValue> data = new HashSet<>(); for(Map.Entry en:p.entrySet()) { - PropertyValue pv = PropertyValue.of(en.getKey().toString(), en.getValue().toString(), resource) + PropertyValue pv = PropertyValue.createValue(en.getKey().toString(), en.getValue().toString()) + .setMeta("source", resource) .setMeta(ConfigurationFormat.class, this); data.add(pv); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java index 06209e6..2353e28 100644 --- a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java +++ b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java @@ -144,8 +144,4 @@ public class JSONPropertySource implements PropertySource { } } - @Override - public boolean isScannable() { - return true; - } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java ---------------------------------------------------------------------- diff --git a/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java b/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java index 2f94d43..4a0b26d 100644 --- a/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java +++ b/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java @@ -100,9 +100,4 @@ public class YAMLPropertySource implements PropertySource { return Collections.unmodifiableMap(values); } - - @Override - public boolean isScannable() { - return true; - } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/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 9944678..f9dd1da 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 @@ -140,46 +140,41 @@ public class ConfigurationProducer { static Object convertValue(String textValue, ConversionContext conversionContext, InjectionPoint injectionPoint, PropertyConverter customConverter) { Object value = null; - try { - ConversionContext.set(conversionContext); - if (customConverter != null) { - return customConverter.convert(textValue); - } - if (String.class.equals(conversionContext.getTargetType().getRawType())) { - return textValue; + if (customConverter != null) { + return customConverter.convert(textValue, conversionContext); + } + if (String.class.equals(conversionContext.getTargetType().getRawType())) { + return textValue; + } + ParameterizedType pt = null; + Type toType = injectionPoint.getAnnotated().getBaseType(); + if (toType instanceof ParameterizedType) { + pt = (ParameterizedType) toType; + if (Provider.class.equals(pt.getRawType()) || Instance.class.equals(pt.getRawType()) + || Optional.class.equals(pt.getRawType())) { + toType = pt.getActualTypeArguments()[0]; } - ParameterizedType pt = null; - Type toType = injectionPoint.getAnnotated().getBaseType(); - if (toType instanceof ParameterizedType) { - 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; - } + if (toType.equals(String.class)) { + value = textValue; } - List<PropertyConverter<Object>> converters = Configuration.current().getContext() - .getPropertyConverters(TypeLiteral.of(toType)); - for (PropertyConverter<Object> converter : converters) { - try { - value = converter.convert(textValue); - if (value != null) { - LOGGER.log(Level.INFO, "Parsed createValue from '" + textValue + "' into " + - injectionPoint); - break; - } - } catch (Exception e) { - LOGGER.log(Level.INFO, "Failed to convert createValue '" + textValue + "' for " + - injectionPoint, e); + } + List<PropertyConverter<Object>> converters = Configuration.current().getContext() + .getPropertyConverters(TypeLiteral.of(toType)); + for (PropertyConverter<Object> converter : converters) { + try { + value = converter.convert(textValue, conversionContext); + if (value != null) { + LOGGER.log(Level.INFO, "Parsed createValue from '" + textValue + "' into " + + injectionPoint); + break; } + } catch (Exception e) { + LOGGER.log(Level.INFO, "Failed to convert createValue '" + textValue + "' for " + + injectionPoint, e); } - if (pt != null && Optional.class.equals(pt.getRawType())) { - return Optional.ofNullable(value); - } - }finally{ - ConversionContext.reset(); + } + 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/89e3dfac/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/spi/BaseDynamicValue.java ---------------------------------------------------------------------- diff --git a/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/spi/BaseDynamicValue.java b/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/spi/BaseDynamicValue.java index 4a4df72..1b21d01 100644 --- a/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/spi/BaseDynamicValue.java +++ b/modules/injection/injection-api/src/main/java/org/apache/tamaya/inject/spi/BaseDynamicValue.java @@ -289,7 +289,7 @@ public abstract class BaseDynamicValue<T> implements DynamicValue<T> { } for(PropertyConverter<T> conv:converters){ try{ - value = conv.convert(stringVal); + value = conv.convert(stringVal, ctx); if(value!=null){ break; } @@ -301,20 +301,15 @@ public abstract class BaseDynamicValue<T> implements DynamicValue<T> { } if(value == null && defaultValue!=null){ ConversionContext ctx = new ConversionContext.Builder("<defaultValue>", targetType).build(); - try { - ConversionContext.set(ctx); - for (PropertyConverter<T> conv : converters) { - try { - value = conv.convert(defaultValue); - if (value != null) { - break; - } - } catch (Exception e) { - LOG.warning("failed to convert: " + ctx); + for (PropertyConverter<T> conv : converters) { + try { + value = conv.convert(defaultValue, ctx); + if (value != null) { + break; } + } catch (Exception e) { + LOG.warning("failed to convert: " + ctx); } - }finally{ - ConversionContext.reset(); } } return value; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/InjectionHelper.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/InjectionHelper.java b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/InjectionHelper.java index 3a3d80e..a143498 100644 --- a/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/InjectionHelper.java +++ b/modules/injection/standalone/src/main/java/org/apache/tamaya/inject/internal/InjectionHelper.java @@ -170,14 +170,11 @@ final class InjectionHelper { // TODO cache here... ConversionContext ctx = new ConversionContext.Builder(key,targetType) .setAnnotatedElement(element).build(); - ConversionContext.set(ctx); PropertyConverter<T> converter = PropertyConverter.class.cast(converterType.newInstance()); - adaptedValue = converter.convert(configValue); + adaptedValue = converter.convert(configValue, ctx); } catch (Exception e) { LOG.log(Level.SEVERE, "Failed to convert using explicit PropertyConverter on " + element + ", trying default conversion.", e); - }finally{ - ConversionContext.reset(); } } } @@ -193,18 +190,13 @@ final class InjectionHelper { ConfigurationContext configContext = Configuration.current().getContext(); List<PropertyConverter<T>> converters = configContext .getPropertyConverters(targetType); - try { - ConversionContext ctx = new ConversionContext.Builder(Configuration.current(), - key, targetType).setAnnotatedElement(element).build(); - ConversionContext.set(ctx); - for (PropertyConverter<T> converter : converters) { - adaptedValue = converter.convert(configValue); - if (adaptedValue != null) { - return adaptedValue; - } + ConversionContext ctx = new ConversionContext.Builder(Configuration.current(), + key, targetType).setAnnotatedElement(element).build(); + for (PropertyConverter<T> converter : converters) { + adaptedValue = converter.convert(configValue, ctx); + if (adaptedValue != null) { + return adaptedValue; } - }finally { - ConversionContext.reset(); } } throw new ConfigException("Non convertible property type: " + element); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java ---------------------------------------------------------------------- diff --git a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java index b055021..5adaf5f 100644 --- a/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java +++ b/modules/injection/standalone/src/test/java/org/apache/tamaya/inject/internal/DefaultDynamicValueTest.java @@ -22,6 +22,7 @@ import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.inject.api.DynamicValue; import org.apache.tamaya.inject.api.Config; import org.apache.tamaya.inject.api.UpdatePolicy; +import org.apache.tamaya.spi.ConversionContext; import org.apache.tamaya.spi.PropertyConverter; import org.apache.tamaya.spi.PropertySource; import org.apache.tamaya.spi.PropertyValue; @@ -307,7 +308,7 @@ public class DefaultDynamicValueTest { private static final class DoublicatingConverter implements PropertyConverter<String>{ @Override - public String convert(String value) { + public String convert(String value, ConversionContext ctx) { return value + value; } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConverter.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConverter.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConverter.java index 2e72ce1..e1ac08d 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConverter.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/MicroprofileConverter.java @@ -46,11 +46,6 @@ public class MicroprofileConverter<T> implements Converter<T> { public T convert(String value) { ConversionContext ctx = new ConversionContext.Builder("microprofile:no-key", TypeLiteral.of( TypeLiteral.of(getClass()).getType())).build(); - ConversionContext.set(ctx); - try{ - return delegate.convert(value); - }finally { - ConversionContext.reset(); - } + return delegate.convert(value, ctx); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/TamayaPropertyConverter.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/TamayaPropertyConverter.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/TamayaPropertyConverter.java index d059434..a83008a 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/TamayaPropertyConverter.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/TamayaPropertyConverter.java @@ -19,6 +19,7 @@ package org.apache.tamaya.microprofile; +import org.apache.tamaya.spi.ConversionContext; import org.apache.tamaya.spi.PropertyConverter; import org.eclipse.microprofile.config.spi.ConfigSource; import org.eclipse.microprofile.config.spi.Converter; @@ -41,7 +42,7 @@ public class TamayaPropertyConverter<T> implements PropertyConverter<T> { } @Override - public T convert(String value) { + public T convert(String value, ConversionContext context) { return delegate.convert(value); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java index f349d7d..e3afea5 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java @@ -125,7 +125,7 @@ public class MicroprofileConfigurationProducer { .getPropertyConverters((TypeLiteral)context.getTargetType()); for (PropertyConverter<Object> converter : converters) { try { - value = converter.convert(textValue); + value = converter.convert(textValue, context); if (value != null) { LOGGER.log(Level.FINEST, "Parsed default createValue from '" + textValue + "' into " + injectionPoint); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/BooleanAsIntegerConverterFix.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/BooleanAsIntegerConverterFix.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/BooleanAsIntegerConverterFix.java index 7c760c5..8f292bb 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/BooleanAsIntegerConverterFix.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/BooleanAsIntegerConverterFix.java @@ -32,9 +32,8 @@ import org.apache.tamaya.spi.PropertyConverter; public class BooleanAsIntegerConverterFix implements PropertyConverter<Boolean> { @Override - public Boolean convert(String value) { - ConversionContext.doOptional(ctx -> - ctx.addSupportedFormats(getClass(), "'1' (true), otherwise false.")); + public Boolean convert(String value, ConversionContext context) { + context.addSupportedFormats(getClass(), "'1' (true), otherwise false."); try{ int val = Integer.parseInt(Objects.requireNonNull(value).trim()); if(val==1) { http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java index 043d9b9..f15dd38 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java @@ -42,13 +42,9 @@ public class ProviderConverter implements PropertyConverter<Provider> { @SuppressWarnings({"unchecked"}) @Override - public Provider convert(String value) { + public Provider convert(String value, ConversionContext context) { return () -> { - ConversionContext context = ConversionContext.current(); try{ - if(context==null){ - return null; - } Type targetType = context.getTargetType().getType(); ConvertQuery converter = new ConvertQuery(value, TypeLiteral.of(targetType)); return context.getConfiguration().adapt(converter); @@ -83,24 +79,19 @@ public class ProviderConverter implements PropertyConverter<Provider> { List<PropertyConverter<T>> converters = config.getContext().getPropertyConverters(type); ConversionContext context = new ConversionContext.Builder(type).setConfiguration(config) .setConfiguration(config).setKey(ConvertQuery.class.getName()).build(); - try{ - ConversionContext.set(context); - for(PropertyConverter<?> conv: converters) { - try{ - if(conv instanceof ProviderConverter){ - continue; - } - @SuppressWarnings("unchecked") - T result = (T)conv.convert(rawValue); - if(result!=null){ - return result; - } - }catch(Exception e){ - LOG.log(Level.FINEST, e, () -> "Converter "+ conv +" failed to convert to " + type); + for(PropertyConverter<?> conv: converters) { + try{ + if(conv instanceof ProviderConverter){ + continue; + } + @SuppressWarnings("unchecked") + T result = (T)conv.convert(rawValue, context); + if(result!=null){ + return result; } + }catch(Exception e){ + LOG.log(Level.FINEST, e, () -> "Converter "+ conv +" failed to convert to " + type); } - }finally { - ConversionContext.reset(); } return null; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/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 7a94d6e..beaac77 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 @@ -19,10 +19,7 @@ package org.apache.tamaya.microprofile; import org.apache.tamaya.*; -import org.apache.tamaya.spi.ConfigurationContext; -import org.apache.tamaya.spi.PropertyConverter; -import org.apache.tamaya.spi.PropertySource; -import org.apache.tamaya.spi.PropertyValue; +import org.apache.tamaya.spi.*; import org.apache.tamaya.spisupport.propertysource.BuildablePropertySource; import org.assertj.core.api.Assertions; import org.eclipse.microprofile.config.Config; @@ -142,7 +139,7 @@ public class MicroprofileAdapterTest { public void toPropertyConverter() throws Exception { PropertyConverter<String> tamayaConverter = MicroprofileAdapter.toPropertyConverter(new UppercaseConverter()); assertNotNull(tamayaConverter); - assertEquals("ABC", tamayaConverter.convert("aBC")); + assertEquals("ABC", tamayaConverter.convert("aBC", null)); } @Test @@ -176,7 +173,7 @@ public class MicroprofileAdapterTest { assertNotNull(tamayaProps); assertEquals(tamayaProps.keySet(), props.keySet()); assertEquals(tamayaProps.get("a").getValue(), "b"); - assertEquals("toPropertyValueMap", tamayaProps.get("a").getSource()); + assertEquals("toPropertyValueMap", tamayaProps.get("a").getMeta("source")); } static class MyConfig implements Config { http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/TamayaPropertySourceTest.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/TamayaPropertySourceTest.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/TamayaPropertySourceTest.java index 47567d2..2abbcb1 100644 --- a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/TamayaPropertySourceTest.java +++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/TamayaPropertySourceTest.java @@ -33,13 +33,6 @@ public class TamayaPropertySourceTest { private ConfigSource configSource; @Test - public void isScannable() throws Exception { - TamayaPropertySource source = new TamayaPropertySource(configSource); - - assertThat(source.isScannable()).isTrue(); - } - - @Test public void ordinalIsTheSameAsOfTheConfigSource() throws Exception { when(configSource.getOrdinal()).thenReturn(44); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/UppercasePropertyConverter.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/UppercasePropertyConverter.java b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/UppercasePropertyConverter.java index 74111e3..849d014 100644 --- a/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/UppercasePropertyConverter.java +++ b/modules/microprofile/src/test/java/org/apache/tamaya/microprofile/UppercasePropertyConverter.java @@ -18,6 +18,7 @@ */ package org.apache.tamaya.microprofile; +import org.apache.tamaya.spi.ConversionContext; import org.apache.tamaya.spi.PropertyConverter; import java.util.Locale; @@ -25,7 +26,7 @@ import java.util.Locale; public class UppercasePropertyConverter implements PropertyConverter<String> { @Override - public String convert(String s) { + public String convert(String s, ConversionContext context) { if(s==null){ return null; } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java ---------------------------------------------------------------------- diff --git a/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java b/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java index 2bc9af8..acc0104 100644 --- a/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java +++ b/modules/osgi/common/src/main/java/org/apache/tamaya/osgi/commands/ConfigCommands.java @@ -19,7 +19,6 @@ package org.apache.tamaya.osgi.commands; import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.functions.ConfigurationFunctions; import org.apache.tamaya.osgi.Policy; import org.apache.tamaya.spi.PropertySource; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/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 6c5b00a..d7beab8 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 @@ -74,7 +74,8 @@ public class OSGIConfigAdminPropertySource extends BasePropertySource{ if(props!=null){ Object value = props.get(key); if(value!=null) { - return PropertyValue.of(key, String.valueOf(value), "OSGI ConfigAdmin: " + pid); + return PropertyValue.createValue(key, String.valueOf(value)) + .setMeta("source", "OSGI ConfigAdmin: " + pid); } } } catch (IOException e) { http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java ---------------------------------------------------------------------- diff --git a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java index dc90449..1fac59b 100644 --- a/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java +++ b/modules/osgi/injection/src/main/java/org/apache/tamaya/osgi/injection/OSGIConfigurationInjector.java @@ -19,7 +19,6 @@ package org.apache.tamaya.osgi.injection; import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.inject.ConfigurationInjection; import org.osgi.service.cm.ConfigurationAdmin; @@ -59,12 +58,11 @@ final class OSGIConfigurationInjector{ this.cm = Objects.requireNonNull(cm); this.pid = Objects.requireNonNull(pid); this.location = location; - tamayaOSGIConfiguration = ConfigurationProvider.createConfiguration( - ConfigurationProvider.getConfigurationContextBuilder() + tamayaOSGIConfiguration = Configuration.createConfigurationBuilder() .addDefaultPropertyConverters() .addDefaultPropertyFilters() .addPropertySources(new OSGIConfigAdminPropertySource(cm, pid, location)) - .build()); + .build(); } /** http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySourceTest.java ---------------------------------------------------------------------- diff --git a/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySourceTest.java b/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySourceTest.java index cff8c3f..5dba958 100644 --- a/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySourceTest.java +++ b/modules/osgi/injection/src/test/java/org/apache/tamaya/osgi/injection/OSGIConfigAdminPropertySourceTest.java @@ -62,11 +62,6 @@ public class OSGIConfigAdminPropertySourceTest extends AbstractOSGITest{ } @Test - public void isScannable() throws Exception { - assertEquals(true, propertySource.isScannable()); - } - - @Test public void get() throws Exception { PropertyValue val = propertySource.get("java.home"); assertNotNull(val); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/89e3dfac/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java ---------------------------------------------------------------------- diff --git a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java index 3b8db24..c7c6a17 100644 --- a/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java +++ b/modules/resolver/src/main/java/org/apache/tamaya/resolver/internal/ExpressionResolutionFilter.java @@ -95,7 +95,7 @@ public class ExpressionResolutionFilter implements PropertyFilter, ClassloaderAw * @return the resolved createValue, or the input in case where no expression was detected. */ @Override - public PropertyValue filterProperty(PropertyValue valueToBeFiltered){ + public PropertyValue filterProperty(PropertyValue valueToBeFiltered, FilterContext context){ LOG.finest("Resolving " + valueToBeFiltered); String newVal = evaluator().evaluateExpression(valueToBeFiltered.getKey(), valueToBeFiltered.getValue(), true); if(newVal!=null){
