You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2014/12/01 10:43:51 UTC
[8/8] incubator-tamaya git commit: TAMAYA-14: added resource support.
TAMAYA-15: Moved PropertyProviders to API,
added SPI. TAMAYA-8: Added/improved Javadoc.
TAMAYA-14: added resource support.
TAMAYA-15: Moved PropertyProviders to API, added SPI.
TAMAYA-8: Added/improved Javadoc.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/a55d1c97
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/a55d1c97
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/a55d1c97
Branch: refs/heads/master
Commit: a55d1c973f66068cfd93a671c85001a95343cde6
Parents: bed1057
Author: anatole <an...@apache.org>
Authored: Mon Dec 1 10:43:33 2014 +0100
Committer: anatole <an...@apache.org>
Committed: Mon Dec 1 10:43:34 2014 +0100
----------------------------------------------------------------------
NOTICE | 1 +
.../org/apache/tamaya/AggregationPolicy.java | 38 +
.../apache/tamaya/ConfigChangeSetBuilder.java | 4 +-
.../java/org/apache/tamaya/ConfigFunctions.java | 107 ++
.../java/org/apache/tamaya/ConfigOperator.java | 2 +-
.../java/org/apache/tamaya/ConfigQuery.java | 2 +-
.../java/org/apache/tamaya/Configuration.java | 38 +-
.../org/apache/tamaya/ConfigurationManager.java | 11 +-
.../main/java/org/apache/tamaya/MetaInfo.java | 2 +-
.../java/org/apache/tamaya/PropertyAdapter.java | 2 +-
.../org/apache/tamaya/PropertyAdapters.java | 2 +-
.../org/apache/tamaya/PropertyProvider.java | 34 +-
.../org/apache/tamaya/PropertyProviders.java | 535 ++++++++
api/src/main/java/org/apache/tamaya/Stages.java | 2 +-
.../apache/tamaya/annot/ConfiguredProperty.java | 2 +-
.../spi/ConfigurationManagerSingletonSpi.java | 3 +
.../spi/PropertyProvidersSingletonSpi.java | 198 +++
.../core/config/ConfigurationBuilder.java | 11 +-
.../core/config/ConfigurationFormats.java | 10 +-
.../config/EnvPropertiesConfigProvider.java | 7 +-
.../core/config/FreezedConfiguration.java | 10 +-
.../config/SystemPropertiesConfigProvider.java | 7 +-
.../internal/AggregatedPropertyProvider.java | 137 ++
.../internal/ContextualPropertyProvider.java | 174 +++
.../core/internal/DefaultConfigProvider.java | 4 +-
.../DefaultPropertyProvidersSingletonSpi.java | 286 ++++
.../internal/DelegatingPropertyProvider.java | 103 ++
.../internal/EnvironmentPropertyProvider.java | 45 +
.../core/internal/FilteredPropertyProvider.java | 72 +
.../core/internal/FreezedPropertyProvider.java | 98 ++
.../internal/IntersectingPropertyProvider.java | 77 ++
.../core/internal/MapBasedPropertyProvider.java | 107 ++
.../apache/tamaya/core/internal/MetaConfig.java | 4 +-
.../internal/PathBasedPropertyProvider.java | 93 ++
.../internal/ReplacingPropertyProvider.java | 111 ++
.../internal/SubtractingPropertyProvider.java | 76 ++
.../SystemPropertiesPropertyProvider.java | 53 +
.../core/internal/UriBasedPropertyProvider.java | 92 ++
...DependentApplicationEnvironmentProvider.java | 2 +-
...ssLoaderDependentEarEnvironmentProvider.java | 2 +-
.../SystemClassLoaderEnvironmentProvider.java | 4 +-
.../tamaya/core/internal/format/IniFormat.java | 1 +
.../core/internal/inject/ConfiguredField.java | 4 +-
.../inject/ConfiguredInstancesManager.java | 2 +-
.../core/internal/inject/ConfiguredMethod.java | 2 +-
.../core/internal/logging/Slf4jLogger.java | 2 +-
.../resources/AntPathClasspathResolver.java | 37 +-
.../resources/AntPathClasspathsResolver.java | 59 +-
.../internal/resources/AntPathFileResolver.java | 22 +-
.../resources/AntPathFilesResolver.java | 22 +-
.../io/AbstractFileResolvingResource.java | 219 ++++
.../internal/resources/io/AbstractResource.java | 215 +++
.../internal/resources/io/AntPathMatcher.java | 777 +++++++++++
.../resources/io/ClassPathResource.java | 250 ++++
.../core/internal/resources/io/ClassUtils.java | 1232 ++++++++++++++++++
.../resources/io/DefaultResourceLoader.java | 136 ++
.../resources/io/FileSystemResource.java | 218 ++++
.../resources/io/InputStreamResource.java | 123 ++
.../resources/io/InputStreamSource.java | 55 +
.../io/PathMatchingResourcePatternResolver.java | 728 +++++++++++
.../internal/resources/io/ReflectionUtils.java | 191 +++
.../core/internal/resources/io/Resource.java | 135 ++
.../internal/resources/io/ResourceUtils.java | 350 +++++
.../core/internal/resources/io/StringUtils.java | 1173 +++++++++++++++++
.../core/internal/resources/io/UrlResource.java | 261 ++++
.../core/internal/resources/io/VfsResource.java | 132 ++
.../core/internal/resources/io/VfsUtils.java | 209 +++
.../internal/resources/io/WritableResource.java | 52 +
.../properties/AbstractPropertyProvider.java | 2 +-
.../properties/AggregatedPropertyProvider.java | 137 --
.../core/properties/AggregationPolicy.java | 38 -
.../properties/ContextualPropertyProvider.java | 176 ---
.../properties/DelegatingPropertyProvider.java | 103 --
.../properties/EnvironmentPropertyProvider.java | 43 -
.../properties/FilteredPropertyProvider.java | 71 -
.../properties/FreezedPropertyProvider.java | 94 --
.../IntersectingPropertyProvider.java | 76 --
.../properties/MapBasedPropertyProvider.java | 106 --
.../MapBasedPropertyProviderBuilder.java | 8 +-
.../properties/PathBasedPropertyProvider.java | 74 --
.../properties/PropertyProviderManager.java | 2 +-
.../core/properties/PropertyProviders.java | 457 -------
.../properties/ReplacingPropertyProvider.java | 111 --
.../apache/tamaya/core/properties/Store.java | 2 +-
.../properties/SubtractingPropertyProvider.java | 75 --
.../SystemPropertiesPropertyProvider.java | 52 -
.../properties/UriBasedPropertyProvider.java | 68 -
.../tamaya/core/spi/ConfigurationFormat.java | 2 +-
.../tamaya/core/spi/EnvironmentProvider.java | 2 +-
.../tamaya/core/spi/ExpressionResolver.java | 2 +-
.../apache/tamaya/core/spi/ResourceLoader.java | 2 +-
...che.tamaya.spi.PropertyProvidersSingletonSpi | 19 +
...tionManagerSingletonSpiSingletonSpiTest.java | 14 +-
.../java/org/apache/tamaya/JavaOneDemo.java | 5 +-
.../core/properties/PropertyProvidersTest.java | 1 +
.../internal/MutableTestConfigProvider.java | 4 +-
.../simple/SimplePropertiesAndCLISample.java | 8 +-
.../UC1ReadPropertiesTest.java | 218 ++++
.../UC1ReadProperties/UC1ReadPropertiesTest.ini | 23 +
.../UC1ReadPropertiesTest.properties | 16 +
.../UC1ReadProperties/UC1ReadPropertiesTest.xml | 25 +
docs/design/0_UseCases.adoc | 223 ++--
.../apache/tamaya/management/ManagedConfig.java | 2 +-
.../tamaya/management/ManagedConfigMBean.java | 2 +-
104 files changed, 9536 insertions(+), 1902 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index 1be4b73..716885f 100644
--- a/NOTICE
+++ b/NOTICE
@@ -9,3 +9,4 @@ Juven Xu (juvenshun at gmail dot com)
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
+The Spring Framework (http://spring.io/projects).
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/AggregationPolicy.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/AggregationPolicy.java b/api/src/main/java/org/apache/tamaya/AggregationPolicy.java
new file mode 100644
index 0000000..1b02a6c
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/AggregationPolicy.java
@@ -0,0 +1,38 @@
+/*
+ * 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;
+
+/**
+ * Policy that defines how the different aggregates should be combined.
+ */
+public enum AggregationPolicy{
+ /** Ignore overrides, only extend (additive). */
+ IGNORE,
+ /**
+ * Interpret later keys as override (additive and override), replacing
+ * the key loaded earlier/fromMap previous contained
+ * {@link org.apache.tamaya.PropertyProvider}.
+ */
+ OVERRIDE,
+ /**
+ * Throw an exception, when keys are not disjunctive (strictly
+ * additive).
+ */
+ EXCEPTION
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/ConfigChangeSetBuilder.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/ConfigChangeSetBuilder.java b/api/src/main/java/org/apache/tamaya/ConfigChangeSetBuilder.java
index be6b906..8f21228 100644
--- a/api/src/main/java/org/apache/tamaya/ConfigChangeSetBuilder.java
+++ b/api/src/main/java/org/apache/tamaya/ConfigChangeSetBuilder.java
@@ -113,7 +113,7 @@ public final class ConfigChangeSetBuilder {
}
/**
- * Marks the given key(s) from the configuration/properties to be removed.
+ * Marks the given key(s) fromMap the configuration/properties to be removed.
* @param key the key of the entry, not null.
* @param otherKeys additional keys to be removed (convenience), not null.
* @return the builder for chaining.
@@ -256,7 +256,7 @@ public final class ConfigChangeSetBuilder {
}
/**
- * This method will create a change set that clears all entries from the given base configuration/properties.
+ * This method will create a change set that clears all entries fromMap the given base configuration/properties.
* @return the builder for chaining.
*/
public ConfigChangeSetBuilder clear() {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/ConfigFunctions.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/ConfigFunctions.java b/api/src/main/java/org/apache/tamaya/ConfigFunctions.java
new file mode 100644
index 0000000..a466b63
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/ConfigFunctions.java
@@ -0,0 +1,107 @@
+/*
+ * 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;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * Accessor that provides useful functions along with configuration.
+ */
+public final class ConfigFunctions {
+ /**
+ * Private singleton constructor.
+ */
+ private ConfigFunctions(){}
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (non recursive). Hereby
+ * the area key is stripped away fromMap the resulting key.
+ * @param areaKey the area key, not null
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static ConfigOperator selectArea(String areaKey) {
+ return selectArea(areaKey, true);
+ }
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (non recursive).
+ * @param areaKey the area key, not null
+ * @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static ConfigOperator selectArea(String areaKey, boolean stripKeys){
+ return config -> {
+ Map<String, String> area = new HashMap<>();
+ area.putAll(
+ config.toMap().entrySet().stream()
+ .filter(e -> isKeyInArea(e.getKey(), areaKey))
+ .collect(Collectors.toMap(
+ e -> stripKeys? e.getKey().substring(areaKey.length()+1) : e.getKey(),
+ e -> e.getValue())));
+ return PropertyProviders.fromMap(area).toConfiguration();
+ };
+ }
+
+ /**
+ * Calculates the current area key and compares it with the given key.
+ * @param key the fully qualified entry key, not null
+ * @param areaKey the area key, not null
+ * @return true, if the entry is exact in this area
+ */
+ public static boolean isKeyInArea(String key, String areaKey){
+ int lastIndex = key.lastIndexOf('.');
+ String curAreaKey = lastIndex > 0 ? key.substring(0, lastIndex) : "";
+ return curAreaKey.equals(areaKey);
+ }
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (recursive). Hereby
+ * the area key is stripped away fromMap the resulting key.
+ * @param areaKey the area key, not null
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static ConfigOperator selectAreaRecursive(String areaKey) {
+ return selectAreaRecursive(areaKey, true);
+ }
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (recursive).
+ * @param areaKey the area key, not null
+ * @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static ConfigOperator selectAreaRecursive(String areaKey, boolean stripKeys){
+ return config -> {
+ Map<String, String> area = new HashMap<>();
+ String lookupKey = areaKey + '.';
+ area.putAll(
+ config.toMap().entrySet().stream()
+ .filter(e -> e.getKey().startsWith(lookupKey))
+ .collect(Collectors.toMap(
+ e -> stripKeys? e.getKey().substring(areaKey.length()+1) : e.getKey(),
+ e -> e.getValue())));
+ return PropertyProviders.fromMap(area).toConfiguration();
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/ConfigOperator.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/ConfigOperator.java b/api/src/main/java/org/apache/tamaya/ConfigOperator.java
index a59712b..b76fa31 100644
--- a/api/src/main/java/org/apache/tamaya/ConfigOperator.java
+++ b/api/src/main/java/org/apache/tamaya/ConfigOperator.java
@@ -27,7 +27,7 @@ package org.apache.tamaya;
public interface ConfigOperator{
/**
- * Method that creates a Configuration from another Configuration. This can be used for implementing
+ * Method that creates a Configuration fromMap another Configuration. This can be used for implementing
* views, security constraints or for overriding/inheriting of configuration.
* @param config The target configuration to be operated, never nnull.
* @return the operated configuration, never null.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/ConfigQuery.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/ConfigQuery.java b/api/src/main/java/org/apache/tamaya/ConfigQuery.java
index c296d12..58d8742 100644
--- a/api/src/main/java/org/apache/tamaya/ConfigQuery.java
+++ b/api/src/main/java/org/apache/tamaya/ConfigQuery.java
@@ -21,7 +21,7 @@ package org.apache.tamaya;
/**
* Interface for an query that converts a Configuration into another object. One typical
- * use cases would creating a complex configuration parameter type from a Configuration instance or
+ * use cases would creating a complex configuration parameter type fromMap a Configuration instance or
* constraint views on configuration.
*/
@FunctionalInterface
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/Configuration.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/Configuration.java b/api/src/main/java/org/apache/tamaya/Configuration.java
index a23f44c..7d5500c 100644
--- a/api/src/main/java/org/apache/tamaya/Configuration.java
+++ b/api/src/main/java/org/apache/tamaya/Configuration.java
@@ -118,12 +118,12 @@ public interface Configuration extends PropertyProvider{
* If {@code Class<T>} is not one of
* {@code Boolean, Short, Integer, Long, Float, Double, BigInteger,
* BigDecimal, String} , an according adapter must be
- * available to perform the conversion from {@link String} to
+ * available to perform the conversion fromMap {@link String} to
* {@code Class<T>}.
*
* @param key the property's absolute, or relative path, e.g. @code
* a/b/c/d.myProperty}.
- * @param adapter the PropertyAdapter to perform the conversion from
+ * @param adapter the PropertyAdapter to perform the conversion fromMap
* {@link String} to {@code Class<T>}, not {@code null}.
* @return the property's value.
* @throws IllegalArgumentException if the value could not be converted to the required target
@@ -141,7 +141,7 @@ public interface Configuration extends PropertyProvider{
/**
* Get the property value as type T. This will implicitly require a corresponding {@link
* PropertyAdapter} to be available that is capable of providing type T
- * from the given String value.
+ * fromMap the given String value.
*
* @param key the property's absolute, or relative path, e.g. @code
* a/b/c/d.myProperty}.
@@ -150,7 +150,9 @@ public interface Configuration extends PropertyProvider{
* @throws IllegalArgumentException if the value could not be converted to the required target
* type.
*/
- <T> Optional<T> get(String key, Class<T> type);
+ default <T> Optional<T> get(String key, Class<T> type){
+ return getAdapted(key, PropertyAdapters.getAdapter(type));
+ }
/**
* Return a set with all fully qualifies area names.
@@ -219,11 +221,11 @@ public interface Configuration extends PropertyProvider{
/**
* Allows to evaluate if an area exists.
*
- * @param key the configuration area (sub)path.
+ * @param areaKey the configuration area (sub)path.
* @return {@code true}, if such a node exists.
*/
- default boolean containsArea(String key){
- return getAreas().contains(key);
+ default boolean containsArea(String areaKey){
+ return getAreas().contains(areaKey);
}
/**
@@ -238,7 +240,7 @@ public interface Configuration extends PropertyProvider{
}
/**
- * Query some value from a configuration.
+ * Query some value fromMap a configuration.
*
* @param query the query, never {@code null}.
* @return the result
@@ -259,13 +261,21 @@ public interface Configuration extends PropertyProvider{
* Add a ConfigChangeListener to this configuration instance.
* @param l the listener, not null.
*/
- void addPropertyChangeListener(PropertyChangeListener l);
+ default void addPropertyChangeListener(PropertyChangeListener l){
+ addConfigChangeListener((p) -> {
+ if (p.getSource() == this) l.propertyChange(p);
+ });
+ }
/**
* Removes a ConfigChangeListener to this configuration instance.
* @param l the listener, not null.
*/
- void removePropertyChangeListener(PropertyChangeListener l);
+ default void removePropertyChangeListener(PropertyChangeListener l){
+ removeConfigChangeListener((p) -> {
+ if (p.getSource() == this) l.propertyChange(p);
+ });
+ }
/**
* Allows to check if a configuration with a given name is defined.
@@ -361,8 +371,8 @@ public interface Configuration extends PropertyProvider{
* Adds a (global) {@link java.beans.PropertyChangeListener} instance that listens to all kind of config changes.
* @param listener the {@link java.beans.PropertyChangeListener} instance to be added, not null.
*/
- public static void addGlobalPropertyChangeListener(PropertyChangeListener listener){
- ConfigurationManager.addPropertyChangeListener(listener);
+ public static void addConfigChangeListener(PropertyChangeListener listener){
+ ConfigurationManager.addConfigChangeListener(listener);
}
/**
@@ -370,7 +380,7 @@ public interface Configuration extends PropertyProvider{
* if one is currently registered.
* @param listener the {@link java.beans.PropertyChangeListener} instance to be removed, not null.
*/
- public static void removeGlobalPropertyChangeListener(PropertyChangeListener listener){
- ConfigurationManager.removePropertyChangeListener(listener);
+ public static void removeConfigChangeListener(PropertyChangeListener listener){
+ ConfigurationManager.removeConfigChangeListener(listener);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/ConfigurationManager.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/ConfigurationManager.java b/api/src/main/java/org/apache/tamaya/ConfigurationManager.java
index 67d4ccb..62cd984 100644
--- a/api/src/main/java/org/apache/tamaya/ConfigurationManager.java
+++ b/api/src/main/java/org/apache/tamaya/ConfigurationManager.java
@@ -22,7 +22,9 @@ import org.apache.tamaya.spi.Bootstrap;
import org.apache.tamaya.spi.ConfigurationManagerSingletonSpi;
import java.beans.PropertyChangeListener;
-import java.util.Optional;
+import java.util.*;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
/**
* Singleton accessor for accessing {@link Configuration} instances and
@@ -41,7 +43,7 @@ final class ConfigurationManager{
}
/**
- * Method to initially load the singleton SPI from the {@link org.apache.tamaya.spi.Bootstrap} mechanism.
+ * Method to initially load the singleton SPI fromMap the {@link org.apache.tamaya.spi.Bootstrap} mechanism.
* The instance loaded will be used until the VM is shutdown. In case use cases require more flexibility
* it should be transparently implemented in the SPI implementation. This singleton will simply delegate calls
* and not cache any responses.
@@ -146,7 +148,7 @@ final class ConfigurationManager{
* Adds a (global) {@link java.beans.PropertyChangeListener} instance that listens to all kind of config changes.
* @param listener the {@link java.beans.PropertyChangeListener} instance to be added, not null.
*/
- public static void addPropertyChangeListener(PropertyChangeListener listener){
+ public static void addConfigChangeListener(PropertyChangeListener listener){
Optional.of(configManagerSingletonSpi).get().addPropertyChangeListener(listener);
}
@@ -155,7 +157,8 @@ final class ConfigurationManager{
* if one is currently registered.
* @param listener the {@link java.beans.PropertyChangeListener} instance to be removed, not null.
*/
- public static void removePropertyChangeListener(PropertyChangeListener listener){
+ public static void removeConfigChangeListener(PropertyChangeListener listener){
Optional.of(configManagerSingletonSpi).get().removePropertyChangeListener(listener);
}
+
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/MetaInfo.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/MetaInfo.java b/api/src/main/java/org/apache/tamaya/MetaInfo.java
index 3d20723..702d4be 100644
--- a/api/src/main/java/org/apache/tamaya/MetaInfo.java
+++ b/api/src/main/java/org/apache/tamaya/MetaInfo.java
@@ -31,7 +31,7 @@ public final class MetaInfo{
private final Map<String, String> metaInfo = new HashMap<>();
/**
- * Constructor, used from the builder.
+ * Constructor, used fromMap the builder.
* @param builder the builder, not null.
*/
MetaInfo(MetaInfoBuilder builder){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyAdapter.java b/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
index 8a238b4..96d1426 100644
--- a/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
+++ b/api/src/main/java/org/apache/tamaya/PropertyAdapter.java
@@ -21,7 +21,7 @@ package org.apache.tamaya;
/**
* Interface for an adapter that converts a configured String into something else.
- * This is typically used for implementing type conversion from String to a certain target
+ * This is typically used for implementing type conversion fromMap String to a certain target
* type of the configured property.
*/
@FunctionalInterface
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyAdapters.java b/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
index d967e3f..1934591 100644
--- a/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
+++ b/api/src/main/java/org/apache/tamaya/PropertyAdapters.java
@@ -32,7 +32,7 @@ public final class PropertyAdapters{
private static final PropertyAdaptersSingletonSpi propertyAdaptersSingletonSpi = loadConfigAdapterProviderSpi();
/**
- * Method that loads the singleton backing bean from the {@link org.apache.tamaya.spi.Bootstrap} component.
+ * Method that loads the singleton backing bean fromMap the {@link org.apache.tamaya.spi.Bootstrap} component.
* @return the PropertyAdaptersSingletonSpi, never null.
*/
private static PropertyAdaptersSingletonSpi loadConfigAdapterProviderSpi(){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/PropertyProvider.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyProvider.java b/api/src/main/java/org/apache/tamaya/PropertyProvider.java
index faf263e..44032c9 100644
--- a/api/src/main/java/org/apache/tamaya/PropertyProvider.java
+++ b/api/src/main/java/org/apache/tamaya/PropertyProvider.java
@@ -24,7 +24,7 @@ import java.util.Set;
/**
* This interface models a provider that serves configuration properties. The contained
- * properties may be read from single or several sources (composite).<br/>
+ * properties may be read fromMap single or several sources (composite).<br/>
* Property providers are the building blocks out of which complex
* configuration is setup.
* <p/>
@@ -114,4 +114,36 @@ public interface PropertyProvider {
throw new UnsupportedOperationException("Config/properties not mutable: "+ this);
}
+ /**
+ * Allows to quickly check, if a provider is empty.
+ * @return true, if the provier is empty.
+ */
+ default boolean isEmpty(){
+ return keySet().isEmpty();
+ }
+
+ /**
+ * Convert the this PropertyProvider instance to a {@link org.apache.tamaya.Configuration}.
+ * @return the configuration, never null.
+ */
+ default Configuration toConfiguration(){
+ return new Configuration(){
+ @Override
+ public Optional<String> get(String key) {
+ return PropertyProvider.this.get(key);
+ }
+ @Override
+ public boolean containsKey(String key) {
+ return PropertyProvider.this.containsKey(key);
+ }
+ @Override
+ public Map<String, String> toMap() {
+ return PropertyProvider.this.toMap();
+ }
+ @Override
+ public MetaInfo getMetaInfo() {
+ return PropertyProvider.this.getMetaInfo();
+ }
+ };
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/PropertyProviders.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyProviders.java b/api/src/main/java/org/apache/tamaya/PropertyProviders.java
new file mode 100644
index 0000000..5a9aebd
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/PropertyProviders.java
@@ -0,0 +1,535 @@
+/*
+ * 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;
+
+import org.apache.tamaya.spi.Bootstrap;
+import org.apache.tamaya.spi.PropertyProvidersSingletonSpi;
+
+import java.net.URI;
+import java.util.*;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+import java.util.logging.Logger;
+
+/**
+ * Accessor factory for several standard {@link PropertyProvider} instances, usable for creating {@code Configuration}
+ * parts.
+ */
+public final class PropertyProviders {
+
+ private static final PropertyProvidersSingletonSpi spi = loadPropertyProvidersSingletonSpi();
+
+ private static final Logger LOG = Logger.getLogger(PropertyProviders.class.getName());
+
+ /**
+ * Private singleton constructor.
+ */
+ private PropertyProviders() {
+ }
+
+ /**
+ * Method to initially load the singleton SPI fromMap the {@link org.apache.tamaya.spi.Bootstrap} mechanism.
+ * The instance loaded will be used until the VM is shutdown. In case use cases require more flexibility
+ * it should be transparently implemented in the SPI implementation. This singleton will simply delegate calls
+ * and not cache any responses.
+ *
+ * @return the SPI, never null.
+ */
+ private static PropertyProvidersSingletonSpi loadPropertyProvidersSingletonSpi() {
+ return Bootstrap.getService(PropertyProvidersSingletonSpi.class);
+ }
+
+ /**
+ * Creates a new {@link }PropertyMap} using the given command line arguments
+ *
+ * @param args the command line arguments, not null.
+ * @return a new {@link }PropertyMap} instance with the given arguments contained as properties.
+ */
+ public static PropertyProvider fromArgs(String... args) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromArgs(null, args);
+ }
+
+ /**
+ * Creates a new {@link }PropertyMap} using the given command line arguments
+ *
+ * @param metaInfo the meta information to be provided additionally.
+ * @param args the command line arguments, not null.
+ * @return a new {@link }PropertyMap} instance with the given arguments contained as properties.
+ */
+ public static PropertyProvider fromArgs(MetaInfo metaInfo, String... args) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromArgs(metaInfo, args);
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} by reading the according path resources. The effective resources read
+ * hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * Properties read fromMap resources evaluated on
+ * paths with lower order are overriding any duplicate values fromMap previous paths hereby.
+ *
+ * @param aggregationPolicy the aggregationPolicy to be used, not null.
+ * @param paths the paths to be resolved by the {@code PathResolverService} , not null.
+ * @return a new {@link }PropertyMap} instance with the given paths contained as properties.
+ */
+ public static PropertyProvider fromPaths(AggregationPolicy aggregationPolicy, String... paths) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromPaths(aggregationPolicy, null, Arrays.asList(paths));
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} by reading the according path resources. The effective resources read
+ * hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * Properties read fromMap resources evaluated on
+ * paths with lower order are overriding any duplicate values fromMap previous paths hereby.
+ *
+ * @param paths the paths to be resolved by the {@code PathResolverService} , not null.
+ * @return a new {@link }PropertyMap} instance with the given paths contained as properties.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider fromPaths(String... paths) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromPaths(AggregationPolicy.EXCEPTION, null, Arrays.asList(paths));
+ }
+
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} by reading the according path resources. The effective resources read
+ * hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * Properties read fromMap resources evaluated on
+ * paths with lower order are overriding any duplicate values fromMap previous paths hereby.
+ *
+ * @param paths the paths to be resolved by the {@code PathResolverService} , not null.
+ * @return a new {@link }PropertyMap} instance with the given paths contained as properties.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider fromPaths(List<String> paths) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromPaths(AggregationPolicy.EXCEPTION, null, paths);
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} by reading the according path resources. The effective resources read
+ * hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * Properties read fromMap resources evaluated on
+ * paths with lower order are overriding any duplicate values fromMap previous paths hereby.
+ *
+ * @param aggregationPolicy the aggregationPolicy to be used, not null.
+ * @param paths the paths to be resolved by the {@code PathResolverService} , not null.
+ * @return a new {@link }PropertyMap} instance with the given paths contained as properties.
+ */
+ public static PropertyProvider fromPaths(AggregationPolicy aggregationPolicy, List<String> paths) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromPaths(aggregationPolicy, null, paths);
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} by reading the according path resources. The effective resources read
+ * hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * Properties read fromMap resources evaluated on
+ * paths with lower order are overriding any duplicate values fromMap previous paths hereby.
+ *
+ * @param metaInfo the meat information to be provided additionally.
+ * @param paths the paths to be resolved by the {@code PathResolverService} , not null.
+ * @return a new {@link }PropertyMap} instance with the given paths contained as properties.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider fromPaths(MetaInfo metaInfo, List<String> paths) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromPaths(AggregationPolicy.EXCEPTION, metaInfo, paths);
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} by reading the according path resources. The effective resources read
+ * hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * Properties read fromMap resources evaluated on
+ * paths with lower order are overriding any duplicate values fromMap previous paths hereby.
+ * @param aggregationPolicy the aggregationPolicy to be used, not null.
+ * @param metaInfo the meat information to be provided additionally.
+ * @param paths the paths to be resolved by the {@code PathResolverService} , not null.
+ * @return a new {@link }PropertyMap} instance with the given paths contained as properties.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider fromPaths(AggregationPolicy aggregationPolicy, MetaInfo metaInfo, List<String> paths) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromPaths(aggregationPolicy, metaInfo, paths);
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} based on the resources defined by the given paths. The effective resources
+ * read hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ *
+ * @param uris the uris to be read, not null.
+ * @return a new {@link }PropertyMap} instance based on the given paths/resources found.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider fromUris(URI... uris) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromUris(AggregationPolicy.EXCEPTION, null, Arrays.asList(uris));
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} based on the resources defined by the given paths. The effective resources
+ * read hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * @param aggregationPolicy the aggregationPolicy to be used, not null.
+ * @param uris the uris to be read, not null.
+ * @return a new {@link }PropertyMap} instance based on the given paths/resources found.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider fromUris(AggregationPolicy aggregationPolicy, URI... uris) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromUris(aggregationPolicy, null, Arrays.asList(uris));
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} based on the resources defined by the given paths. The effective resources
+ * read hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ *
+ * @param uris the uris to be read, not null.
+ * @return a new {@link }PropertyMap} instance based on the given paths/resources found.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider fromUris(List<URI> uris) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromUris(AggregationPolicy.EXCEPTION, null, uris);
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} based on the resources defined by the given paths. The effective resources
+ * read hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * @param aggregationPolicy the aggregationPolicy to be used, not null.
+ * @param uris the uris to be read, not null.
+ * @return a new {@link }PropertyMap} instance based on the given paths/resources found.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider fromUris(AggregationPolicy aggregationPolicy, List<URI> uris) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromUris(aggregationPolicy, null, uris);
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} based on the resources defined by the given paths. The effective resources
+ * read hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ *
+ * @param metaInfo the meat information to be provided additionally.
+ * @param uris the uris to be read, not null.
+ * @return a new {@link }PropertyMap} instance based on the given paths/resources found.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider fromUris(MetaInfo metaInfo, URI... uris) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromUris(AggregationPolicy.EXCEPTION, metaInfo, Arrays.asList(uris));
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} based on the resources defined by the given paths. The effective resources
+ * read hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * @param aggregationPolicy the aggregationPolicy to be used, not null.
+ * @param metaInfo the meat information to be provided additionally.
+ * @param uris the uris to be read, not null.
+ * @return a new {@link }PropertyMap} instance based on the given paths/resources found.
+ */
+ public static PropertyProvider fromUris(AggregationPolicy aggregationPolicy, MetaInfo metaInfo, URI... uris) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromUris(aggregationPolicy, metaInfo, Arrays.asList(uris));
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} based on the resources defined by the given paths. The effective resources
+ * read hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ *
+ * @param metaInfo the meat information to be provided additionally.
+ * @param uris the uris to be read, not null.
+ * @return a new {@link }PropertyMap} instance based on the given paths/resources found.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider fromUris(MetaInfo metaInfo, List<URI> uris) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromUris(AggregationPolicy.EXCEPTION, metaInfo, uris);
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} based on the resources defined by the given paths. The effective resources
+ * read hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * @param aggregationPolicy the aggregationPolicy to be used, not null.
+ * @param metaInfo the meat information to be provided additionally.
+ * @param uris the uris to be read, not null.
+ * @return a new {@link }PropertyMap} instance based on the given paths/resources found.
+ */
+ public static PropertyProvider fromUris(AggregationPolicy aggregationPolicy, MetaInfo metaInfo, List<URI> uris) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromUris(aggregationPolicy, metaInfo, uris);
+ }
+
+ /**
+ * Creates a new read-only {@link org.apache.tamaya.PropertyProvider} by using the given Map.
+ *
+ * @param map the properties to be included, not null.
+ * @return a new {@link }PropertyMap} instance with the given properties fromMap the Map instance passed.
+ */
+ public static PropertyProvider fromMap(Map<String, String> map) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromMap(null, map);
+ }
+
+
+ /**
+ * Creates a new read-only {@link org.apache.tamaya.PropertyProvider} by using the given Map.
+ *
+ * @param metaInfo the meat information to be provided additionally.
+ * @param map the properties to be included, not null.
+ * @return a new {@link }PropertyMap} instance with the given properties fromMap the Map instance passed.
+ */
+ public static PropertyProvider fromMap(MetaInfo metaInfo, Map<String, String> map) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromMap(metaInfo, map);
+ }
+
+ /**
+ * Get an empty and immutable PropertyProvider instance.
+ *
+ * @return an empty and immutable PropertyProvider instance, never null.
+ */
+ public static PropertyProvider empty() {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .empty(null);
+ }
+
+ /**
+ * Get an empty and immutable PropertyProvider instance.
+ *
+ * @return an empty and mutable PropertyProvider instance, never null.
+ */
+ public static PropertyProvider emptyMutable() {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .emptyMutable(null);
+ }
+
+ /**
+ * Get an empty and immutable PropertyProvider instance. The meta-information contains the given String
+ * under the key 'info'.
+ *
+ * @return an empty and immutable PropertyProvider instance, never null, with the given Strings as info meta-data..
+ */
+ public static PropertyProvider empty(MetaInfo metaInfo) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .empty(metaInfo);
+ }
+
+ /**
+ * Get an empty and mutable PropertyProvider instance. The meta-information contains the given String
+ * under the key 'info'.
+ *
+ * @return an empty and immutable PropertyProvider instance, never null, with the given Strings as info meta-data..
+ */
+ public static PropertyProvider emptyMutable(MetaInfo metaInfo) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .emptyMutable(metaInfo);
+ }
+
+ /**
+ * Returns a read-only {@link org.apache.tamaya.PropertyProvider} reflecting the current runtime environment properties.
+ *
+ * @return a new read-only {@link org.apache.tamaya.PropertyProvider} instance based on the current runtime environment properties.
+ */
+ public static PropertyProvider fromEnvironmentProperties() {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromEnvironmentProperties();
+ }
+
+ /**
+ * Creates a new read-only {@link org.apache.tamaya.PropertyProvider} reflecting the current system properties.
+ *
+ * @return a new read-only {@link org.apache.tamaya.PropertyProvider} instance based on the current system properties.
+ */
+ public static PropertyProvider fromSystemProperties() {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .fromSystemProperties();
+ }
+
+ /**
+ * Converts a given {@link PropertyProvider} instance into a serializable and immutable form,
+ * so it can be sent over a network connection.
+ *
+ * @param provider the PropertyProvider to be freezed.
+ * @return the serializable instance.
+ */
+ public static PropertyProvider freezed(PropertyProvider provider) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .freezed(null, provider);
+ }
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} containing all property maps given, hereby later maps in the array override
+ * properties fromMap previous instances.
+ *
+ * @param propertyMaps the maps to be included, not null.
+ * @return the union instance containing all given maps.
+ */
+ public static PropertyProvider aggregate(PropertyProvider... propertyMaps) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .aggregate(AggregationPolicy.OVERRIDE, null, Arrays.asList(propertyMaps));
+ }
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} containing all property maps given, hereby later maps in the array override
+ * properties fromMap previous instances.
+ *
+ * @param providers the maps to be included, not null.
+ * @return the union instance containing all given maps.
+ */
+ public static PropertyProvider aggregate(List<PropertyProvider> providers) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .aggregate(AggregationPolicy.OVERRIDE, null, providers);
+ }
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} containing all property maps given, hereby using the given AggregationPolicy.
+ *
+ * @param aggregationPolicy the AggregationPolicy to be used, not null.
+ * @param propertyMaps the maps to be included, not null.
+ * @return the aggregated instance containing all given maps.
+ */
+ public static PropertyProvider aggregate(AggregationPolicy aggregationPolicy, PropertyProvider... propertyMaps) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .aggregate(aggregationPolicy, null, Arrays.asList(propertyMaps));
+ }
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} containing all property maps given, hereby using the given AggregationPolicy.
+ *
+ * @param aggregationPolicy the AggregationPolicy to be used, not null.
+ * @param providers the providers to be included, not null.
+ * @return the aggregated instance containing all given maps.
+ */
+ public static PropertyProvider aggregate(AggregationPolicy aggregationPolicy, List<PropertyProvider> providers) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .aggregate(aggregationPolicy, null, providers);
+ }
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} that is mutable by adding a map based instance that overrides
+ * values fromMap the original map.
+ *
+ * @param provider the provider to be made mutable, not null.
+ * @return the mutable instance.
+ */
+ public static PropertyProvider mutable(PropertyProvider provider) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .mutable(null, provider);
+ }
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} containing only properties that are shared by all given maps,
+ * hereby later maps in the array override properties fromMap previous instances.
+ * @param aggregationPolicy the aggregationPolicy to be used, not null.
+ * @param providers the maps to be included, not null.
+ * @return the intersecting instance containing all given maps.
+ */
+ public static PropertyProvider intersected(AggregationPolicy aggregationPolicy, PropertyProvider... providers) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .intersected(aggregationPolicy, Arrays.asList(providers));
+ }
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} containing only properties that are shared by all given maps,
+ * hereby later maps in the array override properties fromMap previous instances.
+ *
+ * @param providers the maps to be included, not null.
+ * @return the intersecting instance containing all given maps.
+ * @throws ConfigException if duplicate entries are encountered (AggregationPolicy.EXCEPTION).
+ */
+ public static PropertyProvider intersected(PropertyProvider... providers) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .intersected(AggregationPolicy.OVERRIDE, Arrays.asList(providers));
+ }
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} containing only properties fromMap the target instance, that are not contained
+ * in one of the other maps passed.
+ *
+ * @param target the base map, not null.
+ * @param providers the maps to be subtracted, not null.
+ * @return the intersecting instance containing all given maps.
+ */
+ public static PropertyProvider subtracted(PropertyProvider target, PropertyProvider... providers) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .subtracted(target, Arrays.asList(providers));
+ }
+
+
+ /**
+ * Creates a filtered {@link org.apache.tamaya.PropertyProvider} (a view) of a given base {@link }PropertyMap}. The filter hereby is
+ * applied dynamically on access, so also runtime changes of the base map are reflected appropriately.
+ *
+ * @param provider the base map instance, not null.
+ * @param filter the filtger to be applied, not null.
+ * @return the new filtering instance.
+ */
+ public static PropertyProvider filtered(Predicate<String> filter, PropertyProvider provider) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .filtered(filter, provider);
+ }
+
+ /**
+ * Creates a new contextual {@link org.apache.tamaya.PropertyProvider}. Contextual maps delegate to different instances of PropertyMap depending
+ * on the keys returned fromMap the isolationP
+ *
+ * @param mapSupplier the supplier creating new provider instances
+ * @param isolationKeySupplier the supplier providing contextual keys based on the current environment.
+ */
+ public static PropertyProvider contextual(Supplier<PropertyProvider> mapSupplier,
+ Supplier<String> isolationKeySupplier) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .contextual(mapSupplier, isolationKeySupplier);
+ }
+
+
+ /**
+ * Creates a filtered {@link org.apache.tamaya.PropertyProvider} (a view) of a given base {@link }PropertyMap}. The filter hereby is
+ * applied dynamically on access, so also runtime changes of the base map are reflected appropriately.
+ *
+ * @param mainMap the main map instance, not null.
+ * @param parentMap the delegated parent map instance, not null.
+ * @return the new delegating instance.
+ */
+ public static PropertyProvider delegating(PropertyProvider mainMap, Map<String, String> parentMap) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .delegating(mainMap, parentMap);
+ }
+
+ /**
+ * Creates a {@link PropertyProvider} where all keys of a current map,
+ * existing in another map are replaced
+ * with the ones fromMap the other {@link PropertyProvider}. The filter hereby is
+ * applied dynamically on access, so also runtime changes of the base map are reflected appropriately.
+ * Keys not existing in the {@code mainMap}, but present in {@code replacementMao} will be hidden.
+ *
+ * @param mainMap the main map instance, which keys, present in {@code replacementMap} will be replaced
+ * with the ones
+ * in {@code replacementMap}, not null.
+ * @param replacementMap the map instance, that will replace all corresponding entries in {@code mainMap}, not null.
+ * @return the new delegating instance.
+ */
+ public static PropertyProvider replacing(PropertyProvider mainMap, Map<String, String> replacementMap) {
+ return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
+ .replacing(mainMap, replacementMap);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/Stages.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/Stages.java b/api/src/main/java/org/apache/tamaya/Stages.java
index 5a3559a..7cbf2cd 100644
--- a/api/src/main/java/org/apache/tamaya/Stages.java
+++ b/api/src/main/java/org/apache/tamaya/Stages.java
@@ -79,7 +79,7 @@ final class Stages {
/**
- * Method that loads the singleton backing bean from the {@link org.apache.tamaya.spi.Bootstrap} component.
+ * Method that loads the singleton backing bean fromMap the {@link org.apache.tamaya.spi.Bootstrap} component.
* @return the PropertyAdaptersSingletonSpi, never null.
*/
private static StagesSingletonSpi loadStagesSingletonSpi(){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/annot/ConfiguredProperty.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annot/ConfiguredProperty.java b/api/src/main/java/org/apache/tamaya/annot/ConfiguredProperty.java
index 6b4320f..de76cbe 100644
--- a/api/src/main/java/org/apache/tamaya/annot/ConfiguredProperty.java
+++ b/api/src/main/java/org/apache/tamaya/annot/ConfiguredProperty.java
@@ -60,7 +60,7 @@ import java.lang.annotation.*;
* Within this example we evaluate multiple possible keys. Evaluation is aborted if a key could be successfully
* resolved. Hereby the ordering of the annotations define the ordering of resolution, so in the example above
* resolution equals to {@code "aValue", "a.b.value", "a.b.deprecated.value"}. If no value could be read
- * from the configuration, it uses the value from the {@code DefaultValue} annotation. Interesting here
+ * fromMap the configuration, it uses the value fromMap the {@code DefaultValue} annotation. Interesting here
* is that this value is not static, it is evaluated by calling
* {@link org.apache.tamaya.Configuration#evaluateValue(org.apache.tamaya.Configuration, String)}.
*/
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/spi/ConfigurationManagerSingletonSpi.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/ConfigurationManagerSingletonSpi.java b/api/src/main/java/org/apache/tamaya/spi/ConfigurationManagerSingletonSpi.java
index 8e777ef..9be6ef1 100644
--- a/api/src/main/java/org/apache/tamaya/spi/ConfigurationManagerSingletonSpi.java
+++ b/api/src/main/java/org/apache/tamaya/spi/ConfigurationManagerSingletonSpi.java
@@ -21,6 +21,9 @@ package org.apache.tamaya.spi;
import org.apache.tamaya.Configuration;
import java.beans.PropertyChangeListener;
+import java.util.*;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
/**
* Manager for {@link org.apache.tamaya.Configuration} instances. Implementations must register an instance
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/api/src/main/java/org/apache/tamaya/spi/PropertyProvidersSingletonSpi.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertyProvidersSingletonSpi.java b/api/src/main/java/org/apache/tamaya/spi/PropertyProvidersSingletonSpi.java
new file mode 100644
index 0000000..80de67b
--- /dev/null
+++ b/api/src/main/java/org/apache/tamaya/spi/PropertyProvidersSingletonSpi.java
@@ -0,0 +1,198 @@
+/*
+ * 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.AggregationPolicy;
+import org.apache.tamaya.MetaInfo;
+import org.apache.tamaya.PropertyProvider;
+
+import java.net.URI;
+import java.util.*;
+import java.util.function.Predicate;
+import java.util.function.Supplier;
+
+/**
+ * Singleton backing bean for providing the functionality for {@link org.apache.tamaya.PropertyProviders}.
+ */
+public interface PropertyProvidersSingletonSpi {
+
+ /**
+ * Creates a new read-only {@link org.apache.tamaya.PropertyProvider} by using the given Map.
+ *
+ * @param metaInfo the meat information to be provided additionally.
+ * @param map the properties to be included, not null.
+ * @return a new {@link }PropertyMap} instance with the given properties fromMap the Map instance passed.
+ */
+ PropertyProvider fromMap(MetaInfo metaInfo, Map<String, String> map);
+
+ /**
+ * Creates a new {@link }PropertyMap} using the given command line arguments
+ *
+ * @param metaInfo the meta information to be provided additionally.
+ * @param args the command line arguments, not null.
+ * @return a new {@link }PropertyMap} instance with the given arguments contained as properties.
+ */
+ PropertyProvider fromArgs(MetaInfo metaInfo, String... args);
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} by reading the according path resources. The effective resources read
+ * hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ * Properties read fromMap resources evaluated on
+ * paths with lower order are overriding any duplicate values fromMap previous paths hereby.
+ *
+ * @param metaInfo the meat information to be provided additionally.
+ * @param paths the paths to be resolved by the {@code PathResolverService} , not null.
+ * @param aggregationPolicy the {@link org.apache.tamaya.AggregationPolicy} to be used to resolve conflicts.
+ * @return a new {@link }PropertyMap} instance with the given paths contained as properties.
+ */
+ PropertyProvider fromPaths(AggregationPolicy aggregationPolicy, MetaInfo metaInfo, List<String> paths);
+
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} based on the resources defined by the given paths. The effective resources
+ * read hereby are determined by the {@code PathResolverService} configured into the {@code Bootstrap} SPI.
+ *
+ * @param metaInfo the meat information to be provided additionally.
+ * @param uris the uris to be read, not null.
+ * @return a new {@link }PropertyMap} instance based on the given paths/resources found.
+ */
+ PropertyProvider fromUris(AggregationPolicy aggregationPolicy, MetaInfo metaInfo, List<URI> uris);
+
+ /**
+ * Get an empty and immutable PropertyProvider instance. The meta-information contains the given String
+ * under the key 'info'.
+ *
+ * @return an empty and immutable PropertyProvider instance, never null, with the given Strings as info meta-data..
+ */
+ PropertyProvider empty(MetaInfo metaInfo);
+
+ /**
+ * Get an empty and mutable PropertyProvider instance. The meta-information contains the given String
+ * under the key 'info'.
+ *
+ * @return an empty and immutable PropertyProvider instance, never null, with the given Strings as info meta-data..
+ */
+ PropertyProvider emptyMutable(MetaInfo metaInfo);
+
+ /**
+ * Returns a read-only {@link org.apache.tamaya.PropertyProvider} reflecting the current runtime environment properties.
+ *
+ * @return a new read-only {@link org.apache.tamaya.PropertyProvider} instance based on the current runtime environment properties.
+ */
+ PropertyProvider fromEnvironmentProperties();
+
+ /**
+ * Creates a new read-only {@link org.apache.tamaya.PropertyProvider} reflecting the current system properties.
+ *
+ * @return a new read-only {@link org.apache.tamaya.PropertyProvider} instance based on the current system properties.
+ */
+ PropertyProvider fromSystemProperties();
+
+ /**
+ * Converts a given {@link PropertyProvider} instance into a serializable and immutable form,
+ * so it can be sent over a network connection.
+ *
+ * @param provider the PropertyProvider to be freezed.
+ * @return the serializable instance.
+ */
+ PropertyProvider freezed(MetaInfo metaInfo, PropertyProvider provider);
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} containing all property maps given, hereby using the given AggregationPolicy.
+ *
+ * @param aggregationPolicy the AggregationPolicy to be used, not null.
+ * @param propertyMaps the maps to be included, not null.
+ * @return the aggregated instance containing all given maps.
+ */
+ PropertyProvider aggregate(AggregationPolicy aggregationPolicy, MetaInfo metaInfo, List<PropertyProvider> propertyMaps);
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} that is mutable by adding a map based instance that overrides
+ * values fromMap the original map.
+ * @param provider the provider to be made mutable, not null.
+ * @return the mutable instance.
+ */
+ PropertyProvider mutable(MetaInfo metaInfo, PropertyProvider provider);
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} containing only properties that are shared by all given maps,
+ * hereby later maps in the array override properties fromMap previous instances.
+ *
+ * @param propertyMaps the maps to be included, not null.
+ * @return the intersecting instance containing all given maps.
+ */
+ PropertyProvider intersected(AggregationPolicy policy, List<PropertyProvider> propertyMaps);
+
+ /**
+ * Creates a new {@link org.apache.tamaya.PropertyProvider} containing only properties fromMap the target instance, that are not contained
+ * in one of the other maps passed.
+ *
+ * @param target the base map, not null.
+ * @param subtrahendSets the maps to be subtracted, not null.
+ * @return the intersecting instance containing all given maps.
+ */
+ PropertyProvider subtracted(PropertyProvider target, List<PropertyProvider> subtrahendSets);
+
+
+ /**
+ * Creates a filtered {@link org.apache.tamaya.PropertyProvider} (a view) of a given base {@link }PropertyMap}. The filter hereby is
+ * applied dynamically on access, so also runtime changes of the base map are reflected appropriately.
+ *
+ * @param propertyMap the base map instance, not null.
+ * @param filter the filtger to be applied, not null.
+ * @return the new filtering instance.
+ */
+ PropertyProvider filtered(Predicate<String> filter, PropertyProvider propertyMap);
+
+ /**
+ * Creates a new contextual {@link org.apache.tamaya.PropertyProvider}. Contextual maps delegate to different instances of PropertyMap depending
+ * on the keys returned fromMap the isolationP
+ *
+ * @param mapSupplier the supplier creating new provider instances
+ * @param isolationKeySupplier the supplier providing contextual keys based on the current environment.
+ */
+ PropertyProvider contextual(Supplier<PropertyProvider> mapSupplier,
+ Supplier<String> isolationKeySupplier);
+
+
+ /**
+ * Creates a filtered {@link org.apache.tamaya.PropertyProvider} (a view) of a given base {@link }PropertyMap}. The filter hereby is
+ * applied dynamically on access, so also runtime changes of the base map are reflected appropriately.
+ *
+ * @param mainMap the main map instance, not null.
+ * @param parentMap the delegated parent map instance, not null.
+ * @return the new delegating instance.
+ */
+ PropertyProvider delegating(PropertyProvider mainMap, Map<String, String> parentMap);
+
+ /**
+ * Creates a {@link PropertyProvider} where all keys of a current map,
+ * existing in another map are replaced
+ * with the ones fromMap the other {@link PropertyProvider}. The filter hereby is
+ * applied dynamically on access, so also runtime changes of the base map are reflected appropriately.
+ * Keys not existing in the {@code mainMap}, but present in {@code replacementMao} will be hidden.
+ *
+ * @param mainMap the main map instance, which keys, present in {@code replacementMap} will be replaced
+ * with the ones
+ * in {@code replacementMap}, not null.
+ * @param replacementMap the map instance, that will replace all corresponding entries in {@code mainMap}, not null.
+ * @return the new delegating instance.
+ */
+ PropertyProvider replacing(PropertyProvider mainMap, Map<String, String> replacementMap);
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java b/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java
index 3275907..7dc56c1 100644
--- a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java
+++ b/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java
@@ -18,14 +18,9 @@
*/
package org.apache.tamaya.core.config;
-import org.apache.tamaya.core.properties.AggregationPolicy;
-import org.apache.tamaya.core.properties.PropertyProviders;
+import org.apache.tamaya.*;
import org.apache.tamaya.core.spi.ResourceLoader;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.PropertyProvider;
import org.apache.tamaya.spi.Bootstrap;
import java.net.URI;
import java.util.*;
@@ -118,13 +113,13 @@ public final class ConfigurationBuilder{
}
PropertyProvider prov = PropertyProviders.fromUris(metaInfo, sourcesToRead.collect(Collectors.toList()));
if(!this.data.isEmpty()){
- prov = PropertyProviders.union(AggregationPolicy.OVERRIDE, prov, PropertyProviders.from(this.data));
+ prov = PropertyProviders.aggregate(AggregationPolicy.OVERRIDE, prov, PropertyProviders.fromMap(this.data));
}
for(ConfigMapAddition addition : addedMaps){
PropertyProvider[] newMaps = new PropertyProvider[addition.configMaps.length + 1];
newMaps[0] = prov;
System.arraycopy(addition.configMaps, 0, newMaps, 1, addition.configMaps.length);
- prov = PropertyProviders.union(addition.policy, newMaps);
+ prov = PropertyProviders.aggregate(addition.policy, newMaps);
}
final PropertyProvider finalProvider = prov;
return new MapConfiguration(metaInfo, () -> finalProvider.toMap());
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/config/ConfigurationFormats.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationFormats.java b/core/src/main/java/org/apache/tamaya/core/config/ConfigurationFormats.java
index ebce952..740eacb 100644
--- a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationFormats.java
+++ b/core/src/main/java/org/apache/tamaya/core/config/ConfigurationFormats.java
@@ -40,7 +40,7 @@ public final class ConfigurationFormats{
private static final ConfigurationFormatsSingletonSpi spi = loadSpi();
/**
- * Method to load the spi from the Bootstrap component.
+ * Method to load the spi fromMap the Bootstrap component.
*
* @return an instance of ConfigurationFormatsSingletonSpi, never null.
*/
@@ -96,10 +96,10 @@ public final class ConfigurationFormats{
}
/**
- * Get an instance for reading configuration from a {@code .properties} file,
+ * Get an instance for reading configuration fromMap a {@code .properties} file,
* as defined by {@link java.util.Properties#load(java.io.InputStream)}.
*
- * @return a format instance for reading configuration from a {@code .properties} file, never null.
+ * @return a format instance for reading configuration fromMap a {@code .properties} file, never null.
*/
public static ConfigurationFormat getPropertiesFormat(){
return Optional.ofNullable(spi)
@@ -108,10 +108,10 @@ public final class ConfigurationFormats{
}
/**
- * Get an instance for reading configuration from a {@code .xml} properties file,
+ * Get an instance for reading configuration fromMap a {@code .xml} properties file,
* as defined by {@link java.util.Properties#loadFromXML(java.io.InputStream)}.
*
- * @return a format instance for reading configuration from a {@code .xml} properties file, never null.
+ * @return a format instance for reading configuration fromMap a {@code .xml} properties file, never null.
*/
public static ConfigurationFormat getXmlPropertiesFormat(){
return Optional.ofNullable(spi)
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/config/EnvPropertiesConfigProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/EnvPropertiesConfigProvider.java b/core/src/main/java/org/apache/tamaya/core/config/EnvPropertiesConfigProvider.java
index 62fb8dd..7fe9c09 100644
--- a/core/src/main/java/org/apache/tamaya/core/config/EnvPropertiesConfigProvider.java
+++ b/core/src/main/java/org/apache/tamaya/core/config/EnvPropertiesConfigProvider.java
@@ -18,8 +18,8 @@
*/
package org.apache.tamaya.core.config;
-import org.apache.tamaya.core.properties.AggregationPolicy;
-import org.apache.tamaya.core.properties.PropertyProviders;
+import org.apache.tamaya.AggregationPolicy;
+import org.apache.tamaya.PropertyProviders;
import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
import org.apache.tamaya.Configuration;
@@ -35,7 +35,8 @@ public class EnvPropertiesConfigProvider implements ConfigurationProviderSpi{
private Configuration envConfig;
public EnvPropertiesConfigProvider(){
- envConfig = ConfigurationBuilder.of("environment.properties").addConfigMaps(AggregationPolicy.OVERRIDE, PropertyProviders.fromEnvironmentProperties()).build();
+ envConfig = ConfigurationBuilder.of("environment.properties").addConfigMaps(AggregationPolicy.OVERRIDE,
+ PropertyProviders.fromEnvironmentProperties()).build();
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java b/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
index 134bdc5..4e35c4d 100644
--- a/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
+++ b/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
@@ -18,12 +18,7 @@
*/
package org.apache.tamaya.core.config;
-import org.apache.tamaya.ConfigChangeSetBuilder;
-import org.apache.tamaya.PropertyProvider;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.core.properties.PropertyProviders;
+import org.apache.tamaya.*;
import java.io.Serializable;
import java.time.Instant;
@@ -31,7 +26,8 @@ import java.util.Map;
import java.util.Objects;
/**
- * Created by Anatole on 29.03.14.
+ * Configuration implementation that stores all current values of a given (possibly dynamic, contextual and non remote
+ * capable instance) and is fully serializable.
*/
final class FreezedConfiguration extends AbstractConfiguration implements Serializable{
private static final long serialVersionUID = -6373137316556444171L;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/config/SystemPropertiesConfigProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/SystemPropertiesConfigProvider.java b/core/src/main/java/org/apache/tamaya/core/config/SystemPropertiesConfigProvider.java
index 1356fb1..f19d874 100644
--- a/core/src/main/java/org/apache/tamaya/core/config/SystemPropertiesConfigProvider.java
+++ b/core/src/main/java/org/apache/tamaya/core/config/SystemPropertiesConfigProvider.java
@@ -18,8 +18,8 @@
*/
package org.apache.tamaya.core.config;
-import org.apache.tamaya.core.properties.AggregationPolicy;
-import org.apache.tamaya.core.properties.PropertyProviders;
+import org.apache.tamaya.AggregationPolicy;
+import org.apache.tamaya.PropertyProviders;
import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
import org.apache.tamaya.Configuration;
@@ -35,7 +35,8 @@ public class SystemPropertiesConfigProvider implements ConfigurationProviderSpi{
private Configuration systemConfig;
public SystemPropertiesConfigProvider(){
- systemConfig = ConfigurationBuilder.of("system.properties").addConfigMaps(AggregationPolicy.OVERRIDE, PropertyProviders.fromSystemProperties()).build();
+ systemConfig = ConfigurationBuilder.of("system.properties").addConfigMaps(AggregationPolicy.OVERRIDE,
+ PropertyProviders.fromSystemProperties()).build();
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/internal/AggregatedPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/internal/AggregatedPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/internal/AggregatedPropertyProvider.java
new file mode 100644
index 0000000..fdcd073
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/internal/AggregatedPropertyProvider.java
@@ -0,0 +1,137 @@
+/*
+ * 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.*;
+import org.apache.tamaya.core.properties.AbstractPropertyProvider;
+
+import java.util.*;
+
+/**
+ * Implementation for a {@link org.apache.tamaya.PropertyProvider} that is an aggregate of
+ * multiple child instances. Controlled by an {@link org.apache.tamaya.AggregationPolicy} the
+ * following aggregations are supported:
+ * <ul>
+ * <li><b>IGNORE: </b>Ignore all overrides.</li>
+ * <li><b>: </b></li>
+ * <li><b>: </b></li>
+ * <li><b>: </b></li>
+ * </ul>
+ */
+class AggregatedPropertyProvider extends AbstractPropertyProvider {
+
+ private static final long serialVersionUID = -1419376385695224799L;
+ private AggregationPolicy policy = AggregationPolicy.IGNORE;
+ private List<PropertyProvider> units = new ArrayList<PropertyProvider>();
+ private PropertyProvider mutableProvider;
+
+ /**
+ * Creates a new instance.
+ * @param mutableProvider the provider instance that would be used for delegating
+ * change requests.
+ * @param policy
+ * The aggregation policy to be used.
+ * @param propertyMaps
+ * The property sets to be included.
+ */
+ public AggregatedPropertyProvider(MetaInfo metaInfo, PropertyProvider mutableProvider, AggregationPolicy policy, List<PropertyProvider> propertyMaps) {
+ super(MetaInfoBuilder.of(metaInfo).setType("aggregated").build());
+ Objects.requireNonNull(policy);
+ this.policy = policy;
+ units.addAll(propertyMaps);
+ this.mutableProvider = mutableProvider;
+ }
+
+ /**
+ * Get the {@link AggregationPolicy} for this instance.
+ *
+ * @return the {@link AggregationPolicy}, never {@code null}.
+ */
+ public AggregationPolicy getAggregationPolicy() {
+ return policy;
+ }
+
+ /**
+ * Return the names of the {@link org.apache.tamaya.PropertyProvider} instances to be
+ * aggregated in this instance, in the order of precedence (the first are
+ * the weakest).
+ *
+ * @return the ordered list of aggregated scope identifiers, never
+ * {@code null}.
+ */
+ public List<PropertyProvider> getConfigurationUnits() {
+ return Collections.unmodifiableList(units);
+ }
+
+ /**
+ * Apply a config change to this item. Hereby the change must be related to the same instance.
+ * @param change the config change
+ * @throws org.apache.tamaya.ConfigException if an unrelated change was passed.
+ * @throws UnsupportedOperationException when the configuration is not writable.
+ */
+ @Override
+ public void apply(ConfigChangeSet change){
+ if(mutableProvider!=null)
+ mutableProvider.apply(change);
+ else
+ super.apply(change);
+ }
+
+ @Override
+ public Map<String,String> toMap() {
+ Map<String, String> value = new HashMap<>();
+ for (PropertyProvider unit : units) {
+ for (Map.Entry<String, String> entry : unit.toMap()
+ .entrySet()) {
+ switch (policy) {
+ case IGNORE:
+ if (!value.containsKey(entry.getKey())) {
+ value.put(entry.getKey(), entry.getValue());
+ }
+ break;
+ case EXCEPTION:
+ if (value.containsKey(entry.getKey())) {
+ throw new IllegalStateException("Duplicate key: "
+ + entry.getKey()
+ + " in " + this);
+ }
+ else {
+ value.put(entry.getKey(), entry.getValue());
+ }
+ break;
+ case OVERRIDE:
+ value.put(entry.getKey(), entry.getValue());
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ return value;
+ }
+
+ @Override
+ public ConfigChangeSet load() {
+ for (PropertyProvider unit : units) {
+ unit.load();
+ }
+ return super.load();
+ }
+
+}