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:45 UTC
[2/8] incubator-tamaya git commit: TAMAYA-14: added resource support.
TAMAYA-15: Moved PropertyProviders to API,
added SPI. TAMAYA-8: Added/improved Javadoc.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/FilteredPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/FilteredPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/FilteredPropertyProvider.java
deleted file mode 100644
index bf6c9e2..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/FilteredPropertyProvider.java
+++ /dev/null
@@ -1,71 +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.properties;
-
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.PropertyProvider;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.Predicate;
-
-class FilteredPropertyProvider extends AbstractPropertyProvider{
-
- private static final long serialVersionUID = 4301042530074932562L;
- private PropertyProvider unit;
- private Predicate<String> filter;
-
- public FilteredPropertyProvider(PropertyProvider configuration, Predicate<String> filter){
- super(MetaInfoBuilder.of(configuration.getMetaInfo()).setType("filtered").set("filter", filter.toString()).build());
- Objects.requireNonNull(configuration);
- this.unit = configuration;
- this.filter = filter;
- }
-
- @Override
- public Map<String,String> toMap(){
- final Map<String,String> result = new HashMap<>();
- this.unit.toMap().entrySet().forEach(e -> {
- if(filter.test(e.getKey())){
- result.put(e.getKey(), e.getValue());
- }
- });
- return result;
- }
-
- @Override
- public ConfigChangeSet load(){
- unit.load();
- return super.load();
- }
-
- /**
- * 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){
- this.unit.apply(change);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/FreezedPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/FreezedPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/FreezedPropertyProvider.java
deleted file mode 100644
index 83b230e..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/FreezedPropertyProvider.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.properties;
-
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.PropertyProvider;
-
-import java.io.Serializable;
-import java.time.Instant;
-import java.util.*;
-
-/**
- * This class models a freezed instance of an {@link org.apache.tamaya.PropertyProvider}.
- * Created by Anatole on 28.03.14.
- */
-final class FreezedPropertyProvider implements PropertyProvider, Serializable{
-
- private static final long serialVersionUID = 3365413090311267088L;
- private Map<String,Map<String,String>> fieldMMetaInfo = new HashMap<>();
- private MetaInfo metaInfo;
- private Map<String,String> properties = new HashMap<>();
-
- private FreezedPropertyProvider(PropertyProvider propertyMap){
- Map<String,String> map = propertyMap.toMap();
- this.properties.putAll(map);
- this.properties = Collections.unmodifiableMap(this.properties);
- this.metaInfo =
- MetaInfoBuilder.of(propertyMap.getMetaInfo()).set("freezedAt", Instant.now().toString()).build();
- }
-
- public static PropertyProvider of(PropertyProvider propertyProvider){
- if(propertyProvider instanceof FreezedPropertyProvider){
- return propertyProvider;
- }
- return new FreezedPropertyProvider(propertyProvider);
- }
-
- @Override
- public ConfigChangeSet load(){
- return ConfigChangeSet.emptyChangeSet(this);
- }
-
- public int size(){
- return properties.size();
- }
-
- public boolean isEmpty(){
- return properties.isEmpty();
- }
-
- @Override
- public boolean containsKey(String key){
- return properties.containsKey(key);
- }
-
- @Override
- public Map<String,String> toMap(){
- return Collections.unmodifiableMap(this.properties);
- }
-
- @Override
- public MetaInfo getMetaInfo(){
- return this.metaInfo;
- }
-
- @Override
- public Optional<String> get(String key){
- return Optional.ofNullable(properties.get(key));
- }
-
- @Override
- public Set<String> keySet(){
- return properties.keySet();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/IntersectingPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/IntersectingPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/IntersectingPropertyProvider.java
deleted file mode 100644
index 6f98a4b..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/IntersectingPropertyProvider.java
+++ /dev/null
@@ -1,76 +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.properties;
-
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.PropertyProvider;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * Created by Anatole on 22.10.2014.
- */
-class IntersectingPropertyProvider extends AbstractPropertyProvider {
-
- private Collection<PropertyProvider> providers;
- private PropertyProvider union;
-
- public IntersectingPropertyProvider(AggregationPolicy policy, PropertyProvider... providers) {
- super(MetaInfoBuilder.of().setType("intersection").set("providers", Arrays.toString(providers)).build());
- this.providers = Arrays.asList(Objects.requireNonNull(providers));
- union = PropertyProviders.union(policy, providers);
- }
-
- public IntersectingPropertyProvider(MetaInfo metaInfo, AggregationPolicy policy, PropertyProvider... providers) {
- super(metaInfo);
- this.providers = Arrays.asList(Objects.requireNonNull(providers));
- union = PropertyProviders.union(policy, providers);
- }
-
-
- @Override
- public Optional<String> get(String key) {
- if (containsKey(key))
- return union.get(key);
- return Optional.empty();
- }
-
- private boolean filter(Map.Entry<String, String> entry) {
- return containsKey(entry.getKey());
- }
-
- @Override
- public boolean containsKey(String key) {
- for (PropertyProvider prov : this.providers) {
- if (!prov.containsKey(key)) {
- return false;
- }
- }
- return true;
- }
-
- @Override
- public Map<String, String> toMap() {
- return union.toMap().entrySet().stream().filter(en -> containsKey(en.getKey())).collect(
- Collectors.toConcurrentMap(en -> en.getKey(), en -> en.getValue()));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProvider.java
deleted file mode 100644
index 83ba5bb..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProvider.java
+++ /dev/null
@@ -1,106 +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.properties;
-
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-
-import java.beans.PropertyChangeEvent;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
-
-/**
- * Models a {@link org.apache.tamaya.PropertyProvider} that can be build using a builder pattern.
- */
-class MapBasedPropertyProvider extends AbstractPropertyProvider{
-
- private static final long serialVersionUID = 7601389831472839249L;
-
- private static final Logger LOG = Logger.getLogger(MapBasedPropertyProvider.class.getName());
- /**
- * The unit's entries.
- */
- private Map<String,String> entries = new ConcurrentHashMap<>();
-
- /**
- * Constructor used by {@link MapBasedPropertyProviderBuilder}, or subclasses.
- *
- * @param entries the config entries, not null.
- */
- MapBasedPropertyProvider(MetaInfo metaInfo, Map<String,String> entries){
- super(metaInfo);
- Objects.requireNonNull(entries, "entries required.");
- this.entries.putAll(entries);
- }
-
-
- /**
- * Constructor used by {@link MapBasedPropertyProviderBuilder}, or subclasses.
- *
- * @param entries the entries
- * @param sources the sources
- * @param errors the errors
- */
- MapBasedPropertyProvider(MetaInfo metaInfo, Map<String,String> entries, Set<String> sources,
- Collection<Throwable> errors){
- super(metaInfo);
- Objects.requireNonNull(entries, "entries required.");
- this.entries.putAll(entries);
- addSources(sources);
- }
-
- MapBasedPropertyProvider(MetaInfo metaInfo, Set<String> sources){
- super(metaInfo);
- addSources(sources);
- }
-
- @Override
- public Map<String, String> toMap() {
- return new HashMap<>(this.entries);
- }
-
- @Override
- public ConfigChangeSet load(){
- // Can not reload...
- return ConfigChangeSet.emptyChangeSet(this);
- }
-
- /**
- * 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){
- change.getEvents().forEach(this::applyChange);
- }
-
- private void applyChange(PropertyChangeEvent propertyChangeEvent) {
- LOG.finest(() -> "Applying change to map provider: " + propertyChangeEvent);
- if(propertyChangeEvent.getNewValue()==null){
- this.entries.remove(propertyChangeEvent.getPropertyName());
- }
- else{
- this.entries.put(propertyChangeEvent.getPropertyName(), propertyChangeEvent.getNewValue().toString());
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProviderBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProviderBuilder.java b/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProviderBuilder.java
index 38c41bd..ec67721 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProviderBuilder.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/MapBasedPropertyProviderBuilder.java
@@ -21,11 +21,13 @@ package org.apache.tamaya.core.properties;
import org.apache.tamaya.MetaInfo;
import org.apache.tamaya.MetaInfoBuilder;
import org.apache.tamaya.PropertyProvider;
+import org.apache.tamaya.PropertyProviders;
+
import java.util.*;
/**
* Builder class for creating a new instance of
- * {@link MapBasedPropertyProvider}-
+ * {@link org.apache.tamaya.core.internal.MapBasedPropertyProvider}-
*/
public final class MapBasedPropertyProviderBuilder {
protected MetaInfoBuilder metaInfoBuilder = MetaInfoBuilder.of();
@@ -106,8 +108,8 @@ public final class MapBasedPropertyProviderBuilder {
}
public PropertyProvider build(){
- MetaInfo finalMetaInfo = metaInfoBuilder.setTimestamp(configReadDT).build();
- return new MapBasedPropertyProvider(finalMetaInfo, entries);
+ MetaInfo metaInfo = metaInfoBuilder.setTimestamp(configReadDT).build();
+ return PropertyProviders.fromMap(metaInfo, entries);
}
/*
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/PathBasedPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/PathBasedPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/PathBasedPropertyProvider.java
deleted file mode 100644
index b929c30..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/PathBasedPropertyProvider.java
+++ /dev/null
@@ -1,74 +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.properties;
-
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.PropertyProvider;
-import org.apache.tamaya.core.config.ConfigurationFormats;
-import org.apache.tamaya.spi.Bootstrap;
-import org.apache.tamaya.core.spi.ConfigurationFormat;
-import org.apache.tamaya.core.spi.ResourceLoader;
-
-import java.net.URI;
-import java.util.*;
-
-/**
- * Created by Anatole on 16.10.2014.
- */
-final class PathBasedPropertyProvider extends AbstractPropertyProvider {
-
- private List<String> paths = new ArrayList<>();
- private Map<String,String> properties = new HashMap<>();
-
- public PathBasedPropertyProvider(MetaInfo metaInfo, Collection<String> paths) {
- super(metaInfo);
- Objects.requireNonNull(paths);
- this.paths.addAll(paths);
- init();
- }
-
- @Override
- public Map<String, String> toMap() {
- return this.properties;
- }
-
- private void init() {
- List<String> sources = new ArrayList<>();
- List<String> effectivePaths = new ArrayList<>();
- paths.forEach((path) -> {
- effectivePaths.add(path);
- for(URI uri : Bootstrap.getService(ResourceLoader.class).getResources(path)){
- ConfigurationFormat format = ConfigurationFormats.getFormat(uri);
- if(format != null){
- try{
- properties.putAll(format.readConfiguration(uri));
- sources.add(uri.toString());
- }
- catch(Exception e){
- e.printStackTrace();
- }
- }
- }
- });
- MetaInfoBuilder metaInfoBuilder = MetaInfoBuilder.of(getMetaInfo());
- super.metaInfo = metaInfoBuilder.setSourceExpressions(new String[effectivePaths.size()])
- .set("sources", sources.toString()).build();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/PropertyProviderManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/PropertyProviderManager.java b/core/src/main/java/org/apache/tamaya/core/properties/PropertyProviderManager.java
index d48b637..1e3d567 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/PropertyProviderManager.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/PropertyProviderManager.java
@@ -24,7 +24,7 @@ import java.util.Collection;
/**
* Service for accessing configuration. A configuration service is always base
* on the environment definition provided by one instance of
- * {@link org.apache.tamaya.core.spi.EnvironmentManagerSingletonSpi}. It is possible to define multiple
+ * {@link org.apache.tamaya.spi.EnvironmentManagerSingletonSpi}. It is possible to define multiple
* {@link org.apache.tamaya.core.properties.PropertyProviderManager} instances, if required. <h3>Implementation
* PropertyMapSpec</h3> Implementations of this interface must be
* <ul>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/PropertyProviders.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/PropertyProviders.java b/core/src/main/java/org/apache/tamaya/core/properties/PropertyProviders.java
deleted file mode 100644
index 7a8649b..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/PropertyProviders.java
+++ /dev/null
@@ -1,457 +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.properties;
-
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.PropertyProvider;
-
-import java.net.URI;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.logging.Logger;
-
-/**
- * Accessor factory for several standard {@link org.apache.tamaya.PropertyProvider} instances, usable for creating {@code Configuration}
- * parts.
- */
-public final class PropertyProviders {
-
- private static final PropertyProvider EMPTY_PROPERTYPROVIDER = from(Collections.emptyMap());
- private static final PropertyProvider ENV_PROPERTYPROVIDER = new EnvironmentPropertyProvider();
-
- private static final Logger LOG = Logger.getLogger(PropertyProviders.class.getName());
-
- /**
- * Private singleton constructor.
- */
- private PropertyProviders() {
- }
-
- /**
- * 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 fromArgs(MetaInfo.of("Built from Args"), 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) {
- Objects.requireNonNull(metaInfo);
- // TODO read the CLI with some better library, e.g. move parsing service to ext. service SPI
- Map<String, String> properties = new HashMap<>();
- for (int base = 0; base < args.length; base++) {
- if (args[base].startsWith("--")) {
- String argKey = args[base].substring(2);
- String value = "true"; // flag only
- if (base != args.length - 1) {
- if (args[base + 1].startsWith("-")) {
- base++;
- int eqIndex = argKey.indexOf('=');
- if (eqIndex > 0) {
- value = argKey.substring(eqIndex + 1);
- argKey = argKey.substring(0, eqIndex);
- }
- } else {
- value = args[base + 1];
- base += 2;
- }
- }
- properties.put(argKey, value);
- } else if (args[base].startsWith("-")) {
- String argKey = args[base].substring(1);
- String value = "true"; // flag only
- if (base != args.length - 1) {
- if (args[base + 1].startsWith("-")) {
- base++;
- int eqIndex = argKey.indexOf('=');
- if (eqIndex > 0) {
- value = argKey.substring(eqIndex + 1);
- argKey = argKey.substring(0, eqIndex);
- }
- } else {
- value = args[base + 1];
- base += 2;
- }
- }
- properties.put(argKey, value);
- }
- }
- return from(metaInfo, properties);
- }
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.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 from resources evaluated on
- * paths with lower order are overriding any duplicate values from 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.
- */
- public static PropertyProvider fromPaths(String... paths) {
- return fromPaths(MetaInfo.of("Built from Paths"), paths);
- }
-
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.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 from resources evaluated on
- * paths with lower order are overriding any duplicate values from 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.
- */
- public static PropertyProvider fromPaths(Collection<String> paths) {
- return fromPaths(MetaInfo.of("Built from Paths"), paths);
- }
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.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 from resources evaluated on
- * paths with lower order are overriding any duplicate values from 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.
- */
- public static PropertyProvider fromPaths(MetaInfo metaInfo, String... paths) {
- return fromPaths(metaInfo, Arrays.asList(paths));
- }
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.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 from resources evaluated on
- * paths with lower order are overriding any duplicate values from 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.
- */
- public static PropertyProvider fromPaths(MetaInfo metaInfo, Collection<String> paths) {
- return new PathBasedPropertyProvider(metaInfo, paths);
- }
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.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.
- */
- public static PropertyProvider fromUris(URI... uris) {
- return fromUris(MetaInfo.of("Built from URIs"), uris);
- }
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.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.
- */
- public static PropertyProvider fromUris(Collection<URI> uris) {
- return fromUris(MetaInfo.of("Built from URIs"), uris);
- }
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.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.
- */
- public static PropertyProvider fromUris(MetaInfo metaInfo, URI... uris) {
- Objects.requireNonNull(metaInfo);
- return fromUris(metaInfo, Arrays.asList(uris));
- }
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.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.
- */
- public static PropertyProvider fromUris(MetaInfo metaInfo, Collection<URI> uris) {
- return new URIBasedPropertyProvider(metaInfo, uris);
- }
-
- /**
- * Creates a new read-only {@link 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 from the Map instance passed.
- */
- public static PropertyProvider from(Map<String, String> map) {
- return from(MetaInfo.of("Built from Map"), map);
- }
-
-
- /**
- * Creates a new read-only {@link 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 from the Map instance passed.
- */
- public static PropertyProvider from(MetaInfo metaInfo, Map<String, String> map) {
- return new MapBasedPropertyProvider(metaInfo, map);
- }
-
- /**
- * Create meta information for CLI arguments passed.
- *
- * @param args the CLI arguments, not null.
- * @return the corresponding meta information.
- */
- public static MetaInfo createArgsMetaInfo(String... args) {
- MetaInfoBuilder metaBuilder = MetaInfoBuilder.of();
- return metaBuilder.setType("cli").set("args", Arrays.toString(args)).build();
- }
-
-
- /**
- * Get an empty and immutable PropertyProvider instance.
- *
- * @return an empty and immutable PropertyProvider instance, never null.
- */
- public static PropertyProvider empty() {
- return EMPTY_PROPERTYPROVIDER;
- }
-
- /**
- * Get an empty and immutable PropertyProvider instance.
- *
- * @return an empty and mutable PropertyProvider instance, never null.
- */
- public static PropertyProvider emptyMutable() {
- return PropertyProviders.from(new ConcurrentHashMap<>());
- }
-
- /**
- * 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 from(metaInfo, Collections.emptyMap());
- }
-
- /**
- * 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 from(metaInfo, new ConcurrentHashMap<>());
- }
-
- /**
- * Returns a read-only {@link PropertyProvider} reflecting the current runtime environment properties.
- *
- * @return a new read-only {@link PropertyProvider} instance based on the current runtime environment properties.
- */
- public static PropertyProvider fromEnvironmentProperties() {
- return ENV_PROPERTYPROVIDER;
- }
-
- /**
- * Creates a new read-only {@link PropertyProvider} reflecting the current system properties.
- *
- * @return a new read-only {@link PropertyProvider} instance based on the current system properties.
- */
- public static PropertyProvider fromSystemProperties() {
- return new SystemPropertiesPropertyProvider();
- }
-
- /**
- * Converts a given {@link org.apache.tamaya.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 FreezedPropertyProvider.of(provider);
- }
-
- /**
- * Creates a new {@link PropertyProvider} containing all property maps given, hereby later maps in the array override
- * properties from previous instances.
- *
- * @param propertyMaps the maps to be included, not null.
- * @return the union instance containing all given maps.
- */
- public static PropertyProvider union(PropertyProvider... propertyMaps) {
- return union(AggregationPolicy.OVERRIDE, propertyMaps);
- }
-
- /**
- * Creates a new {@link PropertyProvider} containing all property maps given, hereby using the given AggregationPolicy.
- *
- * @param policy 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 union(AggregationPolicy policy, PropertyProvider... propertyMaps) {
- return new AggregatedPropertyProvider(null, policy, propertyMaps);
- }
-
- /**
- * Creates a new {@link PropertyProvider} that is mutable by adding a map based instance that overrides
- * values from the original map.
- * @param provider the provider to be made mutable, not null.
- * @return the mutable instance.
- */
- public static PropertyProvider mutable(PropertyProvider provider) {
- PropertyProvider mutableProvider = PropertyProviders.emptyMutable();
- return mutableUnion(mutableProvider, AggregationPolicy.OVERRIDE, provider, mutableProvider);
- }
-
- /**
- * Creates a new {@link PropertyProvider} containing all property maps given, hereby later maps in the array override
- * properties from previous instances.
- * @param mutableProvider the provider used for delegating change requests.
- * @param propertyMaps the maps to be included, not null.
- * @return the union instance containing all given maps.
- */
- public static PropertyProvider mutableUnion(PropertyProvider mutableProvider, PropertyProvider... propertyMaps) {
- return mutableUnion(mutableProvider, AggregationPolicy.OVERRIDE, propertyMaps);
- }
-
- /**
- * Creates a new {@link PropertyProvider} containing all property maps given, hereby using the given AggregationPolicy.
- * @param mutableProvider the provider used for delegating change requests.
- * @param policy 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 mutableUnion(PropertyProvider mutableProvider, AggregationPolicy policy, PropertyProvider... propertyMaps) {
- return new AggregatedPropertyProvider(mutableProvider, policy, propertyMaps);
- }
-
- /**
- * Creates a new {@link PropertyProvider} containing only properties that are shared by all given maps,
- * hereby later maps in the array override properties from previous instances.
- *
- * @param propertyMaps the maps to be included, not null.
- * @return the intersecting instance containing all given maps.
- */
- public static PropertyProvider intersected(AggregationPolicy policy, PropertyProvider... propertyMaps) {
- return new IntersectingPropertyProvider(policy, propertyMaps);
- }
-
- /**
- * Creates a new {@link PropertyProvider} containing only properties that are shared by all given maps,
- * hereby later maps in the array override properties from previous instances.
- *
- * @param propertyMaps the maps to be included, not null.
- * @return the intersecting instance containing all given maps.
- */
- public static PropertyProvider intersected(PropertyProvider... propertyMaps) {
- return new IntersectingPropertyProvider(AggregationPolicy.OVERRIDE, propertyMaps);
- }
-
- /**
- * Creates a new {@link PropertyProvider} containing only properties from 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.
- */
- public static PropertyProvider subtracted(PropertyProvider target, PropertyProvider... subtrahendSets) {
- return new SubtractingPropertyProvider(target, subtrahendSets);
- }
-
-
- /**
- * Creates a filtered {@link 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.
- */
- public static PropertyProvider filtered(Predicate<String> filter, PropertyProvider propertyMap) {
- return new FilteredPropertyProvider(propertyMap, filter);
- }
-
- /**
- * Creates a new contextual {@link PropertyProvider}. Contextual maps delegate to different instances of PropertyMap depending
- * on the keys returned from 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 new ContextualPropertyProvider(mapSupplier, isolationKeySupplier);
- }
-
-
- /**
- * Creates a filtered {@link 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 new DelegatingPropertyProvider(mainMap, parentMap);
- }
-
- /**
- * Creates a {@link org.apache.tamaya.PropertyProvider} where all keys of a current map,
- * existing in another map are replaced
- * with the ones from the other {@link org.apache.tamaya.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 new ReplacingPropertyProvider(mainMap, replacementMap);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/ReplacingPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/ReplacingPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/ReplacingPropertyProvider.java
deleted file mode 100644
index 7eb69fa..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/ReplacingPropertyProvider.java
+++ /dev/null
@@ -1,111 +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.properties;
-
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.PropertyProvider;
-
-import java.util.*;
-
-/**
- * Implementation for a {@link org.apache.tamaya.PropertyProvider} that is an aggregate of
- * multiple child instances, where all existing key/values in a replacementMap will
- * replace values in a main map, if present there.
- */
-class ReplacingPropertyProvider implements PropertyProvider{
-
- private static final long serialVersionUID = -1419376385695224799L;
- private PropertyProvider mainMap;
- private Map<String,String> replacingMap;
- private MetaInfo metaInfo;
-
- /**
- * Creates a mew instance, with aggregation polilcy
- * {@code AggregationPolicy.OVERRIDE}.
- *
- * @param mainMap The main ConfigMap.
- * @param replacingMap The replacing ConfigMap.
- */
- public ReplacingPropertyProvider(PropertyProvider mainMap, Map<String,String> replacingMap){
- Objects.requireNonNull(replacingMap);
- this.replacingMap = replacingMap;
- Objects.requireNonNull(mainMap);
- this.mainMap = mainMap;
- this.metaInfo = MetaInfoBuilder.of().setType("replacing").set("mainProvider", mainMap.toString())
- .set("replacing", replacingMap.toString()).build();
- }
-
- @Override
- public ConfigChangeSet load(){
- return mainMap.load();
- }
-
- @Override
- public boolean containsKey(String key){
- return mainMap.containsKey(key);
- }
-
- @Override
- public Map<String,String> toMap(){
- Map<String,String> result = new HashMap<>(replacingMap);
- for(Map.Entry<String,String> en : mainMap.toMap().entrySet()){
- if(!replacingMap.containsKey(en.getKey())){
- result.put(en.getKey(), en.getValue());
- }
- }
- return result;
- }
-
- @Override
- public MetaInfo getMetaInfo(){
- return this.metaInfo;
- }
-
- @Override
- public Optional<String> get(String key){
- String val = replacingMap.get(key);
- if(val == null){
- return mainMap.get(key);
- }
- return Optional.ofNullable(val);
- }
-
- @Override
- public Set<String> keySet(){
- return mainMap.keySet();
- }
-
- /**
- * 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){
- this.mainMap.apply(change);
- }
-
- @Override
- public String toString(){
- return super.toString() + "(mainMap=" + mainMap + ", replacingMap=" + replacingMap + ")";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/Store.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/Store.java b/core/src/main/java/org/apache/tamaya/core/properties/Store.java
index 711824e..0c1d775 100644
--- a/core/src/main/java/org/apache/tamaya/core/properties/Store.java
+++ b/core/src/main/java/org/apache/tamaya/core/properties/Store.java
@@ -23,7 +23,7 @@ import java.util.*;
/**
* This store encapsulates an list of WeakReferences to items.
- * It cleans up the list from null references, when an item is removed, or an Iterator is created.
+ * It cleans up the list fromMap null references, when an item is removed, or an Iterator is created.
* Created by Anatole on 10.04.2014.
*/
public class Store<T>implements Iterable<T> {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/SubtractingPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/SubtractingPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/SubtractingPropertyProvider.java
deleted file mode 100644
index 0ecb837..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/SubtractingPropertyProvider.java
+++ /dev/null
@@ -1,75 +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.properties;
-
-import org.apache.tamaya.ConfigChangeSet;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.PropertyProvider;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-class SubtractingPropertyProvider extends AbstractPropertyProvider{
-
- private static final long serialVersionUID = 4301042530074932562L;
- private PropertyProvider unit;
- private Collection<PropertyProvider> subtrahends;
-
- public SubtractingPropertyProvider(PropertyProvider configuration, PropertyProvider... subtrahends){
- super(MetaInfoBuilder.of(configuration.getMetaInfo()).setType("sutracted").set("subtrahends", Arrays.toString(subtrahends)).build());
- Objects.requireNonNull(configuration);
- this.unit = configuration;
- this.subtrahends = Arrays.asList(subtrahends);
- }
-
- private boolean filter(Map.Entry<String,String> entry){
- for(PropertyProvider prov: subtrahends){
- if(prov.containsKey(entry.getKey())){
- return false;
- }
- }
- return true;
- }
-
- @Override
- public Map<String,String> toMap(){
- return this.unit.toMap().entrySet().stream().filter(this::filter).collect(Collectors.toMap(
- (en) -> en.getKey(),
- (en) -> en.getValue()
- ));
- }
-
- @Override
- public ConfigChangeSet load(){
- unit.load();
- return super.load();
- }
-
- /**
- * 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){
- this.unit.apply(change);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/SystemPropertiesPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/SystemPropertiesPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/SystemPropertiesPropertyProvider.java
deleted file mode 100644
index 8f186be..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/SystemPropertiesPropertyProvider.java
+++ /dev/null
@@ -1,52 +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.properties;
-
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.core.env.ConfiguredSystemProperties;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-class SystemPropertiesPropertyProvider extends AbstractPropertyProvider{
-
-
- private static final long serialVersionUID = -5935940312707001199L;
-
- public SystemPropertiesPropertyProvider(){
- super(MetaInfoBuilder.of().setType("sys-properties").build());
- }
-
- @Override
- public Map<String,String> toMap(){
- Properties sysProps = System.getProperties();
- if(sysProps instanceof ConfiguredSystemProperties){
- sysProps = ((ConfiguredSystemProperties)sysProps).getInitialProperties();
- }
- Map<String,String> props = new HashMap<>();
- for (Map.Entry<Object,Object> en : sysProps.entrySet()) {
- props.put(en.getKey().toString(), en.getValue().toString());
- }
- return Collections.unmodifiableMap(props);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/properties/UriBasedPropertyProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/properties/UriBasedPropertyProvider.java b/core/src/main/java/org/apache/tamaya/core/properties/UriBasedPropertyProvider.java
deleted file mode 100644
index 0e81769..0000000
--- a/core/src/main/java/org/apache/tamaya/core/properties/UriBasedPropertyProvider.java
+++ /dev/null
@@ -1,68 +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.properties;
-
-import org.apache.tamaya.MetaInfo;
-import org.apache.tamaya.MetaInfoBuilder;
-import org.apache.tamaya.core.config.ConfigurationFormats;
-import org.apache.tamaya.spi.Bootstrap;
-import org.apache.tamaya.core.spi.ConfigurationFormat;
-
-import java.net.URI;
-import java.util.*;
-
-/**
- * Created by Anatole on 16.10.2014.
- */
-final class URIBasedPropertyProvider extends AbstractPropertyProvider {
-
- private List<URI> uris = new ArrayList<>();
- private Map<String,String> properties = new HashMap<>();
-
- public URIBasedPropertyProvider(MetaInfo metaInfo, Collection<URI> uris) {
- super(metaInfo);
- Objects.requireNonNull(uris);
- this.uris.addAll(uris);
- init();
- }
-
- private void init(){
- List<String> sources = new ArrayList<>();
- for(URI uri : uris){
- ConfigurationFormat format = ConfigurationFormats.getFormat(uri);
- if(format != null){
- try{
- properties.putAll(format.readConfiguration(uri));
- sources.add(uri.toString());
- }
- catch(Exception e){
- e.printStackTrace();
- }
- }
- }
- MetaInfoBuilder metaInfoBuilder = MetaInfoBuilder.of(getMetaInfo());
- super.metaInfo = metaInfoBuilder
- .setSources(sources.toString()).build();
- }
-
- @Override
- public Map<String, String> toMap() {
- return properties;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormat.java b/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormat.java
index 1ebe566..f06e224 100644
--- a/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormat.java
+++ b/core/src/main/java/org/apache/tamaya/core/spi/ConfigurationFormat.java
@@ -46,7 +46,7 @@ public interface ConfigurationFormat{
boolean isAccepted(URI resource);
/**
- * Reads a {@link javax.config.PropertyMap} from the given URI, using this format.
+ * Reads a {@link org.apache.tamaya.PropertyProvider} fromMap the given URI, using this format.
*
* @param resource the configuration location, not null
* @return the corresponding {@link java.util.Map}, never {@code null}.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/spi/EnvironmentProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/spi/EnvironmentProvider.java b/core/src/main/java/org/apache/tamaya/core/spi/EnvironmentProvider.java
index 992b337..e57730d 100644
--- a/core/src/main/java/org/apache/tamaya/core/spi/EnvironmentProvider.java
+++ b/core/src/main/java/org/apache/tamaya/core/spi/EnvironmentProvider.java
@@ -52,7 +52,7 @@ public interface EnvironmentProvider {
/**
* Get all currently known environment contexts for this environment type.
* @return all currently known environment contexts, never null. Environment
- * providers may prevent abritrary access to environment from outside of the
+ * providers may prevent abritrary access to environment fromMap outside of the
* regarding runtime context by just not including the context information
* in this call's result.
* @return all currently known environment contexts, never null.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/spi/ExpressionResolver.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/spi/ExpressionResolver.java b/core/src/main/java/org/apache/tamaya/core/spi/ExpressionResolver.java
index f2a32b7..3edf23e 100644
--- a/core/src/main/java/org/apache/tamaya/core/spi/ExpressionResolver.java
+++ b/core/src/main/java/org/apache/tamaya/core/spi/ExpressionResolver.java
@@ -37,7 +37,7 @@ public interface ExpressionResolver {
String getResolverId();
/**
- * Resolve the expression. The expression should be stripped from any surrounding parts.
+ * Resolve the expression. The expression should be stripped fromMap any surrounding parts.
* E.g. <code>${myresolver:blabla to be interpreted AND executed.}</code> should be passed
* as {@code blabla to be interpreted AND executed.} only.
*
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/java/org/apache/tamaya/core/spi/ResourceLoader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/spi/ResourceLoader.java b/core/src/main/java/org/apache/tamaya/core/spi/ResourceLoader.java
index 2cca547..e2727d3 100644
--- a/core/src/main/java/org/apache/tamaya/core/spi/ResourceLoader.java
+++ b/core/src/main/java/org/apache/tamaya/core/spi/ResourceLoader.java
@@ -24,7 +24,7 @@ import java.util.List;
import java.util.stream.Stream;
/**
- * Interface to be implemented by containers that decouples loading of classpath resources from the effective
+ * Interface to be implemented by containers that decouples loading of classpath resources fromMap the effective
* classloader architecture of a runtime environment. Implementations of this class encapsulate the mechanism of
* determining the
* concrete resources available base on an expression defining the configuration
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyProvidersSingletonSpi
----------------------------------------------------------------------
diff --git a/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyProvidersSingletonSpi b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyProvidersSingletonSpi
new file mode 100644
index 0000000..092a7c2
--- /dev/null
+++ b/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyProvidersSingletonSpi
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+org.apache.tamaya.core.internal.DefaultPropertyProvidersSingletonSpi
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java b/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
index 6ca1063..f8ac835 100644
--- a/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
+++ b/core/src/test/java/org/apache/tamaya/DefaultConfigurationManagerSingletonSpiSingletonSpiTest.java
@@ -86,13 +86,13 @@ public class DefaultConfigurationManagerSingletonSpiSingletonSpiTest {
@Test
public void testAddRemoveGlobalConfigChangeListener() {
- Configuration.addGlobalPropertyChangeListener(LISTENER);
- Configuration.removeGlobalPropertyChangeListener(LISTENER);
- Configuration.addGlobalPropertyChangeListener(LISTENER);
- Configuration.addGlobalPropertyChangeListener(LISTENER);
- Configuration.removeGlobalPropertyChangeListener(LISTENER);
- Configuration.removeGlobalPropertyChangeListener(LISTENER);
- Configuration.removeGlobalPropertyChangeListener(LISTENER);
+ Configuration.addConfigChangeListener(LISTENER);
+ Configuration.removeConfigChangeListener(LISTENER);
+ Configuration.addConfigChangeListener(LISTENER);
+ Configuration.addConfigChangeListener(LISTENER);
+ Configuration.removeConfigChangeListener(LISTENER);
+ Configuration.removeConfigChangeListener(LISTENER);
+ Configuration.removeConfigChangeListener(LISTENER);
}
@Test
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/JavaOneDemo.java b/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
index 9cd271c..8719693 100644
--- a/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
+++ b/core/src/test/java/org/apache/tamaya/JavaOneDemo.java
@@ -20,9 +20,6 @@ package org.apache.tamaya;
import org.apache.tamaya.core.config.ConfigurationBuilder;
import org.apache.tamaya.core.config.ConfigurationFormats;
-import org.apache.tamaya.core.properties.AggregationPolicy;
-import org.apache.tamaya.core.properties.PropertyProviders;
-import org.apache.tamaya.samples.annotations.ConfiguredClass;
import org.apache.tamaya.core.spi.ConfigurationFormat;
import org.junit.Test;
@@ -62,7 +59,7 @@ public class JavaOneDemo{
PropertyProviders
.fromPaths("classpath:cfg/test.xml"),
PropertyProviders.fromArgs(new String[]{"-arg1", "--fullarg", "fullValue", "-myflag"}),
- PropertyProviders.from(cfgMap)).build();
+ PropertyProviders.fromMap(cfgMap)).build();
System.out.println(config.getAreas());
System.out.println("---");
System.out.println(config.getAreas(s -> s.startsWith("another")));
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/test/java/org/apache/tamaya/core/properties/PropertyProvidersTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/core/properties/PropertyProvidersTest.java b/core/src/test/java/org/apache/tamaya/core/properties/PropertyProvidersTest.java
index 3e3435c..825f895 100644
--- a/core/src/test/java/org/apache/tamaya/core/properties/PropertyProvidersTest.java
+++ b/core/src/test/java/org/apache/tamaya/core/properties/PropertyProvidersTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.tamaya.core.properties;
+import org.apache.tamaya.PropertyProviders;
import org.junit.Test;
import org.apache.tamaya.PropertyProvider;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java b/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
index 91d99dd..c42e926 100644
--- a/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
+++ b/core/src/test/java/org/apache/tamaya/internal/MutableTestConfigProvider.java
@@ -21,8 +21,8 @@ package org.apache.tamaya.internal;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.MetaInfoBuilder;
import org.apache.tamaya.PropertyProvider;
+import org.apache.tamaya.PropertyProviders;
import org.apache.tamaya.core.config.Configurations;
-import org.apache.tamaya.core.properties.PropertyProviders;
import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
import java.util.Map;
@@ -43,7 +43,7 @@ public class MutableTestConfigProvider implements ConfigurationProviderSpi{
dataMap.put("sons.1", "Robin");
dataMap.put("sons.2", "Luke");
dataMap.put("sons.3", "Benjamin");
- PropertyProvider provider = PropertyProviders.from(MetaInfoBuilder.of().setName(CONFIG_NAME).build(),
+ PropertyProvider provider = PropertyProviders.fromMap(MetaInfoBuilder.of().setName(CONFIG_NAME).build(),
dataMap);
testConfig = Configurations.getConfiguration(provider);
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java b/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
index f4905d5..63a9aaa 100644
--- a/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
+++ b/core/src/test/java/org/apache/tamaya/simple/SimplePropertiesAndCLISample.java
@@ -16,12 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tamaya.simple.simple;
+package org.apache.tamaya.simple;
+import org.apache.tamaya.PropertyProviders;
import org.apache.tamaya.core.config.ConfigurationBuilder;
import org.apache.tamaya.core.config.ConfigurationFormats;
-import org.apache.tamaya.core.properties.AggregationPolicy;
-import org.apache.tamaya.core.properties.PropertyProviders;
+import org.apache.tamaya.AggregationPolicy;
import org.apache.tamaya.core.spi.ConfigurationFormat;
import org.junit.Test;
@@ -55,7 +55,7 @@ public class SimplePropertiesAndCLISample{
PropertyProviders
.fromPaths("classpath:cfg/test.xml"),
PropertyProviders.fromArgs(new String[]{"-arg1", "--fullarg", "fullValue", "-myflag"}),
- PropertyProviders.from(cfgMap)).build();
+ PropertyProviders.fromMap(cfgMap)).build();
System.out.println(config.getAreas());
System.out.println("---");
System.out.println(config.getAreas(s -> s.startsWith("another")));
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties/UC1ReadPropertiesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties/UC1ReadPropertiesTest.java b/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties/UC1ReadPropertiesTest.java
new file mode 100644
index 0000000..2105c94
--- /dev/null
+++ b/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties/UC1ReadPropertiesTest.java
@@ -0,0 +1,218 @@
+/**
+ * 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.ucs.UC1ReadProperties;
+
+import org.apache.tamaya.*;
+import org.junit.Test;
+
+import java.math.BigDecimal;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Configuration is organized as key/value pairs. This basically can be modeled as {@code Map<String,String>}
+ * Configuration should be as simple as possible. A {@code Map<String,String>} instance has methods that may not
+ * be used in many use cases and/or are not easy to implement. Currently the following functionality
+ * must be supported:
+ * <ul>
+ * <li>access a value by key (+get+)</li>
+ * <li>check if a value is present (+containsKey+)</li>
+ * <li>get a set of all defined keys (+keySet+)</li>
+ * <li>a property provider must be convertible to a +Map+, by calling +toMap()+</li>
+ * <li>a property provider must get access to its meta information.</li>
+ * </ul>
+ * Additionally there are other requirement important for ease of use:
+ * <ul>
+ * <li>The API must never return null.</li>
+ * <li>The API should support undefined values.</li>
+ * <li>The API must support passing default values, to be returned if a value is undefined.</li>
+ * <li>The API must allow to throw exceptions, when a value is undefined.
+ * Customized exceptions hereby should be supported.</li>
+ * <li>Properties can be stored in the classpath, on a file.</li>
+ * <li>Properties can be stored as properties, xml-properties or as ini-files.</li>
+ * <li>Properties can also be provided as properties, or as a Map<String,String></li>
+ * </ul>
+ */
+public class UC1ReadPropertiesTest {
+
+ @Test
+ public void example() {
+ Configuration config = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").toConfiguration();
+ String name = config.get("name").orElse("Anatole");
+ BigDecimal bigNum = config.get("num.BD", BigDecimal.class).orElseThrow(() -> new IllegalStateException("Sorry"));
+ double anotherNum = config.getDouble("num.Double").getAsDouble();
+ long longNum = config.getLong("num.Long").orElse(288900L);
+
+ // or more simpler use area function
+ Configuration areaConfig2 = config.with(ConfigFunctions.selectArea("num"));
+ System.out.println(areaConfig2);
+
+ // iterator over an area, using streams only
+ Map<String, String> areaMap = config.toMap().entrySet().stream()
+ .filter((e) -> e.getKey().startsWith("num."))
+ .collect(Collectors.toMap((e) -> e.getKey().substring("num.".length()), (e) -> e.getValue()));
+ Configuration areaConfig = PropertyProviders.fromMap(areaMap).toConfiguration();
+ System.out.println(areaConfig);
+ }
+
+ @Test
+ public void getConfigurationTest() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:barFoo.properties");
+ Configuration config = provider.toConfiguration();
+ assertNotNull(config);
+ assertTrue(config.isEmpty());
+ assertTrue(config.keySet().isEmpty());
+ assertFalse(config.isMutable());
+ }
+
+ @Test
+ public void readBadPropertiesTest() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:barFoo.properties");
+ assertNotNull(provider);
+ assertTrue(provider.isEmpty());
+ assertTrue(provider.keySet().isEmpty());
+ assertFalse(provider.isMutable());
+ }
+
+ @Test
+ public void readPropertiesTest() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ assertNotNull(provider);
+ assertEquals(provider.get("a").get(), "aValue");
+ assertEquals(provider.get("b").get(), "bValue");
+ assertEquals(provider.get("c").get(), "cValue");
+ assertEquals(provider.get("a.b.c").get(), "abcValue");
+ assertEquals(provider.get("a.b.a").get(), "abaValue");
+ assertEquals(provider.get("a.b.b").get(), "abbValue");
+ assertEquals(provider.get("a.b").get(), "abValue");
+ assertEquals(provider.get("a.a.a").get(), "aaaValue");
+ assertEquals(provider.get("b.b.b").get(), "bbbValue");
+ assertEquals(provider.get("c.c.c").get(), "cccValue");
+ assertEquals(provider.get("numInt").get(), "9999");
+ assertEquals(provider.get("num.Int").get(), "123");
+ assertEquals(provider.get("num.Byte").get(), "100");
+ assertEquals(provider.get("boolean").get(), "true");
+ assertEquals(provider.get("num.BD").get(), "2376523725372653.287362836283628362863");
+ assertEquals(provider.get("num.Double").get(), "21334.43254");
+ assertTrue(!provider.get("blabla").isPresent());
+ assertTrue(provider.get("num.BD").isPresent());
+ }
+
+ @Test
+ public void readXmlPropertiesTest() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.xml");
+ assertNotNull(provider);
+ assertEquals(provider.get("a-xml").get(), "aFromXml");
+ assertEquals(provider.get("b-xml").get(), "bFromXml");
+ assertEquals(provider.get("a.b.c-xml").get(), "abcFromXml");
+ }
+
+ @Test
+ public void readIniPropertiesTest() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.ini");
+ assertNotNull(provider);
+ assertEquals(provider.get("a.b.c").get(), "abcValue-fromIni");
+ assertEquals(provider.get("a.b.b").get(), "abbValue-fromIni");
+ assertEquals(provider.get("a.b.a").get(), "abaValue-fromIni");
+ assertEquals(provider.get("mixed.a.b").get(), "abValue");
+ assertFalse(provider.get("mixed.foo").isPresent());
+ assertTrue(provider.get("num.BD").isPresent());
+ }
+
+ @Test
+ public void readAllPropertiesTest() {
+ PropertyProvider provider = PropertyProviders.fromPaths(AggregationPolicy.IGNORE, "classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.*");
+ assertNotNull(provider);
+ // fromMap ini file
+ assertEquals(provider.get("a.b.c").get(), "abcValue-fromIni");
+ assertEquals(provider.get("a.b.b").get(), "abbValue-fromIni");
+ assertEquals(provider.get("a.b.a").get(), "abaValue-fromIni");
+ // fromMap properties
+ assertTrue(provider.containsKey("num.BD"));
+ // fromMap xml properties
+ assertEquals(provider.get("a-xml").get(), "aFromXml");
+ assertEquals(provider.get("b-xml").get(), "bFromXml");
+ }
+
+ @Test
+ public void checkForAValue() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ assertFalse(provider.containsKey("blabla"));
+ assertTrue(provider.containsKey("num.BD"));
+ assertFalse(provider.get("blabla").isPresent());
+ assertTrue(provider.get("num.BD").isPresent());
+ }
+
+ @Test
+ public void checkKeys() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ assertEquals(provider.keySet().size(), 16);
+ assertTrue(provider.keySet().contains("boolean"));
+ assertFalse(provider.keySet().contains("blabla"));
+ }
+
+ @Test
+ public void checkToMap() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ Map<String, String> map = provider.toMap();
+ assertNotNull(map);
+ assertEquals(map.size(), 16);
+ assertEquals(provider.keySet(), map.keySet());
+ assertTrue(map.keySet().contains("boolean"));
+ assertFalse(map.keySet().contains("blabla"));
+ }
+
+ @Test
+ public void checkMetaInfo() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ MetaInfo meta = provider.getMetaInfo();
+ assertNotNull(meta);
+ }
+
+ @Test
+ public void checkNeverNull() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ assertNotNull(provider.get("blabla"));
+ assertNotNull(provider.get("a.b.c"));
+ }
+
+ @Test
+ public void checkUndefined() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ assertFalse(provider.get("blabla").isPresent());
+ assertTrue(provider.get("a.b.c").isPresent());
+ }
+
+ @Test
+ public void checkPassDefaultValues() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ assertEquals("myDefaultValue", provider.get("blabla").orElse("myDefaultValue"));
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void checkThrowCustomException() {
+ PropertyProvider provider = PropertyProviders.fromPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties");
+ provider.get("blabla").orElseThrow(() -> new IllegalStateException("checkThrowCustomException"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.ini
----------------------------------------------------------------------
diff --git a/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.ini b/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.ini
new file mode 100644
index 0000000..2e19f08
--- /dev/null
+++ b/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.ini
@@ -0,0 +1,23 @@
+[a.b]
+c=abcValue-fromIni
+a=abaValue-fromIni
+b=abbValue-fromIni
+
+[mixed]
+a.b=abValue
+a.a.a=aaaValue
+b.b.b=bbbValue
+c.c.c=cccValue
+
+[num]
+Int=123
+Byte=100
+BD=2376523725372653.287362836283628362863
+Double=21334.43254
+
+[other]
+boolean=true
+a=aValue
+b=bValue
+c=cValue
+numInt=9999s
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties
----------------------------------------------------------------------
diff --git a/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties b/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties
new file mode 100644
index 0000000..3fca7fd
--- /dev/null
+++ b/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties
@@ -0,0 +1,16 @@
+a=aValue
+b=bValue
+c=cValue
+a.b.c=abcValue
+a.b.a=abaValue
+a.b.b=abbValue
+a.b=abValue
+a.a.a=aaaValue
+b.b.b=bbbValue
+c.c.c=cccValue
+numInt=9999
+num.Int=123
+num.Byte=100
+boolean=true
+num.BD=2376523725372653.287362836283628362863
+num.Double=21334.43254
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a55d1c97/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.xml
----------------------------------------------------------------------
diff --git a/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.xml b/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.xml
new file mode 100644
index 0000000..425233c
--- /dev/null
+++ b/core/src/test/resources/ucs/UC1ReadProperties/UC1ReadPropertiesTest.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties version="1.0">
+ <entry key="a-xml">aFromXml</entry>
+ <entry key="b-xml">bFromXml</entry>
+ <entry key="a.b.c-xml">abcFromXml</entry>
+</properties>
\ No newline at end of file