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/06 02:03:30 UTC
[8/9] incubator-tamaya git commit: TAMAYA-19: Code cleanup.
TAMAYA-19: Code cleanup.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/0eef8f37
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/0eef8f37
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/0eef8f37
Branch: refs/heads/master
Commit: 0eef8f370d715ec7770916bca2a0e54a88df589e
Parents: 8162078
Author: anatole <an...@apache.org>
Authored: Sat Dec 6 02:02:57 2014 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Dec 6 02:02:57 2014 +0100
----------------------------------------------------------------------
.../java/org/apache/tamaya/MetaInfoBuilder.java | 8 +-
.../org/apache/tamaya/PropertyProvider.java | 4 +
.../apache/tamaya/PropertyProviderBuilder.java | 166 ++--
.../tamaya/spi/PropertyProviderBuilderSpi.java | 30 +-
.../apache/tamaya/core/EnvironmentSelector.java | 47 ++
.../tamaya/core/config/ConfigLocation.java | 116 ---
.../core/config/ConfigurationBuilder.java | 148 ----
.../core/config/ConfigurationDecorator.java | 109 ---
.../core/config/ConfigurationFormats.java | 5 +-
.../core/config/ConfigurationProducer.java | 56 --
.../config/ConfigurationProducerBuilder.java | 94 ---
.../tamaya/core/config/Configurations.java | 43 -
.../config/EnvPropertiesConfigProvider.java | 51 --
.../core/config/FreezedConfiguration.java | 7 +-
.../tamaya/core/config/MapConfiguration.java | 44 -
.../tamaya/core/config/MetaInfoEditor.java | 134 ---
.../core/config/PropertyChangeConsumer.java | 50 --
.../config/SystemPropertiesConfigProvider.java | 51 --
.../apache/tamaya/core/env/DefaultStage.java | 69 ++
.../tamaya/core/env/EnvironmentSelector.java | 47 --
.../apache/tamaya/core/env/StageBuilder.java | 81 ++
.../internal/AggregatedPropertyProvider.java | 122 ---
.../ConfigurationInvocationHandler.java | 51 --
.../internal/ContextualPropertyProvider.java | 174 ----
...DefaultConfigurationManagerSingletonSpi.java | 131 ---
.../internal/DefaultExpressionEvaluator.java | 139 ----
.../DefaultPropertyAdaptersSingletonSpi.java | 100 ---
.../DefaultPropertyProvidersSingletonSpi.java | 288 -------
.../tamaya/core/internal/DefaultStage.java | 69 --
.../internal/DefaultStagesSingletonSpi.java | 108 ---
.../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 ---
.../tamaya/core/internal/MapConfiguration.java | 121 ---
.../apache/tamaya/core/internal/MetaConfig.java | 16 +-
.../internal/PathBasedPropertyProvider.java | 85 --
.../internal/ReplacingPropertyProvider.java | 111 ---
.../tamaya/core/internal/StageBuilder.java | 81 --
.../internal/SubtractingPropertyProvider.java | 76 --
.../SystemPropertiesPropertyProvider.java | 53 --
.../core/internal/UriBasedPropertyProvider.java | 83 --
.../internal/WeakConfigListenerManager.java | 104 ---
.../config/ConfigTemplateInvocationHandler.java | 51 ++
...DefaultConfigurationManagerSingletonSpi.java | 151 ++++
.../config/EnvPropertiesConfigProvider.java | 49 ++
.../config/SystemPropertiesConfigProvider.java | 49 ++
.../config/WeakConfigListenerManager.java | 104 +++
.../internal/el/DefaultExpressionEvaluator.java | 139 ++++
.../tamaya/core/internal/el/ELResolver.java | 159 ----
...DependentApplicationEnvironmentProvider.java | 33 +-
...ssLoaderDependentEarEnvironmentProvider.java | 37 +-
.../internal/env/DefaultStagesSingletonSpi.java | 109 +++
.../SystemClassLoaderEnvironmentProvider.java | 22 +-
.../DefaultConfigFormatsSingletonSpi.java | 4 +-
.../tamaya/core/internal/format/IniFormat.java | 19 +-
.../core/internal/format/PropertiesFormat.java | 19 +-
.../internal/format/PropertiesXmlFormat.java | 19 +-
.../properties/AggregatedPropertyProvider.java | 122 +++
.../properties/ClasspathPropertyProvider.java | 150 ++++
.../properties/ContextualPropertyProvider.java | 177 ++++
.../DefaultPropertyAdaptersSingletonSpi.java | 100 +++
.../DefaultPropertyProviderBuilderSpi.java | 282 +++++++
.../properties/DelegatingPropertyProvider.java | 108 +++
.../properties/EnvironmentPropertyProvider.java | 45 +
.../properties/FilteredPropertyProvider.java | 74 ++
.../properties/FreezedPropertyProvider.java | 98 +++
.../IntersectingPropertyProvider.java | 71 ++
.../properties/MapBasedPropertyProvider.java | 107 +++
.../properties/PathBasedPropertyProvider.java | 85 ++
.../properties/ReplacingPropertyProvider.java | 115 +++
.../properties/SubtractingPropertyProvider.java | 78 ++
.../SystemPropertiesPropertyProvider.java | 53 ++
.../properties/URLBasedPropertyProvider.java | 90 ++
.../resources/AntPathClasspathResolver.java | 39 +-
.../resources/AntPathClasspathsResolver.java | 133 ++-
.../internal/resources/AntPathFileResolver.java | 23 +-
.../resources/AntPathFilesResolver.java | 121 +--
.../resources/DefaultPathResourceLoader.java | 33 +-
.../core/internal/resources/PathResolver.java | 45 -
.../io/AbstractFileResolvingResource.java | 2 +
.../internal/resources/io/AbstractResource.java | 6 +-
.../resources/io/ClassPathResource.java | 4 +-
.../resources/io/DefaultResourceLoader.java | 2 +
.../resources/io/FileSystemResource.java | 4 +-
.../resources/io/InputStreamResource.java | 9 +-
.../resources/io/InputStreamSource.java | 55 --
.../io/PathMatchingResourcePatternResolver.java | 2 +
.../core/internal/resources/io/Resource.java | 135 ---
.../core/internal/resources/io/UrlResource.java | 4 +-
.../core/internal/resources/io/VfsResource.java | 4 +-
.../internal/resources/io/WritableResource.java | 2 +
.../properties/AbstractPropertyProvider.java | 3 +-
.../properties/AbstractResourceConfigMap.java | 10 +-
.../ClasspathModulePropertyProvider.java | 2 +-
.../properties/ClasspathPropertyProvider.java | 147 ----
.../MapBasedPropertyProviderBuilder.java | 125 ---
.../tamaya/core/resource/InputStreamSource.java | 55 ++
.../apache/tamaya/core/resource/Resource.java | 126 +++
.../tamaya/core/resource/ResourceLoader.java | 84 ++
.../tamaya/core/spi/ConfigurationFormat.java | 7 +-
.../spi/ConfigurationFormatsSingletonSpi.java | 5 +-
.../tamaya/core/spi/EnvironmentProvider.java | 4 +-
.../apache/tamaya/core/spi/PathResolver.java | 45 +
.../apache/tamaya/core/spi/ResourceLoader.java | 86 --
.../resources/META-INF/meta-model.properties | 2 +-
....tamaya.core.internal.resources.PathResolver | 22 -
...g.apache.tamaya.core.resource.ResourceLoader | 20 +
...che.tamaya.core.spi.ConfigurationProviderSpi | 3 +-
.../org.apache.tamaya.core.spi.PathResolver | 20 +
.../org.apache.tamaya.core.spi.ResourceLoader | 20 -
....tamaya.spi.ConfigurationManagerSingletonSpi | 2 +-
...ache.tamaya.spi.PropertyAdaptersSingletonSpi | 2 +-
...apache.tamaya.spi.PropertyProviderBuilderSpi | 19 +
.../org.apache.tamaya.spi.StagesSingletonSpi | 2 +-
...tionManagerSingletonSpiSingletonSpiTest.java | 4 +-
.../java/org/apache/tamaya/JavaOneDemo.java | 29 +-
.../tamaya/core/env/EnvironmentManagerTest.java | 13 +-
.../properties/PropertyProviderBuilderTest.java | 54 ++
.../core/properties/PropertyProvidersTest.java | 54 --
.../internal/MutableTestConfigProvider.java | 8 +-
.../tamaya/internal/TestConfigProvider.java | 6 +-
.../simple/SimplePropertiesAndCLISample.java | 28 +-
.../apache/tamaya/ucs/UC1ReadProperties.java | 34 +-
.../apache/tamaya/ucs/UC2CombineProperties.java | 27 +-
.../META-INF/env/application.properties | 3 +-
core/src/test/resources/META-INF/env/ear.ini | 2 +-
.../resources/META-INF/env/system.properties | 2 +-
...che.tamaya.core.spi.ConfigurationProviderSpi | 2 -
docs/design/2_CoreConcepts.adoc | 65 +-
docs/design/3_Extensions.adoc | 825 +++++++++++++++++++
docs/design/4_ImplementationCore.adoc | 31 +
.../ext/cdi/ConfigurationExtension.java | 81 ++
.../tamaya/ext/cdi/ConfigurationExtension.java | 82 --
.../javax.enterprise.inject.spi.Extension | 2 +-
.../java/metamodel/ext/cdi/ConfiguredClass.java | 112 +++
.../java/metamodel/ext/cdi/ConfiguredTest.java | 45 +
.../metamodel/ext/cdi/TestConfigProvider.java | 46 ++
.../apache/tamaya/ext/cdi/ConfiguredClass.java | 112 ---
.../apache/tamaya/ext/cdi/ConfiguredTest.java | 45 -
.../tamaya/ext/cdi/TestConfigProvider.java | 47 --
143 files changed, 4705 insertions(+), 4981 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java b/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
index d2e477e..a35c8e8 100644
--- a/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
+++ b/api/src/main/java/org/apache/tamaya/MetaInfoBuilder.java
@@ -46,16 +46,20 @@ public final class MetaInfoBuilder{
}
}
+ private MetaInfoBuilder(String name){
+ this.map.put(NAME, Objects.requireNonNull(name));
+ }
+
public static MetaInfoBuilder of(MetaInfo metaInfo){
return new MetaInfoBuilder(metaInfo);
}
public static MetaInfoBuilder of(String name){
- return new MetaInfoBuilder(null).setName(name);
+ return new MetaInfoBuilder(name);
}
public static MetaInfoBuilder of(){
- return new MetaInfoBuilder(null).setName("<noname>");
+ return new MetaInfoBuilder("<noname>");
}
public MetaInfoBuilder withName(String name){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/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 0d225a4..5284690 100644
--- a/api/src/main/java/org/apache/tamaya/PropertyProvider.java
+++ b/api/src/main/java/org/apache/tamaya/PropertyProvider.java
@@ -151,6 +151,10 @@ public interface PropertyProvider {
public MetaInfo getMetaInfo() {
return PropertyProvider.this.getMetaInfo();
}
+ @Override
+ public String toString() {
+ return "Configuration ["+getMetaInfo().getOwnerInfo()+"]";
+ }
};
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/api/src/main/java/org/apache/tamaya/PropertyProviderBuilder.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/PropertyProviderBuilder.java b/api/src/main/java/org/apache/tamaya/PropertyProviderBuilder.java
index d3af701..99e7e9e 100644
--- a/api/src/main/java/org/apache/tamaya/PropertyProviderBuilder.java
+++ b/api/src/main/java/org/apache/tamaya/PropertyProviderBuilder.java
@@ -21,7 +21,7 @@ package org.apache.tamaya;
import org.apache.tamaya.spi.Bootstrap;
import org.apache.tamaya.spi.PropertyProviderBuilderSpi;
-import java.net.URI;
+import java.net.URL;
import java.util.*;
import java.util.function.Predicate;
import java.util.function.Supplier;
@@ -109,6 +109,15 @@ public final class PropertyProviderBuilder {
return create(MetaInfo.of(name));
}
+ /**
+ * Creates a new builder instance.
+ *
+ * @return a new builder instance, never null.
+ */
+ public static PropertyProviderBuilder create() {
+ return create(MetaInfo.of("<noname>"));
+ }
+
/**
* Sets the aggregation policy to be used, when adding additional property sets. The policy will
@@ -134,7 +143,11 @@ public final class PropertyProviderBuilder {
}
public PropertyProviderBuilder addProviders(PropertyProvider... providers) {
- List<PropertyProvider> allProviders = Arrays.asList(providers);
+ return addProviders(Arrays.asList(providers));
+ }
+
+ public PropertyProviderBuilder addProviders(List<PropertyProvider> providers) {
+ List<PropertyProvider> allProviders = new ArrayList<>(providers);
if (this.current != null) {
allProviders.add(0, this.current);
}
@@ -143,16 +156,17 @@ public final class PropertyProviderBuilder {
mi = MetaInfoBuilder.of("aggregate").setEnvironment(Environment.current()).build();
}
this.current = Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .aggregate(this.aggregationPolicy, mi, allProviders);
+ .aggregate(mi, this.aggregationPolicy, allProviders);
this.metaInfo = null;
return this;
}
/**
- * Creates a new {@link }PropertyMap} using the given command line arguments
+ * Creates a new {@link PropertyProvider} using the given command line arguments and adds it
+ * using the current aggregation policy in place.
*
* @param args the command line arguments, not null.
- * @return a new {@link }PropertyMap} instance with the given arguments contained as properties.
+ * @return the builder for chaining.
*/
public PropertyProviderBuilder addArgs(String... args) {
MetaInfo mi = this.metaInfo;
@@ -167,33 +181,23 @@ public final class PropertyProviderBuilder {
/**
* 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.
+ * Properties read are aggregated using the current aggregation policy active.
*
* @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.
+ * @return the builder for chaining.
*/
public PropertyProviderBuilder addPaths(String... paths) {
- MetaInfo mi = this.metaInfo;
- if (mi == null) {
- mi = MetaInfoBuilder.of("aggregate").setEnvironment(Environment.current()).build();
- } else {
- mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).set("paths", Arrays.toString(paths)).build();
- }
- return addProviders(Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .fromPaths(aggregationPolicy, mi, Arrays.asList(paths)));
+ return addPaths(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.
+ * Properties read are aggregated using the current aggregation policy active.
*
* @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).
+ * @return the builder for chaining.
*/
public PropertyProviderBuilder addPaths(List<String> paths) {
MetaInfo mi = this.metaInfo;
@@ -203,34 +207,45 @@ public final class PropertyProviderBuilder {
mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).set("paths", paths.toString()).build();
}
return addProviders(Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .fromPaths(aggregationPolicy, metaInfo, paths));
+ .fromPaths(mi, aggregationPolicy, paths));
+ }
+
+ /**
+ * Creates a new read-only {@link PropertyProvider} by reading the according URL resources.
+ * Properties read are aggregated using the current aggregation policy active.
+ *
+ * @param urls the urls to be read, not null.
+ * @return the builder for chaining.
+ */
+ public PropertyProviderBuilder addURLs(URL... urls) {
+ return addURLs(Arrays.asList(urls));
}
/**
- * 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.
+ * Creates a new read-only {@link PropertyProvider} by reading the according URL resources.
+ * Properties read are aggregated using the current aggregation policy active.
*
- * @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).
+ * @param urls the urls to be read, not null.
+ * @return the builder for chaining.
*/
- public PropertyProviderBuilder addUris(URI... uris) {
+ public PropertyProviderBuilder addURLs(List<URL> urls) {
MetaInfo mi = this.metaInfo;
if (mi == null) {
- mi = MetaInfoBuilder.of("aggregate").set("uris", Arrays.toString(uris)).setEnvironment(Environment.current()).build();
+ mi = MetaInfoBuilder.of("aggregate").set("urls", urls.toString()).setEnvironment(Environment.current()).build();
} else {
- mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).set("paths", uris.toString()).build();
+ mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).set("urls", urls.toString()).build();
}
return addProviders(Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .fromUris(this.aggregationPolicy, mi, Arrays.asList(uris)));
+ .fromURLs(mi, this.aggregationPolicy, urls));
}
/**
- * Creates a new read-only {@link org.apache.tamaya.PropertyProvider} by using the given Map.
+ * Creates a new read-only {@link PropertyProvider} based on the given map.
+ * Properties read are aggregated using the current aggregation policy active.
*
- * @param map the properties to be included, not null.
- * @return a new {@link }PropertyMap} instance with the given properties fromMap the Map instance passed.
+ * @param map the map to be added, not null.
+ * @return the builder for chaining.
*/
public PropertyProviderBuilder addMap(Map<String, String> map) {
MetaInfo mi = this.metaInfo;
@@ -240,14 +255,14 @@ public final class PropertyProviderBuilder {
mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).build();
}
return addProviders(Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .fromMap(metaInfo, map));
+ .fromMap(mi, map));
}
/**
- * Returns a read-only {@link org.apache.tamaya.PropertyProvider} reflecting the current runtime environment properties.
+ * Add the current environment properties. Aggregation is based on the current {@link org.apache.tamaya.AggregationPolicy} acvtive.
*
- * @return a new read-only {@link org.apache.tamaya.PropertyProvider} instance based on the current runtime environment properties.
+ * @return the builder for chaining.
*/
public PropertyProviderBuilder addEnvironmentProperties() {
MetaInfo mi = this.metaInfo;
@@ -261,9 +276,9 @@ public final class PropertyProviderBuilder {
}
/**
- * Creates a new read-only {@link org.apache.tamaya.PropertyProvider} reflecting the current system properties.
+ * Add the current system properties. Aggregation is based on the current {@link org.apache.tamaya.AggregationPolicy} acvtive.
*
- * @return a new read-only {@link org.apache.tamaya.PropertyProvider} instance based on the current system properties.
+ * @return the builder for chaining.
*/
public PropertyProviderBuilder addSystemProperties() {
MetaInfo mi = this.metaInfo;
@@ -277,11 +292,11 @@ public final class PropertyProviderBuilder {
}
/**
- * Creates a new {@link org.apache.tamaya.PropertyProvider} containing all property maps given, hereby later maps in the array override
- * properties fromMap previous instances.
+ * Adds the given {@link org.apache.tamaya.PropertyProvider} instances using the current {@link org.apache.tamaya.AggregationPolicy}
+ * active.
*
* @param providers the maps to be included, not null.
- * @return the union instance containing all given maps.
+ * @return the builder for chaining.
*/
public PropertyProviderBuilder aggregate(PropertyProvider... providers) {
MetaInfo mi = this.metaInfo;
@@ -291,16 +306,16 @@ public final class PropertyProviderBuilder {
mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).build();
}
return addProviders(Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .aggregate(aggregationPolicy, mi, Arrays.asList(providers)));
+ .aggregate(mi, aggregationPolicy, Arrays.asList(providers)));
}
/**
- * Creates a new {@link org.apache.tamaya.PropertyProvider} containing all property maps given, hereby later maps in the array override
- * properties fromMap previous instances.
+ * Adds the given {@link org.apache.tamaya.PropertyProvider} instances using the current {@link org.apache.tamaya.AggregationPolicy}
+ * active.
*
* @param providers the maps to be included, not null.
- * @return the union instance containing all given maps.
+ * @return the builder for chaining.
*/
public PropertyProviderBuilder aggregate(List<PropertyProvider> providers) {
MetaInfo mi = this.metaInfo;
@@ -310,7 +325,7 @@ public final class PropertyProviderBuilder {
mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).build();
}
return addProviders(Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .aggregate(aggregationPolicy, metaInfo, providers));
+ .aggregate(mi, aggregationPolicy, providers));
}
@@ -326,12 +341,12 @@ public final class PropertyProviderBuilder {
.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.
+ * Intersetcs the current properties with the given {@link org.apache.tamaya.PropertyProvider} instance.
*
- * @param providers the maps to be included, not null.
- * @return the intersecting instance containing all given maps.
+ * @param providers the maps to be intersected, not null.
+ * @return the builder for chaining.
*/
public PropertyProviderBuilder intersect(PropertyProvider... providers) {
MetaInfo mi = this.metaInfo;
@@ -341,16 +356,15 @@ public final class PropertyProviderBuilder {
mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).build();
}
return addProviders(Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .intersected(aggregationPolicy, mi, Arrays.asList(providers)));
+ .intersected(mi,aggregationPolicy, Arrays.asList(providers)));
}
/**
- * Creates a new {@link org.apache.tamaya.PropertyProvider} containing only properties fromMap the target instance, that are not contained
- * in one current the other maps passed.
+ * Subtracts with the given {@link org.apache.tamaya.PropertyProvider} instance from the current properties.
*
* @param providers the maps to be subtracted, not null.
- * @return the intersecting instance containing all given maps.
+ * @return the builder for chaining.
*/
public PropertyProviderBuilder subtract(PropertyProvider... providers) {
MetaInfo mi = this.metaInfo;
@@ -360,16 +374,15 @@ public final class PropertyProviderBuilder {
mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).build();
}
current = Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .subtracted(current, mi, Arrays.asList(providers));
+ .subtracted(mi, current, Arrays.asList(providers));
return this;
}
/**
- * Creates a filtered {@link org.apache.tamaya.PropertyProvider} (a view) current a given base {@link }PropertyMap}. The filter hereby is
- * applied dynamically on access, so also runtime changes current the base map are reflected appropriately.
+ * Filters the current properties based on the given predicate..
*
- * @param filter the filtger to be applied, not null.
+ * @param filter the filter to be applied, not null.
* @return the new filtering instance.
*/
public PropertyProviderBuilder filter(Predicate<String> filter) {
@@ -380,7 +393,7 @@ public final class PropertyProviderBuilder {
mi = MetaInfoBuilder.of(metaInfo).set("filter", filter.toString()).setEnvironment(Environment.current()).build();
}
current = Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .filtered(filter, mi, current);
+ .filtered(mi, filter, current);
return this;
}
@@ -400,34 +413,11 @@ public final class PropertyProviderBuilder {
mi = MetaInfoBuilder.of(metaInfo).set("mapSupplier", mapSupplier.toString()).set("isolationKeySupplier", isolationKeySupplier.toString()).setEnvironment(Environment.current()).build();
}
return addProviders(Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .contextual(mapSupplier, mi, isolationKeySupplier));
- }
-
- /**
- * Creates a filtered {@link org.apache.tamaya.PropertyProvider} (a view) current a given base {@link }PropertyMap}. The filter hereby is
- * applied dynamically on access, so also runtime changes current the base map are reflected appropriately.
- *
- * @param delegates the delegated parent map instance, not null.
- * @return the new delegating instance.
- */
- public PropertyProviderBuilder addDefaults(Map<String, String> delegates) {
- MetaInfo mi = this.metaInfo;
- if (mi == null) {
- mi = MetaInfoBuilder.of("filtered").setEnvironment(Environment.current()).set("delegates", delegates.toString()).build();
- } else {
- mi = MetaInfoBuilder.of(metaInfo).set("delegates", delegates.toString()).setEnvironment(Environment.current()).build();
- }
- current = Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .delegating(current, mi, delegates);
- return this;
+ .contextual(mi, mapSupplier, isolationKeySupplier));
}
/**
- * Creates a {@link PropertyProvider} where all keys current 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 current the base map are reflected appropriately.
- * Keys not existing in the {@code mainMap}, but present in {@code replacementMao} will be hidden.
+ * Replaces all keys in the current provider by the given map.
*
* @param replacementMap the map instance, that will replace all corresponding entries in {@code mainMap}, not null.
* @return the new delegating instance.
@@ -440,13 +430,17 @@ public final class PropertyProviderBuilder {
mi = MetaInfoBuilder.of(metaInfo).setEnvironment(Environment.current()).build();
}
current = Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
- .replacing(current, mi, replacementMap);
+ .replacing(mi, current, replacementMap);
return this;
}
+ /**
+ * Build a new property provider based on the input.
+ * @return a new property provider, or null.
+ */
public PropertyProvider build() {
if (current != null) {
- return current;
+ return current; // TODO add meta info here...
}
return Optional.of(spi).orElseThrow(() -> new IllegalStateException("No PropertyProvidersSingletonSpi available."))
.empty(metaInfo);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/api/src/main/java/org/apache/tamaya/spi/PropertyProviderBuilderSpi.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/spi/PropertyProviderBuilderSpi.java b/api/src/main/java/org/apache/tamaya/spi/PropertyProviderBuilderSpi.java
index c72bfee..4c1a844 100644
--- a/api/src/main/java/org/apache/tamaya/spi/PropertyProviderBuilderSpi.java
+++ b/api/src/main/java/org/apache/tamaya/spi/PropertyProviderBuilderSpi.java
@@ -22,7 +22,9 @@ import org.apache.tamaya.AggregationPolicy;
import org.apache.tamaya.MetaInfo;
import org.apache.tamaya.PropertyProvider;
+import java.io.InputStream;
import java.net.URI;
+import java.net.URL;
import java.util.*;
import java.util.function.Predicate;
import java.util.function.Supplier;
@@ -61,7 +63,7 @@ public interface PropertyProviderBuilderSpi {
* @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);
+ PropertyProvider fromPaths(MetaInfo metaInfo, AggregationPolicy aggregationPolicy, List<String> paths);
/**
@@ -69,10 +71,10 @@ public interface PropertyProviderBuilderSpi {
* 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.
+ * @param urls the urls 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);
+ PropertyProvider fromURLs(MetaInfo metaInfo, AggregationPolicy aggregationPolicy, List<URL> urls);
/**
* Get an empty and immutable PropertyProvider instance. The meta-information contains the given String
@@ -83,14 +85,6 @@ public interface PropertyProviderBuilderSpi {
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.
@@ -120,7 +114,7 @@ public interface PropertyProviderBuilderSpi {
* @param propertyMaps the maps to be included, not null.
* @return the aggregated instance containing all given maps.
*/
- PropertyProvider aggregate(AggregationPolicy policy, MetaInfo metaInfo, List<PropertyProvider> propertyMaps);
+ PropertyProvider aggregate(MetaInfo metaInfo, AggregationPolicy policy, List<PropertyProvider> propertyMaps);
/**
* Creates a new {@link org.apache.tamaya.PropertyProvider} that is mutable by adding a map based instance that overrides
@@ -138,7 +132,7 @@ public interface PropertyProviderBuilderSpi {
* @param propertyMaps the maps to be included, not null.
* @return the intersecting instance containing all given maps.
*/
- PropertyProvider intersected(AggregationPolicy policy, MetaInfo metaInfo, List<PropertyProvider> propertyMaps);
+ PropertyProvider intersected(MetaInfo metaInfo, AggregationPolicy policy, List<PropertyProvider> propertyMaps);
/**
* Creates a new {@link org.apache.tamaya.PropertyProvider} containing only properties fromMap the target instance, that are not contained
@@ -149,7 +143,7 @@ public interface PropertyProviderBuilderSpi {
* @param subtrahendSets the maps to be subtracted, not null.
* @return the intersecting instance containing all given maps.
*/
- PropertyProvider subtracted(PropertyProvider target, MetaInfo metaInfo, List<PropertyProvider> subtrahendSets);
+ PropertyProvider subtracted(MetaInfo metaInfo, PropertyProvider target, List<PropertyProvider> subtrahendSets);
/**
@@ -161,7 +155,7 @@ public interface PropertyProviderBuilderSpi {
* @param filter the filtger to be applied, not null.
* @return the new filtering instance.
*/
- PropertyProvider filtered(Predicate<String> filter, MetaInfo metaInfo, PropertyProvider propertyMap);
+ PropertyProvider filtered(MetaInfo metaInfo, Predicate<String> filter, PropertyProvider propertyMap);
/**
* Creates a new contextual {@link org.apache.tamaya.PropertyProvider}. Contextual maps delegate to different instances current PropertyMap depending
@@ -170,7 +164,7 @@ public interface PropertyProviderBuilderSpi {
* @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,MetaInfo metaInfo,
+ PropertyProvider contextual(MetaInfo metaInfo, Supplier<PropertyProvider> mapSupplier,
Supplier<String> isolationKeySupplier);
@@ -183,7 +177,7 @@ public interface PropertyProviderBuilderSpi {
* @param parentMap the delegated parent map instance, not null.
* @return the new delegating instance.
*/
- PropertyProvider delegating(PropertyProvider mainMap, MetaInfo metaInfo, Map<String, String> parentMap);
+ PropertyProvider delegating(MetaInfo metaInfo, PropertyProvider mainMap, Map<String, String> parentMap);
/**
* Creates a {@link PropertyProvider} where all keys current a current map,
@@ -199,5 +193,5 @@ public interface PropertyProviderBuilderSpi {
* @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, MetaInfo metaInfo, Map<String, String> replacementMap);
+ PropertyProvider replacing(MetaInfo metaInfo, PropertyProvider mainMap, Map<String, String> replacementMap);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/EnvironmentSelector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/EnvironmentSelector.java b/core/src/main/java/org/apache/tamaya/core/EnvironmentSelector.java
new file mode 100644
index 0000000..aa535e1
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/EnvironmentSelector.java
@@ -0,0 +1,47 @@
+/*
+ * 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;
+
+
+import org.apache.tamaya.Environment;
+
+/**
+ * The selector is responsible for determining if a configuration should be
+ * included into the current configuration aggregate for a given runtime
+ * {@link org.apache.tamaya.Environment}.
+ */
+@FunctionalInterface
+public interface EnvironmentSelector {
+
+ /**
+ * Selector INSTANCE that selects every environment.
+ */
+ public static final EnvironmentSelector ANY = configurationContext -> true;
+
+ /**
+ * Method that evaluates if a concrete environment is matching the
+ * constraints current this selector.
+ *
+ * @param configurationContext
+ * The environment, not {@code null}.
+ * @return {@code true} if the environment is selected.
+ */
+ public boolean isMatching(Environment configurationContext);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/config/ConfigLocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/ConfigLocation.java b/core/src/main/java/org/apache/tamaya/core/config/ConfigLocation.java
deleted file mode 100644
index d64561f..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/ConfigLocation.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import java.io.Serializable;
-
-/**
- * This class models a configuration location as an immutable value type. Hereby
- * the location defines
- * <ul>
- * <li>the <b>reader</b>, identified by the unique readerId, which implements
- * the mechanism, how configuration is read.
- * <li>the <b>location</b> configures the reader, what resources to read.
- * </ul>
- */
-public final class ConfigLocation implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private String readerId;
- private String locationId;
-
- public ConfigLocation(String readerId, String locationId) {
- if (readerId == null) {
- throw new NullPointerException("readerID null.");
- }
- if (locationId == null) {
- throw new NullPointerException("locationId null.");
- }
- this.readerId = readerId;
- this.locationId = locationId;
- }
-
- /**
- * @return the readerId
- */
- public final String getReaderId() {
- return readerId;
- }
-
- /**
- * @return the locationId
- */
- public final String getLocationId() {
- return locationId;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((locationId == null) ? 0 : locationId.hashCode());
- result = prime * result
- + ((readerId == null) ? 0 : readerId.hashCode());
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ConfigLocation other = (ConfigLocation) obj;
- if (locationId == null) {
- if (other.locationId != null)
- return false;
- } else if (!locationId.equals(other.locationId))
- return false;
- if (readerId == null) {
- if (other.readerId != null)
- return false;
- } else if (!readerId.equals(other.readerId))
- return false;
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "ConfigLocation [readerId=" + readerId + ", locationId="
- + locationId + "]";
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/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
deleted file mode 100644
index 519a9a9..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.*;
-import org.apache.tamaya.core.spi.ResourceLoader;
-
-import org.apache.tamaya.spi.Bootstrap;
-import java.net.URI;
-import java.util.*;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-/**
- * Created by Anatole on 06.09.2014.
- */
-public final class ConfigurationBuilder{
-
- private ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- private Predicate<URI> ignoredSourcesPredicate;
- private List<URI> sources = new ArrayList<>();
- private String configId;
- private Map<String,String> data = new HashMap<>();
- private MetaInfo metaInfo;
- private List<ConfigMapAddition> addedMaps = new ArrayList<>();
-
-
- public static final ConfigurationBuilder of(String configId){
- return of(configId, null);
- }
-
- public static final ConfigurationBuilder of(String configId, ClassLoader classLoader){
- return new ConfigurationBuilder(configId, classLoader);
- }
-
- private ConfigurationBuilder(String configId, ClassLoader classLoader){
- Objects.requireNonNull(configId);
- this.configId = configId;
- if(classLoader == null){
- classLoader = getClass().getClassLoader();
- }
- }
-
- public ConfigurationBuilder put(String key, String value){
- this.data.put(key, value);
- return this;
- }
-
- public ConfigurationBuilder setMetainfo(MetaInfo metaInfo){
- this.metaInfo = metaInfo;
- return this;
- }
-
- public ConfigurationBuilder setMetainfo(String key, String metaInfo){
- this.data.put(key + ".metainfo", metaInfo);
- return this;
- }
-
- public ConfigurationBuilder putAll(Map<String,String> data){
- Objects.requireNonNull(data);
- this.data.putAll(data);
- return this;
- }
-
- public ConfigurationBuilder addResources(String... sources){
- this.sources.addAll(Bootstrap.getService(ResourceLoader.class).getResources(classLoader, sources));
- return this;
- }
-
- public ConfigurationBuilder addResources(Collection<String> sources){
- this.sources.addAll(Bootstrap.getService(ResourceLoader.class).getResources(classLoader, sources));
- return this;
- }
-
- public ConfigurationBuilder setIgnoredSourcesFilter(Predicate<String> sourceFilter){
- return this;
- }
-
- public ConfigurationBuilder setClassLoader(ClassLoader classLoader){
- Objects.requireNonNull(classLoader);
- this.classLoader = classLoader;
- return this;
- }
-
- public Configuration build(){
- Stream<URI> sourcesToRead = sources.parallelStream();
- if(ignoredSourcesPredicate != null){
- sourcesToRead = sourcesToRead.filter(ignoredSourcesPredicate);
- }
- if(metaInfo == null){
- metaInfo = MetaInfoBuilder.of(this.configId).setTimestamp(System.currentTimeMillis()).setName(this.configId)
- .build();
- }else{
- metaInfo = MetaInfoBuilder.of(this.metaInfo).setTimestamp(System.currentTimeMillis()).setName(this.configId)
- .build();
- }
- PropertyProvider prov = PropertyProviders.fromUris(metaInfo, sourcesToRead.collect(Collectors.toList()));
- if(!this.data.isEmpty()){
- 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.aggregate(addition.policy, newMaps);
- }
- final PropertyProvider finalProvider = prov;
- return new MapConfiguration(metaInfo, () -> finalProvider.toMap());
- }
-
- public ConfigurationBuilder addConfigMaps(AggregationPolicy override, PropertyProvider... configMaps){
- ConfigMapAddition maps = new ConfigMapAddition(override, configMaps);
- this.addedMaps.add(maps);
- return this;
- }
-
- private static final class ConfigMapAddition{
- AggregationPolicy policy;
- PropertyProvider[] configMaps;
-
- public ConfigMapAddition(AggregationPolicy policy, PropertyProvider[] configMaps){
- Objects.requireNonNull(policy, "AggregationPolicy");
- Objects.requireNonNull(configMaps, "ConfigMaps");
- for(PropertyProvider map : configMaps){
- Objects.requireNonNull(map, "A contained ConfigMap is null.");
- }
- this.policy = policy;
- this.configMaps = configMaps.clone();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/config/ConfigurationDecorator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationDecorator.java b/core/src/main/java/org/apache/tamaya/core/config/ConfigurationDecorator.java
deleted file mode 100644
index 3e639d4..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationDecorator.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.*;
-import org.apache.tamaya.core.spi.AdapterProviderSpi;
-import org.apache.tamaya.spi.Bootstrap;
-
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-/**
- * Decorator that adds {@link org.apache.tamaya.Configuration} capabilities to
- * a given {@link org.apache.tamaya.PropertyProvider} instance.
- */
-public class ConfigurationDecorator extends AbstractConfiguration{
-
- private static final long serialVersionUID = 503764580971917964L;
-
- /** The underlying property provider. */
- private PropertyProvider provider;
- /** Lock for applying changes. */
- private final Object LOCK = new Object();
-
- /**
- * Constructor.
- * @param provider The underlying property provider, not null.
- */
- protected ConfigurationDecorator(PropertyProvider provider){
- super(provider.getMetaInfo());
- this.provider = Objects.requireNonNull(provider);
- }
-
-
- @Override
- public <T> Optional<T> get(String key, Class<T> type){
- AdapterProviderSpi as = Bootstrap.getService(AdapterProviderSpi.class);
- PropertyAdapter<T> adapter = as.getAdapter(type);
- if(adapter == null){
- throw new ConfigException(
- "Can not adapt config property '" + key + "' to " + type.getName() + ": no such " +
- "adapter.");
- }
- return getAdapted(key, adapter);
- }
-
- @Override
- public Optional<String> get(String key) {
- return provider.get(key);
- }
-
- @Override
- public boolean containsKey(String key) {
- return provider.containsKey(key);
- }
-
- @Override
- public Map<String, String> toMap() {
- return provider.toMap();
- }
-
- @Override
- public MetaInfo getMetaInfo() {
- return provider.getMetaInfo();
- }
-
- @Override
- protected ConfigChangeSet reload() {
- return provider.load();
- }
-
- @Override
- public void apply(ConfigChangeSet change) {
- Configuration oldState;
- Configuration newState;
- synchronized(LOCK) {
- oldState = FreezedConfiguration.of(this);
- provider.apply(change);
- newState = FreezedConfiguration.of(this);
- if(oldState.hasSameProperties(newState)){
- return;
- }
- }
- publishPropertyChangeEvents(ConfigChangeSetBuilder.of(oldState).addChanges(newState).build().getEvents());
- }
-
- @Override
- public String toString(){
- return "ConfigurationDecorator(provider="+this.provider+")";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/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 68937cf..4e6e772 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
@@ -20,11 +20,12 @@ package org.apache.tamaya.core.config;
import org.apache.tamaya.ConfigException;
import org.apache.tamaya.core.internal.format.DefaultConfigFormatsSingletonSpi;
+import org.apache.tamaya.core.resource.Resource;
import org.apache.tamaya.core.spi.ConfigurationFormat;
import org.apache.tamaya.core.spi.ConfigurationFormatsSingletonSpi;
import org.apache.tamaya.spi.Bootstrap;
-import java.net.URI;
+
import java.util.Collection;
import java.util.Optional;
@@ -88,7 +89,7 @@ public final class ConfigurationFormats{
* @param resource The resource
* @return a matching configuration format, or {@code null} if no matching format could be determined.
*/
- public static ConfigurationFormat getFormat(URI resource){
+ public static ConfigurationFormat getFormat(Resource resource){
return Optional.ofNullable(spi)
.orElseThrow(() -> new ConfigException("No ConfigurationFormatsSingletonSpi loaded."))
.getFormat(resource);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/config/ConfigurationProducer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationProducer.java b/core/src/main/java/org/apache/tamaya/core/config/ConfigurationProducer.java
deleted file mode 100644
index d89847f..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationProducer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.Configuration;
-import java.util.*;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-
-/**
-* Created by Anatole on 06.09.2014.
-*/
-final class ConfigurationProducer implements Supplier<Configuration>{
-
- private ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- private Predicate<String> ignoredSourcesFilter;
- private List<String> resources = new ArrayList<>();
- private String configId;
-
- ConfigurationProducer(ConfigurationProducerBuilder producerBuilder) {
- Objects.requireNonNull(producerBuilder);
- this.configId = producerBuilder.configId;
- this.classLoader = producerBuilder.classLoader;
- this.ignoredSourcesFilter = producerBuilder.ignoredSourcesFilter;
- this.resources.addAll(producerBuilder.resources);
- }
-
-
- public Configuration get() {
- ConfigurationBuilder builder = ConfigurationBuilder.of(configId);
- if(ignoredSourcesFilter!=null){
- builder.setIgnoredSourcesFilter(ignoredSourcesFilter);
- }
- builder.addResources(resources);
- if(classLoader!=null){
- builder.setClassLoader(classLoader);
- }
- return builder.build();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/config/ConfigurationProducerBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationProducerBuilder.java b/core/src/main/java/org/apache/tamaya/core/config/ConfigurationProducerBuilder.java
deleted file mode 100644
index 1752623..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/ConfigurationProducerBuilder.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.core.spi.ConfigurationFormat;
-
-import org.apache.tamaya.Configuration;
-import java.util.*;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.stream.Stream;
-
-/**
-* Created by Anatole on 06.09.2014.
-*/
-public final class ConfigurationProducerBuilder{
-
- ClassLoader classLoader;
- Predicate<String> ignoredSourcesFilter;
- List<String> resources = new ArrayList<>();
- List<ConfigurationFormat> privateFormats = new ArrayList<>();
- String configId;
-
- private ConfigurationProducerBuilder(String configId, ClassLoader classLoader) {
- Objects.requireNonNull(configId);
- this.configId = configId;
- if(classLoader==null){
- classLoader = getClass().getClassLoader();
- }
- }
-
- public static final ConfigurationProducerBuilder of(String configName) {
- return new ConfigurationProducerBuilder(configName, null);
- }
-
- public static final ConfigurationProducerBuilder of(String configName, ClassLoader classLoader) {
- return new ConfigurationProducerBuilder(configName, null);
- }
-
- public ConfigurationProducerBuilder addResources(String... resources){
- this.resources.addAll(Arrays.asList(resources));
- return this;
- }
-
- public ConfigurationProducerBuilder setClassLoader(ClassLoader classLoader){
- this.classLoader = classLoader;
- return this;
- }
-
-
- public ConfigurationProducerBuilder addResources(Stream<String> resources){
- resources.forEach(this.resources::add);
- return this;
- }
-
- public ConfigurationProducerBuilder addPrivateFormats(ConfigurationFormat... formats){
- this.privateFormats.addAll(Arrays.asList(formats));
- return this;
- }
-
- @SafeVarargs
- public final ConfigurationProducerBuilder addPrivateFormats(Iterable<ConfigurationFormat>... formats){
- for(Iterable<ConfigurationFormat> it: formats){
- for (ConfigurationFormat anIt : it) {
- this.privateFormats.add(anIt);
- }
- }
- return this;
- }
-
- public ConfigurationProducerBuilder setIgnoredSourcesFilter(Predicate<String> sourceFilter){
- return this;
- }
-
- public Supplier<Configuration> build() {
- return new ConfigurationProducer(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/config/Configurations.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/Configurations.java b/core/src/main/java/org/apache/tamaya/core/config/Configurations.java
deleted file mode 100644
index 80f9561..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/Configurations.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.PropertyProvider;
-
-import java.util.Map;
-import java.util.function.Supplier;
-
-/**
- * Created by Anatole on 21.10.2014.
- */
-public final class Configurations {
-
- private Configurations(){}
-
- public static Configuration getConfiguration(MetaInfo metaInfo, Supplier<Map<String,String>> mapSupplier){
- return new MapConfiguration(metaInfo, mapSupplier);
- }
-
- public static Configuration getConfiguration(PropertyProvider provider){
- return new ConfigurationDecorator(provider);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/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
deleted file mode 100644
index 3628a4f..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/EnvPropertiesConfigProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.AggregationPolicy;
-import org.apache.tamaya.PropertyProviders;
-import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
-
-import org.apache.tamaya.Configuration;
-
-/**
- * Provides a {@link org.apache.tamaya.Configuration} named 'environment.properties'
- * containing the current environment properties.
- *
- * Created by Anatole on 29.09.2014.
- */
-public class EnvPropertiesConfigProvider implements ConfigurationProviderSpi{
-
- private Configuration envConfig;
-
- public EnvPropertiesConfigProvider(){
- envConfig = ConfigurationBuilder.of("environment.properties").addConfigMaps(AggregationPolicy.OVERRIDE(),
- PropertyProviders.fromEnvironmentProperties()).build();
- }
-
- @Override
- public String getConfigName(){
- return "environment.properties";
- }
-
- @Override
- public Configuration getConfiguration(){
- return envConfig;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/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 b94383a..5830540 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
@@ -37,11 +37,14 @@ final class FreezedConfiguration extends AbstractConfiguration implements Serial
private FreezedConfiguration(Configuration config){
super(MetaInfoBuilder.of(config.getMetaInfo()).set("freezedAt", Instant.now().toString()).build());
- this.properties = PropertyProviders.freezed(config);
+ this.properties = PropertyProviderBuilder.create(config).freeze();
this.version = Objects.requireNonNull(config.getVersion());
}
- public static final FreezedConfiguration of(Configuration config){
+ public static final Configuration of(Configuration config){
+ if(config instanceof FreezedConfiguration){
+ return config;
+ }
return new FreezedConfiguration(config);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/config/MapConfiguration.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/MapConfiguration.java b/core/src/main/java/org/apache/tamaya/core/config/MapConfiguration.java
deleted file mode 100644
index e00fafa..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/MapConfiguration.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.MetaInfo;
-
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.Supplier;
-
-
-class MapConfiguration extends AbstractConfiguration {
-
- private static final long serialVersionUID = 707575538680740130L;
- private Supplier<Map<String,String>> mapSupplier;
-
- public MapConfiguration(MetaInfo metaInfo, Supplier<Map<String,String>> mapSupplier) {
- super(metaInfo);
- Objects.requireNonNull(mapSupplier);
- this.mapSupplier = mapSupplier;
- }
-
- @Override
- public Map<String,String> toMap(){
- return mapSupplier.get();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/config/MetaInfoEditor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/MetaInfoEditor.java b/core/src/main/java/org/apache/tamaya/core/config/MetaInfoEditor.java
deleted file mode 100644
index 8d3a270..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/MetaInfoEditor.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.core.spi.ConfigurationFormat;
-
-import org.apache.tamaya.Environment;
-import java.net.URI;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-
-public final class MetaInfoEditor{
-
- public static final String METAINFO = "_metainfo";
- public static final String TIMESTAMP = "timestamp";
- public static final String CONTEXT = "context";
- public static final String NAME = "name";
- public static final String SOURCE = "source";
- public static final String FORMAT = "format";
- public static final String ENVIRONMENT = "environment";
- public static final String SOURCE_EXPRESSION = "source-expression";
-
- private Map<String,String> map = new ConcurrentHashMap<>();
-
- private MetaInfoEditor(String metaInfo){
- // TODO parse
- }
-
- public static MetaInfoEditor of(String metaInfo){
- return new MetaInfoEditor(metaInfo);
- }
-
- public static MetaInfoEditor of(){
- return new MetaInfoEditor(null);
- }
-
- public MetaInfoEditor withName(String name){
- Objects.requireNonNull(name);
- map.put(NAME, name);
- return this;
- }
-
- public MetaInfoEditor withSource(String source){
- Objects.requireNonNull(source);
- map.put(SOURCE, source);
- return this;
- }
-
- public static Map<String, String> setMetaInfo(Map<String, String> targetMap, String key, String metaInfo){
- Objects.requireNonNull(metaInfo);
- Objects.requireNonNull(key);
- Objects.requireNonNull(targetMap);
- targetMap.put(key + '.' + METAINFO, metaInfo);
- return targetMap;
- }
-
- public static Map<String, String> setMetaInfo(Map<String, String> targetMap, String metaInfo){
- if(metaInfo!=null){
- Objects.requireNonNull(metaInfo);
- Objects.requireNonNull(targetMap);
- targetMap.put(METAINFO, metaInfo);
- }
- return targetMap;
- }
-
- public MetaInfoEditor withSource(URI source){
- Objects.requireNonNull(source);
- map.put(SOURCE, source.toString());
- return this;
- }
-
- public MetaInfoEditor withSourceExpression(String sourceExpression){
- Objects.requireNonNull(sourceExpression);
- map.put(SOURCE_EXPRESSION, sourceExpression);
- return this;
- }
-
- public MetaInfoEditor withTimestamp(long timestamp){
- map.put(TIMESTAMP, String.valueOf(timestamp));
- return this;
- }
-
- public MetaInfoEditor withContext(String context){
- Objects.requireNonNull(context);
- map.put(CONTEXT, context);
- return this;
- }
-
- public MetaInfoEditor withFormat(ConfigurationFormat format){
- Objects.requireNonNull(format);
- map.put(FORMAT, format.getClass().getName());
- return this;
- }
-
- public MetaInfoEditor withEnvironment(Environment configurationContext){
- Objects.requireNonNull(configurationContext);
- map.put(ENVIRONMENT, configurationContext.toString());
- return this;
- }
-
- public String build(){
- StringBuilder r = new StringBuilder("METADATA[");
- for(Map.Entry<String,String> en:map.entrySet()){
- r.append(escape(en.getKey())).append('=').append(escape(en.getValue())).append(", ");
- }
- if(!map.isEmpty()){
- r.setLength(r.length()-2);
- }
- r.append(']');
- return r.toString();
- }
-
- private String escape(String val){
- return val.replaceAll("=", "\\\\=").replaceAll("[", "\\\\[").replaceAll("]", "\\\\]").replaceAll(",", "\\\\,");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/config/PropertyChangeConsumer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/PropertyChangeConsumer.java b/core/src/main/java/org/apache/tamaya/core/config/PropertyChangeConsumer.java
deleted file mode 100644
index e339675..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/PropertyChangeConsumer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import java.beans.PropertyChangeEvent;
-import java.util.Collection;
-import java.util.Objects;
-import java.util.function.Consumer;
-
-/**
- * Simple interface to be implemented by components that can be used for handling changes done
- * on a {@link org.apache.tamaya.MutablePropertyProvider} instance.
- */
-public interface PropertyChangeConsumer extends Consumer<Collection<PropertyChangeEvent>> {
-
- /**
- * Checks if the given change is accepted by this consumer.
- * @param evt the change event
- * @return true, if the event is accepted.
- * @throws java.beans.PropertyVetoException if the change is not acceptable.
- */
- void validatePropertyChange(PropertyChangeEvent evt);
-
- /**
- * Basically passes all events to the acceptPropertyChange method.
- *
- * @param events the input events
- */
- default void accept(Collection<PropertyChangeEvent> events){
- Objects.requireNonNull(events);
- events.forEach(this::validatePropertyChange);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/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
deleted file mode 100644
index cd77ca2..0000000
--- a/core/src/main/java/org/apache/tamaya/core/config/SystemPropertiesConfigProvider.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.AggregationPolicy;
-import org.apache.tamaya.PropertyProviders;
-import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
-
-import org.apache.tamaya.Configuration;
-
-/**
- * Provides a {@link org.apache.tamaya.Configuration} named 'system.properties'
- * containing the current system properties.
- *
- * Created by Anatole on 29.09.2014.
- */
-public class SystemPropertiesConfigProvider implements ConfigurationProviderSpi{
-
- private Configuration systemConfig;
-
- public SystemPropertiesConfigProvider(){
- systemConfig = ConfigurationBuilder.of("system.properties").addConfigMaps(AggregationPolicy.OVERRIDE(),
- PropertyProviders.fromSystemProperties()).build();
- }
-
- @Override
- public String getConfigName(){
- return "system.properties";
- }
-
- @Override
- public Configuration getConfiguration(){
- return systemConfig;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/env/DefaultStage.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/env/DefaultStage.java b/core/src/main/java/org/apache/tamaya/core/env/DefaultStage.java
new file mode 100644
index 0000000..d2b256f
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/env/DefaultStage.java
@@ -0,0 +1,69 @@
+/*
+ * 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.env;
+
+import org.apache.tamaya.Stage;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Simple default implementation current a stage.
+ * Created by Anatole on 12.11.2014.
+ */
+final class DefaultStage implements Stage, Serializable{
+ /** The stage's name. */
+ private final String name;
+ /** The stage's properites. */
+ private final Map<String,String> properties;
+
+ /**
+ * Creates a new stage.
+ * @param name the name, not null.
+ * @param properties the properties, not null.
+ */
+ DefaultStage(String name, Map<String,String> properties){
+ this.name = Objects.requireNonNull(name);
+ Map<String,String> tempProps = new HashMap<>(properties);
+ tempProps = Collections.unmodifiableMap(properties);
+ this.properties = tempProps;
+ }
+
+ /**
+ * Get the stage's name.
+ * @return the stage's name, never null.
+ */
+ @Override
+ public String getName(){
+ return name;
+ }
+
+ /**
+ * Get all the stage's (unmodifiable) properties.
+ * @return the stage's (unmodifiable) properties, never null.
+ */
+ @Override
+ public Map<String,String> getProperties(){
+ return properties;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/env/EnvironmentSelector.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/env/EnvironmentSelector.java b/core/src/main/java/org/apache/tamaya/core/env/EnvironmentSelector.java
deleted file mode 100644
index d4fcdbe..0000000
--- a/core/src/main/java/org/apache/tamaya/core/env/EnvironmentSelector.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.env;
-
-
-import org.apache.tamaya.Environment;
-
-/**
- * The selector is responsible for determining if a configuration should be
- * included into the current configuration aggregate for a given runtime
- * {@link org.apache.tamaya.Environment}.
- */
-@FunctionalInterface
-public interface EnvironmentSelector {
-
- /**
- * Selector INSTANCE that selects every environment.
- */
- public static final EnvironmentSelector ANY = configurationContext -> true;
-
- /**
- * Method that evaluates if a concrete environment is matching the
- * constraints current this selector.
- *
- * @param configurationContext
- * The environment, not {@code null}.
- * @return {@code true} if the environment is selected.
- */
- public boolean isMatching(Environment configurationContext);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0eef8f37/core/src/main/java/org/apache/tamaya/core/env/StageBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/env/StageBuilder.java b/core/src/main/java/org/apache/tamaya/core/env/StageBuilder.java
new file mode 100644
index 0000000..16f7884
--- /dev/null
+++ b/core/src/main/java/org/apache/tamaya/core/env/StageBuilder.java
@@ -0,0 +1,81 @@
+/*
+ * 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.env;
+
+import org.apache.tamaya.Stage;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * Builder for creating new stages. Instances current this class are not thread safe.
+ * Created by Anatole on 12.11.2014.
+ */
+public final class StageBuilder {
+
+ private String name;
+ private Map<String,String> properties = new HashMap<>();
+
+ /**
+ * Constructor.
+ * @param name the required stage's name, not null.
+ */
+ private StageBuilder(String name){
+ this.name = Objects.requireNonNull(name);
+ }
+
+ /**
+ * Creates a new builder instance.
+ * @param name the stage's name, not null.
+ * @return the new builder, never null.
+ */
+ public static StageBuilder create(String name){
+ return new StageBuilder(name);
+ }
+
+ /**
+ * Adds all the given properties to the stage, existing properties, will be replaced.
+ * @param properties the properties, not null.
+ * @return the builder for chaining.
+ */
+ public StageBuilder setProperties(Map<String,String> properties){
+ this.properties.putAll(properties);
+ return this;
+ }
+
+ /**
+ * Sets a property for the stage, any existing property value will be overriden.
+ * @param key the property key, not null.
+ * @param value the property value, not null.
+ * @return the builder for chaining.
+ */
+ public StageBuilder setProperty(String key, String value){
+ this.properties.put(key, value);
+ return this;
+ }
+
+ /**
+ * Creates a new Stage instance.
+ * @return a new Stage, never null.
+ */
+ public Stage build(){
+ return new DefaultStage(name, properties);
+ }
+}