tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [7/8] incubator-tamaya git commit: Applied several quality fixes. Aligned Java 7 with Java 8.
Date Fri, 27 Feb 2015 02:40:52 GMT
Applied several quality fixes.
Aligned Java 7 with Java 8.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/0ce780da
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/0ce780da
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/0ce780da

Branch: refs/heads/master
Commit: 0ce780da6833d801ca9bf6f8e9c2dbe208959ce1
Parents: 237bbcd
Author: anatole <anatole@apache.org>
Authored: Fri Feb 27 03:38:57 2015 +0100
Committer: anatole <anatole@apache.org>
Committed: Fri Feb 27 03:40:37 2015 +0100

----------------------------------------------------------------------
 .../apache/tamaya/ConfigurationProvider.java    |  41 +++++
 .../tamaya/spi/ConfigurationContextBuilder.java | 184 +++++++++++++++++++
 .../tamaya/spi/ConfigurationProviderSpi.java    |  29 +++
 .../internal/DefaultConfigurationContext.java   |  75 ++++----
 .../DefaultConfigurationContextBuilder.java     | 144 +++++++++++++++
 .../internal/DefaultConfigurationProvider.java  |  14 ++
 .../ConverterTestsPropertySource.java           |   2 +-
 .../java/org/apache/tamaya/TypeLiteral.java     |   9 +-
 .../ConverterTestsPropertySource.java           |   5 +
 9 files changed, 455 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0ce780da/java7/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/java7/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java b/java7/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
index 69045b5..46a2315 100644
--- a/java7/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
+++ b/java7/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
@@ -17,6 +17,7 @@
 package org.apache.tamaya;
 
 import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConfigurationContextBuilder;
 import org.apache.tamaya.spi.ConfigurationProviderSpi;
 import org.apache.tamaya.spi.ServiceContextManager;
 
@@ -58,4 +59,44 @@ public final class ConfigurationProvider {
         return PROVIDER_SPI.getConfigurationContext();
     }
 
+    /**
+     * This method allows to replace the current {@link org.apache.tamaya.spi.ConfigurationContext}
with a new
+     * instance. This can be used to update the context with a new one, e.g. because some
of the configuration
+     * data has changed and should be updated. It is the responsibility of the ConfigurationProvider
to trigger
+     * corresponding update events for the current {@link org.apache.tamaya.Configuration},
so observing
+     * listeners can do whatever is appropriate to react to any given configuration changes.
+     *
+     * @param context the new ConfigurationContext to be applied.
+     * @throws java.lang.UnsupportedOperationException if the current provider is read-only
and does not support
+     *                                                 applying a new ConfigurationContext.
+     */
+    public static void setConfigurationContext(ConfigurationContext context) {
+        PROVIDER_SPI.setConfigurationContext(context);
+    }
+
+    /**
+     * Method that allows to determine if a new {@link org.apache.tamaya.spi.ConfigurationContext}
can be applied
+     * programmatically.
+     * @see #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)
+     * @return true, if {@link #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)}
is supported
+     * by the current implementation.
+     */
+    public static boolean isConfigurationContextSettable() {
+        return PROVIDER_SPI.isConfigurationContextSettable();
+    }
+
+    /**
+     * Create a new {@link org.apache.tamaya.spi.ConfigurationContextBuilder} instance. This
method creates
+     * a new builder instance that is not related to any concrete {@link org.apache.tamaya.spi.ConfigurationContext}.
+     * You can use {@link #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)}
to change the
+     * current configuration context.
+     *
+     * @return a new, empty {@link org.apache.tamaya.spi.ConfigurationContextBuilder}, never
null.
+     * @see #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)
+     * @see org.apache.tamaya.spi.ConfigurationContext
+     */
+    public static ConfigurationContextBuilder getConfigurationContextBuilder() {
+        return PROVIDER_SPI.getConfigurationContextBuilder();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0ce780da/java7/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/java7/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java
b/java7/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java
new file mode 100644
index 0000000..4555bc8
--- /dev/null
+++ b/java7/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java
@@ -0,0 +1,184 @@
+/*
+ * 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.spi;
+
+import org.apache.tamaya.PropertyConverter;
+import org.apache.tamaya.TypeLiteral;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.function.Predicate;
+
+/**
+ * A builder for creating new or adapting instances of {@link ConfigurationContext}.
+ * Builders can be obtained in exactly two ways:
+ * <ol>
+ *     <li>By accessing a preinitialized builder from an existing {@link ConfigurationContext},
+ *     by calling {@link org.apache.tamaya.spi.ConfigurationContext#toBuilder()}.</li>
+ *     <li>By accessing an empty builder instance from
+ *     {@link org.apache.tamaya.ConfigurationProvider#getConfigurationContextBuilder()}.</li>
+ * </ol>
+ * After all changes are applied to a builder a new {@link ConfigurationContext} instance
can
+ * be created and can be applied by calling
+ * {@link org.apache.tamaya.ConfigurationProvider#setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)}.
Since this method can
+ * throw an UnsupportedOperationException, you should check before if changing the current
ConfigurationContext
+ * programmatically is supported by calling
+ * {@link org.apache.tamaya.ConfigurationProvider#isConfigurationContextSettable()}.
+ */
+public interface ConfigurationContextBuilder {
+
+    /**
+     * Init this builder instance with the given {@link ConfigurationContext} instance. This
+     * method will replace any existing data in the current builder with the data contained
in the given
+     * {@link ConfigurationContext}.
+     *
+     * @param context the {@link ConfigurationContext} instance to be used, not null.
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder setContext(ConfigurationContext context);
+
+    /**
+     * This method can be used for programmatically adding {@link PropertySource}s.
+     * It is not needed for normal 'usage' by end users, but only for Extension Developers!
+     *
+     * @param propertySourcesToAdd the PropertySources to add
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder addPropertySources(PropertySource... propertySourcesToAdd);
+
+    /**
+     * This method can be used for programmatically adding {@link PropertySource}s.
+     * It is not needed for normal 'usage' by end users, but only for Extension Developers!
+     *
+     * @param propertySourcesToAdd the PropertySources to add
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder addPropertySources(Collection<PropertySource> propertySourcesToAdd);
+
+    /**
+     * This method can be used for programmatically adding {@link PropertySource}s.
+     * It is not needed for normal 'usage' by end users, but only for Extension Developers!
+     *
+     * @param propertySourcesNames the PropertySource names of the sources to remove
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder removePropertySources(String... propertySourcesNames);
+
+    /**
+     * This method can be used for programmatically adding {@link PropertySource}s.
+     * It is not needed for normal 'usage' by end users, but only for Extension Developers!
+     *
+     * @param propertySourcesNames the PropertySource names of the sources to remove
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder removePropertySources(Collection<String> propertySourcesNames);
+
+    /**
+     * Adds the given PropertyFilter instances.
+     *
+     * @param filters the filters to add
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder addPropertyFilters(PropertyFilter... filters);
+
+    /**
+     * Adds the given PropertyFilter instances.
+     *
+     * @param filters the filters to add
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder addPropertyFilters(Collection<PropertyFilter> filters);
+
+    /**
+     * Removes the given PropertyFilter instances.
+     *
+     * @param filters the filters to remove
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder removePropertyFilters(PropertyFilter... filters);
+    /**
+     * Removes the given PropertyFilter instances.
+     *
+     * @param selector the selector query, not null.
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder removePropertyFilters(Predicate<PropertyFilter> selector);
+
+    /**
+     * Removes the given PropertyFilter instances.
+     *
+     * @param filters the filters to remove
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder removePropertyFilters(Collection<PropertyFilter> filters);
+
+    /**
+     * Remove the property sources selected by the given selector predicate.
+     *
+     * @param selector the selector query, not null.
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder removePropertySources(Predicate<PropertySource> selector);
+
+    /**
+     * This method can be used for programmatically adding {@link org.apache.tamaya.PropertyConverter}s.
+     * It is not needed for normal 'usage' by end users, but only for Extension Developers!
+     *
+     * @param typeToConvert     the type which the converter is for
+     * @param propertyConverter the PropertyConverters to add for this type
+     * @return this builder, for chaining, never null.
+     */
+    <T> ConfigurationContextBuilder addPropertyConverter(TypeLiteral<T> typeToConvert,
+                                                         PropertyConverter<T> propertyConverter);
+
+    /**
+     * Removes the given PropertyConverter instances.
+     *
+     * @param typeToConvert the type which the converter is for
+     * @param converters    the converters to remove
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert,
+                                                         PropertyConverter<?>... converters);
+
+    /**
+     * Removes the given PropertyConverter instances.
+     *
+     * @param typeToConvert the type which the converter is for
+     * @param converters    the converters to remove
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert,
+                                                         Collection<PropertyConverter<?>>
converters);
+
+    /**
+     * Sets the {@link PropertyValueCombinationPolicy} used to evaluate the final
+     * property values.
+     *
+     * @param policy the {@link PropertyValueCombinationPolicy} used, not null
+     * @return this builder, for chaining, never null.
+     */
+    ConfigurationContextBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy
policy);
+
+    /**
+     * Builds a {@link ConfigurationContext} based on the data set.
+     */
+    ConfigurationContext build();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0ce780da/java7/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
----------------------------------------------------------------------
diff --git a/java7/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java b/java7/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
index 3e96abd..bb87372 100644
--- a/java7/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
+++ b/java7/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
@@ -42,4 +42,33 @@ public interface ConfigurationProviderSpi {
      */
     ConfigurationContext getConfigurationContext();
 
+    /**
+     * This method allows to replace the current {@link org.apache.tamaya.spi.ConfigurationContext}
with a new
+     * instance. This can be used to update the context with a new one, e.g. because some
of the configuration
+     * data has changed and must be updated. It is the responsibility of the ConfigurationProvider
to trigger
+     * corresponding update event for the current {@link org.apache.tamaya.spi.ConfigurationContext}
or
+     * {@link org.apache.tamaya.Configuration}.
+     *
+     * @param context the new ConfigurationContext to be applied.
+     * @throws java.lang.UnsupportedOperationException if the current provider is read-only.
+     */
+    void setConfigurationContext(ConfigurationContext context);
+
+    /**
+     * Method that allows to determine if a new {@link org.apache.tamaya.spi.ConfigurationContext}
can be applied
+     * programmatically.
+     *
+     * @return true, if {@link #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)}
is supported
+     * by the current implementation.
+     * @see #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)
+     */
+    boolean isConfigurationContextSettable();
+
+    /**
+     * Creates a new {@link org.apache.tamaya.spi.ConfigurationContextBuilder} instance.
+     *
+     * @return a new {@link org.apache.tamaya.spi.ConfigurationContextBuilder}, never null.
+     */
+    ConfigurationContextBuilder getConfigurationContextBuilder();
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0ce780da/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
----------------------------------------------------------------------
diff --git a/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
b/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
index cc07d98..74f269a 100644
--- a/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
+++ b/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java
@@ -70,7 +70,13 @@ public class DefaultConfigurationContext implements ConfigurationContext
{
     /**
      * Lock for internal synchronization.
      */
-    private ReentrantReadWriteLock propertySourceLock = new ReentrantReadWriteLock();
+    private final ReentrantReadWriteLock propertySourceLock = new ReentrantReadWriteLock();
+
+    /** Comparator used for ordering property sources. */
+    private final PropertySourceComparator propertySourceComparator = new PropertySourceComparator();
+
+    /** Comparator used for ordering property filters. */
+    private final PropertyFilterComparator propertyFilterComparator = new PropertyFilterComparator();
 
 
     /**
@@ -92,12 +98,7 @@ public class DefaultConfigurationContext implements ConfigurationContext
{
 
         immutablePropertySources = Collections.unmodifiableList(propertySources);
         LOG.info("Registered " + immutablePropertySources.size() + " property sources: "
+
-                createStringList(immutablePropertySources, new Function<PropertySource,
String>() {
-                    @Override
-                    public String apply(PropertySource ps) {
-                        return ps.getName() + '[' + ps.getClass().getName()+']';
-                    }
-                }));
+                immutablePropertySources);
 
         // as next step we pick up the PropertyFilters pretty much the same way
         List<PropertyFilter> propertyFilters = new ArrayList<>();
@@ -105,22 +106,11 @@ public class DefaultConfigurationContext implements ConfigurationContext
{
         Collections.sort(propertyFilters, new PropertyFilterComparator());
         immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
         LOG.info("Registered " + immutablePropertyFilters.size() + " property filters: "
+
-                createStringList(immutablePropertyFilters, new Function<PropertyFilter,
String>() {
-                    @Override
-                    public String apply(PropertyFilter propertyFilter) {
-                        return propertyFilter.getClass().getName();
-                    }
-                }));
+                immutablePropertyFilters);
 
         immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
         LOG.info("Registered " + immutablePropertyFilters.size() + " property filters: "
+
-                createStringList(immutablePropertyFilters,new Function<PropertyFilter,
String>() {
-                    @Override
-                    public String apply(PropertyFilter propertyFilter) {
-                        return propertyFilter.getClass().getName();
-                    }
-                }));
-
+                immutablePropertyFilters);
         propertyValueCombinationPolicy = ServiceContextManager.getServiceContext().getService(PropertyValueCombinationPolicy.class);
         if(propertyValueCombinationPolicy==null) {
             propertyValueCombinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
@@ -128,6 +118,31 @@ public class DefaultConfigurationContext implements ConfigurationContext
{
         LOG.info("Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
     }
 
+    DefaultConfigurationContext(DefaultConfigurationContextBuilder builder) {
+        List<PropertySource> propertySources = new ArrayList<>();
+        // first we load all PropertySources which got registered via java.util.ServiceLoader
+        propertySources.addAll(builder.propertySources);
+        // now sort them according to their ordinal values
+        Collections.sort(propertySources, propertySourceComparator);
+        immutablePropertySources = Collections.unmodifiableList(propertySources);
+        LOG.info("Registered " + immutablePropertySources.size() + " property sources: "
+
+                immutablePropertySources);
+
+        // as next step we pick up the PropertyFilters pretty much the same way
+        List<PropertyFilter> propertyFilters = new ArrayList<>();
+        propertyFilters.addAll(ServiceContextManager.getServiceContext().getServices(PropertyFilter.class));
+        Collections.sort(propertyFilters, propertyFilterComparator);
+        immutablePropertyFilters = Collections.unmodifiableList(propertyFilters);
+        LOG.info("Registered " + immutablePropertyFilters.size() + " property filters: "
+
+                immutablePropertyFilters);
+
+        propertyValueCombinationPolicy = ServiceContextManager.getServiceContext().getService(PropertyValueCombinationPolicy.class);
+        if(propertyValueCombinationPolicy==null){
+            propertyValueCombinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
+        }
+        LOG.info("Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
+    }
+
     /**
      * Pick up all {@link org.apache.tamaya.spi.PropertySourceProvider}s and return all the
      * {@link org.apache.tamaya.spi.PropertySource}s they like to register.
@@ -138,13 +153,7 @@ public class DefaultConfigurationContext implements ConfigurationContext
{
         for (PropertySourceProvider propertySourceProvider : propertySourceProviders) {
             Collection<PropertySource> sources = propertySourceProvider.getPropertySources();
             LOG.finer("PropertySourceProvider " + propertySourceProvider.getClass().getName()
+
-                    " provided the following property sources: " +
-                    createStringList(sources,new Function<PropertySource, String>()
{
-                        @Override
-                        public String apply(PropertySource ps) {
-                            return ps.getName() + '[' + ps.getClass().getName()+']';
-                        }
-                    }));
+                    " provided the following property sources: " + sources);
                 propertySources.addAll(sources);
         }
 
@@ -256,16 +265,4 @@ public class DefaultConfigurationContext implements ConfigurationContext
{
         return propertyValueCombinationPolicy;
     }
 
-    private <T> String createStringList(Collection<T> items, Function<T,String>
mapper){
-        StringBuilder builder = new StringBuilder();
-        for(T t: items){
-            builder.append(mapper.apply(t));
-        }
-        return builder.toString();
-    }
-
-    private static interface Function<T,R>{
-        R apply(T t);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0ce780da/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
b/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
new file mode 100644
index 0000000..7b27c77
--- /dev/null
+++ b/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilder.java
@@ -0,0 +1,144 @@
+/*
+ * 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.core.internal;
+
+import org.apache.tamaya.PropertyConverter;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConfigurationContextBuilder;
+import org.apache.tamaya.spi.PropertyFilter;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Default implementation of {@link org.apache.tamaya.spi.ConfigurationContextBuilder}.
+ */
+class DefaultConfigurationContextBuilder implements ConfigurationContextBuilder {
+
+    List<PropertySource> propertySources = new ArrayList<>();
+    List<PropertyFilter> propertyFilters = new ArrayList<>();
+    Map<TypeLiteral<?>, List<PropertyConverter<?>>> propertyConverters
= new HashMap<>();
+    PropertyValueCombinationPolicy combinationPolicy;
+
+    DefaultConfigurationContextBuilder(){
+    }
+
+    @Override
+    public ConfigurationContextBuilder setContext(ConfigurationContext context) {
+        this.propertySources.clear();
+        this.propertySources.addAll(context.getPropertySources());
+        this.propertyFilters.clear();
+        this.propertyFilters.addAll(context.getPropertyFilters());
+        this.propertyConverters.clear();
+        this.propertyConverters.putAll(context.getPropertyConverters());
+        this.combinationPolicy = context.getPropertyValueCombinationPolicy();
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder addPropertySources(PropertySource... propertySourcesToAdd)
{
+        return addPropertySources(Arrays.asList(propertySourcesToAdd));
+    }
+
+    @Override
+    public ConfigurationContextBuilder addPropertySources(Collection<PropertySource>
propertySourcesToAdd) {
+        this.propertySources.addAll(propertySourcesToAdd);
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertySources(PropertySource... propertySourcesToRemove)
{
+        return removePropertySources(Arrays.asList(propertySourcesToRemove));
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertySources(Collection<PropertySource>
propertySourcesToRemove) {
+        this.propertySources.removeAll(propertySourcesToRemove);
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder addPropertyFilters(PropertyFilter... filters) {
+        return addPropertyFilters(Arrays.asList(filters));
+    }
+
+    @Override
+    public ConfigurationContextBuilder addPropertyFilters(Collection<PropertyFilter>
filters) {
+        this.propertyFilters.addAll(filters);
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertyFilters(PropertyFilter... filters) {
+        return removePropertyFilters(Arrays.asList(filters));
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertyFilters(Collection<PropertyFilter>
filters) {
+        this.propertyFilters.removeAll(filters);
+        return this;
+    }
+
+    @Override
+    public <T> ConfigurationContextBuilder addPropertyConverter(TypeLiteral<T>
typeToConvert,
+                                                                PropertyConverter<T>
propertyConverter) {
+        List<PropertyConverter<?>> converters = this.propertyConverters.get(typeToConvert);
+        if(converters==null){
+            converters = new ArrayList<>();
+            this.propertyConverters.putIfAbsent(typeToConvert, converters);
+            converters = this.propertyConverters.get(typeToConvert);
+        }
+        converters.add(propertyConverter);
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert,
PropertyConverter<?>... converters) {
+        return removePropertyConverters(typeToConvert, Arrays.asList(converters));
+    }
+
+    @Override
+    public ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert,
Collection<PropertyConverter<?>> converters) {
+        List<PropertyConverter<?>> existing = this.propertyConverters.get(typeToConvert);
+        if(existing!=null) {
+            existing.removeAll(converters);
+        }
+        return this;
+    }
+
+    @Override
+    public ConfigurationContextBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy
policy) {
+        this.combinationPolicy = Objects.requireNonNull(policy);
+        return this;
+    }
+
+    @Override
+    public ConfigurationContext build() {
+        return new DefaultConfigurationContext(this);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0ce780da/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
b/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
index c06755d..a0671f2 100644
--- a/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
+++ b/java7/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationProvider.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.core.internal;
 
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConfigurationContextBuilder;
 import org.apache.tamaya.spi.ConfigurationProviderSpi;
 
 /**
@@ -42,4 +43,17 @@ public class DefaultConfigurationProvider implements ConfigurationProviderSpi
{
         return context;
     }
 
+    @Override
+    public ConfigurationContextBuilder getConfigurationContextBuilder() {
+        return new DefaultConfigurationContextBuilder();
+    }
+
+    @Override
+    public void setConfigurationContext(ConfigurationContext context){
+        Configuration oldConfig = this.config;
+        Configuration newConfig = new DefaultConfiguration(context);
+        // TODO think on a SPI or move event part into API...
+        this.config = newConfig;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0ce780da/java7/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
----------------------------------------------------------------------
diff --git a/java7/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
b/java7/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
index a2c61a8..26ad140 100644
--- a/java7/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
+++ b/java7/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
@@ -34,7 +34,7 @@ public class ConverterTestsPropertySource implements PropertySource{
 
     @Override
     public String getName(){
-        return getClass().getName();
+        return "ConverterTestsPropertySource";
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0ce780da/java8/api/src/main/java/org/apache/tamaya/TypeLiteral.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/TypeLiteral.java b/java8/api/src/main/java/org/apache/tamaya/TypeLiteral.java
index 6a962d2..6edbb68 100644
--- a/java8/api/src/main/java/org/apache/tamaya/TypeLiteral.java
+++ b/java8/api/src/main/java/org/apache/tamaya/TypeLiteral.java
@@ -103,14 +103,7 @@ public class TypeLiteral<T> implements Serializable {
      * @return the generic type parameter of the given single type generic interfaceType,
or null.
      */
     public static Type getTypeParameter(Class<?> clazz, Class<?> interfaceType)
{
-        Type type = clazz;
-        if (type instanceof ParameterizedType) {
-            ParameterizedType parameterizedType = (ParameterizedType) type;
-            if (parameterizedType.getActualTypeArguments().length == 1) {
-                return parameterizedType.getActualTypeArguments()[0];
-            }
-        }
-        type = clazz.getGenericSuperclass();
+        Type type = clazz.getGenericSuperclass();
         if (type instanceof ParameterizedType) {
             if(interfaceType == null ||type.equals(interfaceType)){
                 ParameterizedType parameterizedType = (ParameterizedType) type;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0ce780da/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
index 812eb8c..32d0b93 100644
--- a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
+++ b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
@@ -33,6 +33,11 @@ public class ConverterTestsPropertySource implements PropertySource{
     }
 
     @Override
+    public String getName() {
+        return "ConverterTestsPropertySource";
+    }
+
+    @Override
     public String get(String key) {
         switch(key){
             // Bytes


Mime
View raw message