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 2015/05/05 13:11:27 UTC
[08/10] incubator-tamaya git commit: Removed unused dormant parts.
Moved usable dormant utils into new sandbox module. Fixed jqassistant issues
in simple metamodel module.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/old/ConfigurationProviderSpi.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/ConfigurationProviderSpi.java b/dormant/core/src/main/java/old/ConfigurationProviderSpi.java
deleted file mode 100644
index 26697ea..0000000
--- a/dormant/core/src/main/java/old/ConfigurationProviderSpi.java
+++ /dev/null
@@ -1,46 +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 old;
-
-import org.apache.tamaya.Configuration;
-
-/**
-* This configuration provider SPI allows to register the effective factory logic to of and manage a configuration
-* instance. Hereby the qualifiers determine the type current configuration. By default
-*/
-public interface ConfigurationProviderSpi{
-
- /**
- * Returns the name current the configuration provided.
- * @return the name current the configuration provided, not empty.
- */
- String getConfigName();
-
- /**
- * Get the {@link Configuration}, if available.
- * @return according configuration, or null, if none is available for the given environment.
- */
- Configuration getConfiguration();
-
- /**
- * Reloads the provider for the current context.
- */
- void reload();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/old/ContextualPropertySource.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/ContextualPropertySource.java b/dormant/core/src/main/java/old/ContextualPropertySource.java
deleted file mode 100644
index 3ff5e15..0000000
--- a/dormant/core/src/main/java/old/ContextualPropertySource.java
+++ /dev/null
@@ -1,142 +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.spi.PropertySource;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Supplier;
-
-/**
- * Created by Anatole on 12.04.2014.
- */
-class ContextualPropertySource implements PropertySource {
-
- private volatile Map<String,PropertySource> cachedMaps = new ConcurrentHashMap<>();
-
- private Supplier<PropertySource> mapSupplier;
- private Supplier<String> isolationKeySupplier;
- private String name;
-
-
- /**
- * Creates a new contextual PropertyMap. Contextual maps delegate to different instances current PropertyMap depending
- * on the keys returned fromMap the isolationP
- *
- * @param mapSupplier
- * @param isolationKeySupplier
- */
- public ContextualPropertySource(String name, Supplier<PropertySource> mapSupplier, Supplier<String> isolationKeySupplier){
- this.name = Optional.ofNullable(name).orElse("<noname>");
- Objects.requireNonNull(mapSupplier);
- Objects.requireNonNull(isolationKeySupplier);
- this.mapSupplier = mapSupplier;
- this.isolationKeySupplier = isolationKeySupplier;
- }
-
- /**
- * This method provides the contextual Map for the current environment. Hereby, ba default, for each different
- * key returned by the #isolationKeySupplier a separate PropertyMap instance is acquired fromMap the #mapSupplier.
- * If the map supplier returns an instance it is cached in the local #cachedMaps.
- *
- * @return the current contextual PropertyMap.
- */
- protected PropertySource getContextualMap(){
- String environmentKey = this.isolationKeySupplier.get();
- if(environmentKey == null){
- return PropertySource.EMPTY_PROPERTYSOURCE;
- }
- PropertySource map = this.cachedMaps.get(environmentKey);
- if(map == null){
- synchronized(cachedMaps){
- map = this.cachedMaps.get(environmentKey);
- if(map == null){
- map = this.mapSupplier.get();
- if(map == null){
- return PropertySource.EMPTY_PROPERTYSOURCE;
- }
- this.cachedMaps.put(environmentKey, map);
- }
- }
- }
- return map;
- }
-
- @Override
- public Map<String,String> getProperties(){
- return getContextualMap().getProperties();
- }
-
- @Override
- public String getName(){
- return this.name;
- }
-
- @Override
- public Optional<String> get(String key){
- return getContextualMap().get(key);
- }
-
- /**
- * Access a cached PropertyMap.
- *
- * @param key the target environment key as returned by the environment key supplier, not null.
- * @return the corresponding PropertyMap, or null.
- */
- public PropertySource getCachedMap(String key){
- return this.cachedMaps.get(key);
- }
-
- /**
- * Access the set current currently loaded/cached maps.
- *
- * @return the set current cached map keys, never null.
- */
- public Set<String> getCachedMapKeys(){
- return this.cachedMaps.keySet();
- }
-
- /**
- * Access the supplier for environment key, determining map isolation.
- *
- * @return the environment key supplier instance, not null.
- */
- public Supplier<String> getIsolationKeySupplier(){
- return this.isolationKeySupplier;
- }
-
- /**
- * Access the supplier for new PropertyMap instances.
- *
- * @return the PropertyMap supplier instance, not null.
- */
- public Supplier<PropertySource> getMapSupplier(){
- return this.mapSupplier;
- }
-
- @Override
- public String toString(){
- return "ContextualMap{" +
- "cachedMaps(key)=" + cachedMaps.keySet() +
- ", mapSupplier=" + mapSupplier +
- ", isolationKeySupplier=" + isolationKeySupplier +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/old/DefaultConfigurationSpi.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/DefaultConfigurationSpi.java b/dormant/core/src/main/java/old/DefaultConfigurationSpi.java
deleted file mode 100644
index fe9f788..0000000
--- a/dormant/core/src/main/java/old/DefaultConfigurationSpi.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 old;
-
-import java.lang.reflect.Proxy;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.internal.config.FallbackSimpleConfigProvider;
-import org.apache.tamaya.core.internal.el.DefaultExpressionEvaluator;
-import org.apache.tamaya.core.internal.inject.ConfigTemplateInvocationHandler;
-import org.apache.tamaya.core.internal.inject.ConfigurationInjector;
-import org.apache.tamaya.core.spi.ExpressionEvaluator;
-import org.apache.tamaya.spi.ConfigurationSpi;
-import org.apache.tamaya.spi.ServiceContext;
-
-
-/**
- * Default SPI that implements the behaviour of {@link org.apache.tamaya.spi.ConfigurationSpi}.
- */
-@SuppressWarnings("unchecked")
-public class DefaultConfigurationSpi implements ConfigurationSpi {
-
- private static final String DEFAULT_CONFIG_NAME = "default";
-
- private Map<String, ConfigurationProviderSpi> configProviders = new ConcurrentHashMap<>();
-
- private ExpressionEvaluator expressionEvaluator = loadEvaluator();
-
- private ExpressionEvaluator loadEvaluator() {
- ExpressionEvaluator eval = ServiceContext.getInstance().getService(ExpressionEvaluator.class).orElse(null);
- if (eval == null) {
- eval = new DefaultExpressionEvaluator();
- }
- return eval;
- }
-
- public DefaultConfigurationSpi() {
- if(configProviders.isEmpty()) {
- for (ConfigurationProviderSpi spi : ServiceContext.getInstance().getServices(ConfigurationProviderSpi.class, Collections.emptyList())) {
- configProviders.put(spi.getConfigName(), spi);
- }
- }
- }
-
- @Override
- public <T> T createTemplate(Class<T> type, Configuration... configurations) {
- ClassLoader cl = Optional.ofNullable(Thread.currentThread()
- .getContextClassLoader()).orElse(getClass().getClassLoader());
- return (T) Proxy.newProxyInstance(cl, new Class[]{type}, new ConfigTemplateInvocationHandler(type, configurations));
- }
-
- /**
- *
- * @param instance the instance with configuration annotations, not null.
- * @param configurations the configurations to be used for evaluating the values for injection into {@code instance}.
- * If no items are passed, the default configuration is used.
- */
- @Override
- public void configure(Object instance, Configuration... configurations) {
- ConfigurationInjector.configure(instance, configurations);
- }
-
-
- @Override
- public String evaluateValue(String expression, Configuration... configurations) {
- return expressionEvaluator.evaluate(expression, configurations);
- }
-
- @Override
- public boolean isConfigurationAvailable(String name) {
- ConfigurationProviderSpi spi = this.configProviders.get(name);
- return spi != null;
- }
-
- @Override
- public Configuration getConfiguration(String name) {
- ConfigurationProviderSpi provider = configProviders.get(name);
- if (provider == null) {
- if (DEFAULT_CONFIG_NAME.equals(name)) {
- provider = new FallbackSimpleConfigProvider();
- configProviders.put(DEFAULT_CONFIG_NAME, provider);
- } else {
- throw new ConfigException("No such config: " + name);
- }
- }
- Configuration config = provider.getConfiguration();
- if (config == null) {
- throw new ConfigException("No such config: " + name);
- }
- return config;
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/old/DefaultServiceComparator.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/DefaultServiceComparator.java b/dormant/core/src/main/java/old/DefaultServiceComparator.java
deleted file mode 100644
index f284426..0000000
--- a/dormant/core/src/main/java/old/DefaultServiceComparator.java
+++ /dev/null
@@ -1,85 +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 old;
-
-import java.util.*;
-
-/**
- * Simple comparator based on a Collection of {@link OrdinalProvider} instances.
- */
-final class DefaultServiceComparator implements Comparator<Object>{
-
- /**
- * List of ordinal providers loaded.
- */
- private List<OrdinalProvider> ordinalProviders = new ArrayList<>();
-
- DefaultServiceComparator(Collection<? extends OrdinalProvider> providers){
- ordinalProviders.addAll(Objects.requireNonNull(providers));
- ordinalProviders.sort(this::compare);
- }
-
- private int compare(OrdinalProvider provider1, OrdinalProvider provider2){
- int o1 = getOrdinal(provider1);
- int o2 = getOrdinal(provider2);
- int order = o1-o2;
- if(order < 0){
- return -1;
- }
- else if(order > 0){
- return 1;
- }
- return 0;
- }
-
- private int getOrdinal(OrdinalProvider provider){
- if(provider instanceof Orderable){
- return ((Orderable)provider).order();
- }
- return 0;
- }
-
- public int getOrdinal(Object service){
- for(OrdinalProvider provider: ordinalProviders){
- OptionalInt ord = provider.getOrdinal(service.getClass());
- if(ord.isPresent()){
- return ord.getAsInt();
- }
- }
- if(service instanceof Orderable){
- return ((Orderable)service).order();
- }
- return 0;
- }
-
-
- @Override
- public int compare(Object o1, Object o2) {
- int ord1 = getOrdinal(o1);
- int ord2 = getOrdinal(o2);
- int order = ord1-ord2;
- if(order < 0){
- return -1;
- }
- else if(order > 0){
- return 1;
- }
- return 0;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/old/DefaultServiceContextProvider.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/DefaultServiceContextProvider.java b/dormant/core/src/main/java/old/DefaultServiceContextProvider.java
deleted file mode 100644
index ae02afd..0000000
--- a/dormant/core/src/main/java/old/DefaultServiceContextProvider.java
+++ /dev/null
@@ -1,112 +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 old;
-
-import org.apache.tamaya.spi.ServiceContext;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * This class implements the (default) {@link org.apache.tamaya.spi.ServiceContext} interface and hereby uses the JDK
- * {@link java.util.ServiceLoader} to load the services required.
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-class DefaultServiceContextProvider implements ServiceContext {
- /** List current services loaded, per class. */
- private final ConcurrentHashMap<Class, List<Object>> servicesLoaded = new ConcurrentHashMap<>();
- /** Singletons. */
- private final ConcurrentHashMap<Class, Optional<?>> singletons = new ConcurrentHashMap<>();
- /** Comparator for ordering of multiple services found. */
- private DefaultServiceComparator serviceComparator;
-
- public DefaultServiceContextProvider(){
- serviceComparator = new DefaultServiceComparator(getServices(OrdinalProvider.class, Collections.emptyList()));
- }
-
- @Override
- public <T> Optional<T> getService(Class<T> serviceType) {
- Optional<T> cached = (Optional<T>)singletons.get(serviceType);
- if(cached==null) {
- List<? extends T> services = getServices(serviceType, Collections.emptyList());
- if (services.isEmpty()) {
- cached = Optional.empty();
- }
- else{
- cached = Optional.of(services.get(0));
- }
- singletons.put(serviceType, cached);
- }
- return cached;
- }
-
- /**
- * Loads and registers services.
- *
- * @param serviceType
- * The service type.
- * @param <T>
- * the concrete type.
- * @param defaultList
- * the list current items returned, if no services were found.
- * @return the items found, never {@code null}.
- */
- @Override
- public <T> List<? extends T> getServices(final Class<T> serviceType, final List<? extends T> defaultList) {
- List<T> found = (List<T>) servicesLoaded.get(serviceType);
- if (found != null) {
- return found;
- }
- return loadServices(serviceType, defaultList);
- }
-
- /**
- * Loads and registers services.
- *
- * @param serviceType The service type.
- * @param <T> the concrete type.
- * @param defaultList the list current items returned, if no services were found.
- *
- * @return the items found, never {@code null}.
- */
- private <T> List<? extends T> loadServices(final Class<T> serviceType, final List<? extends T> defaultList) {
- try {
- List<T> services = new ArrayList<>();
- for (T t : ServiceLoader.load(serviceType)) {
- services.add(t);
- }
- if(services.isEmpty()){
- services.addAll(defaultList);
- }
- if(!serviceType.equals(OrdinalProvider.class)) {
- services.sort(serviceComparator);
- }
- services = Collections.unmodifiableList(services);
- final List<T> previousServices = (List<T>) servicesLoaded.putIfAbsent(serviceType, (List<Object>)services);
- return previousServices != null ? previousServices : services;
- } catch (Exception e) {
- Logger.getLogger(DefaultServiceContextProvider.class.getName()).log(Level.WARNING,
- "Error loading services current type " + serviceType, e);
- return defaultList;
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/old/DelegatingPropertySource.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/DelegatingPropertySource.java b/dormant/core/src/main/java/old/DelegatingPropertySource.java
deleted file mode 100644
index 7f4ce43..0000000
--- a/dormant/core/src/main/java/old/DelegatingPropertySource.java
+++ /dev/null
@@ -1,79 +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 old;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.*;
-
-/**
- * Implementation for a {@link org.apache.tamaya.spi.PropertySource} that is an aggregate current
- * multiple child instances. Controlled by an {@link org.apache.tamaya.AggregationPolicy} the
- * following aggregations are supported:
- * <ul>
- * <li><b>IGNORE_DUPLICATES: </b>Ignore all overrides.</li>
- * <li><b>: </b></li>
- * <li><b>: </b></li>
- * <li><b>: </b></li>
- * </ul>
- */
-class DelegatingPropertySource implements PropertySource {
-
- private PropertySource mainMap;
- private Map<String,String> parentMap;
- private String name;
-
-
- /**
- * Creates a mew instance, with aggregation polilcy
- * {@code AggregationPolicy.OVERRIDE}.
- *
- * @param mainMap The main ConfigMap.
- * @param parentMap The delegated parent ConfigMap.
- */
- public DelegatingPropertySource(String name, PropertySource mainMap, Map<String, String> parentMap){
- this.name = Optional.of(name).orElse("<noname>");
- this.parentMap = Objects.requireNonNull(parentMap);
- this.parentMap = Objects.requireNonNull(parentMap);
- }
-
- @Override
- public Map<String,String> getProperties(){
- return null;
- }
-
- @Override
- public String getName(){
- return this.name;
- }
-
- @Override
- public Optional<String> get(String key){
- Optional<String> val = mainMap.get(key);
- if(!val.isPresent()){
- return Optional.ofNullable(parentMap.get(key));
- }
- return val;
- }
-
- @Override
- public String toString(){
- return super.toString() + "(mainMap=" + mainMap + ", delegate=" + parentMap + ")";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/old/MappedConfiguration.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/MappedConfiguration.java b/dormant/core/src/main/java/old/MappedConfiguration.java
deleted file mode 100644
index 43c63dc..0000000
--- a/dormant/core/src/main/java/old/MappedConfiguration.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package old;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.UnaryOperator;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.config.AbstractConfiguration;
-
-/**
- * Configuration implementation that maps certain parts (defined by an {@code UnaryOperator<String>}) to alternate areas.
- */
-class MappedConfiguration extends AbstractConfiguration implements Configuration {
-
- private static final long serialVersionUID = 8690637705511432083L;
-
- /** The mapping operator. */
- private UnaryOperator<String> keyMapper;
- /** The base configuration. */
- private Configuration config;
-
- /**
- * Creates a new instance.
- * @param config the base configuration, not null
- * @param keyMapper The mapping operator, not null
- */
- public MappedConfiguration(Configuration config, UnaryOperator<String> keyMapper) {
- super(config.getName());
- this.config = Objects.requireNonNull(config);
- this.keyMapper = Objects.requireNonNull(keyMapper);
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> result = new HashMap<>();
- Map<String, String> map = this.config.getProperties();
- map.forEach((k,v) -> {
- String targetKey = keyMapper.apply(k);
- if(targetKey!=null){
- result.put(targetKey, v);
- }
- });
- return result;
- }
-
- @Override
- public boolean isEmpty() {
- return this.config.isEmpty();
- }
-
- @Override
- public Configuration toConfiguration() {
- return this;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/old/SubtractingPropertySource.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/old/SubtractingPropertySource.java b/dormant/core/src/main/java/old/SubtractingPropertySource.java
deleted file mode 100644
index 4dc1d18..0000000
--- a/dormant/core/src/main/java/old/SubtractingPropertySource.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.properties;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-class SubtractingPropertySource extends AbstractPropertySource {
-
- private static final long serialVersionUID = 4301042530074932562L;
- private PropertySource unit;
- private List<PropertySource> subtrahends;
-
- public SubtractingPropertySource(String name, PropertySource configuration, List<PropertySource> subtrahends){
- super(name);
- Objects.requireNonNull(configuration);
- this.unit = configuration;
- this.subtrahends = new ArrayList<>(subtrahends);
- }
-
- private boolean filter(Map.Entry<String,String> entry){
- for(PropertySource prov: subtrahends){
- if(prov.get(entry.getKey()).isPresent()){
- return false;
- }
- }
- return true;
- }
-
- @Override
- public Map<String,String> getProperties(){
- return this.unit.getProperties().entrySet().stream().filter(this::filter).collect(Collectors.toMap(
- Map.Entry::getKey,
- Map.Entry::getValue
- ));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/ConfigurationFunctions.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/ConfigurationFunctions.java b/dormant/core/src/main/java/org/apache/tamaya/core/ConfigurationFunctions.java
deleted file mode 100644
index b1c2522..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/ConfigurationFunctions.java
+++ /dev/null
@@ -1,213 +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;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.properties.PropertySourceBuilder;
-
-import java.util.*;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.function.UnaryOperator;
-import java.util.stream.Collectors;
-
-/**
- * Accessor that provides useful functions along with configuration.
- */
-public final class ConfigurationFunctions {
- /**
- * Private singleton constructor.
- */
- private ConfigurationFunctions() {
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given area (non recursive). Hereby
- * the area key is stripped away fromMap the resulting key.
- *
- * @param areaKey the area key, not null
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<Configuration> selectArea(String areaKey) {
- return selectArea(areaKey, true);
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given area (non recursive).
- *
- * @param areaKey the area key, not null
- * @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<Configuration> selectArea(String areaKey, boolean stripKeys) {
- return config -> {
- Map<String, String> area = new HashMap<>();
- area.putAll(
- config.getProperties().entrySet().stream()
- .filter(e -> isKeyInArea(e.getKey(), areaKey))
- .collect(Collectors.toMap(
- e -> stripKeys ? e.getKey().substring(areaKey.length() + 1) : e.getKey(),
- Map.Entry::getValue)));
- return Configuration.from(PropertySourceBuilder.of("area: " + areaKey).addMap(area).build());
- };
- }
-
- /**
- * Calculates the current area key and compares it with the given key.
- *
- * @param key the fully qualified entry key, not null
- * @param areaKey the area key, not null
- * @return true, if the entry is exact in this area
- */
- public static boolean isKeyInArea(String key, String areaKey) {
- int lastIndex = key.lastIndexOf('.');
- String curAreaKey = lastIndex > 0 ? key.substring(0, lastIndex) : "";
- return curAreaKey.equals(areaKey);
- }
-
- /**
- * Return a query to evaluate the set with all fully qualifies area names. This method should return the areas as accurate as possible,
- * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @return s set with all areas, never {@code null}.
- */
- public static Function<Configuration,Set<String>> getAreas() {
- return config -> {
- final Set<String> areas = new HashSet<>();
- config.getProperties().keySet().forEach(s -> {
- int index = s.lastIndexOf('.');
- if (index > 0) {
- areas.add(s.substring(0, index));
- } else {
- areas.add("<root>");
- }
- });
- return areas;
- };
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified area names, containing the transitive closure also including all
- * subarea names, regardless if properties are accessible or not. This method should return the areas as accurate
- * as possible, but may not provide a complete set of areas that are finally accessible, especially when the
- * underlying storage does not support key iteration.
- *
- * @return s set with all transitive areas, never {@code null}.
- */
- public static Function<Configuration,Set<String>> getTransitiveAreas() {
- return config -> {
- final Set<String> transitiveAreas = new HashSet<>();
- config.query(getAreas()).forEach(s -> {
- int index = s.lastIndexOf('.');
- if (index < 0) {
- transitiveAreas.add("<root>");
- } else {
- while (index > 0) {
- s = s.substring(0, index);
- transitiveAreas.add(s);
- index = s.lastIndexOf('.');
- }
- }
- });
- return transitiveAreas;
- };
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified area names, containing only the
- * areas that match the predicate and have properties attached. This method should return the areas as accurate as possible,
- * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param predicate A predicate to deternine, which areas should be returned, not {@code null}.
- * @return s set with all areas, never {@code null}.
- */
- public static Function<Configuration,Set<String>> getAreas(final Predicate<String> predicate) {
- return config -> {
- return config.query(getAreas()).stream().filter(predicate).collect(Collectors.toCollection(TreeSet::new));
- };
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified area names, containing the transitive closure also including all
- * subarea names, regardless if properties are accessible or not. This method should return the areas as accurate as possible,
- * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param predicate A predicate to deternine, which areas should be returned, not {@code null}.
- * @return s set with all transitive areas, never {@code null}.
- */
- public static Function<Configuration,Set<String>> getTransitiveAreas(Predicate<String> predicate) {
- return config -> {
- return config.query(getTransitiveAreas()).stream().filter(predicate).collect(Collectors.toCollection(TreeSet::new));
- };
- }
-
- /**
- * Return a query to evaluate to evaluate if an area exists. In case where the underlying storage implementation does not allow
- * querying the keys available, {@code false} should be returned.
- *
- * @param areaKey the configuration area (sub)path.
- * @return {@code true}, if such a node exists.
- */
- public static Function<Configuration,Boolean> containsArea(String areaKey) {
- return config -> {
- return config.query(getAreas()).contains(areaKey);
- };
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given area (recursive). Hereby
- * the area key is stripped away fromMap the resulting key.
- *
- * @param areaKey the area key, not null
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<Configuration> selectAreaRecursive(String areaKey) {
- return selectAreaRecursive(areaKey, true);
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given area (recursive).
- *
- * @param areaKey the area key, not null
- * @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<Configuration> selectAreaRecursive(String areaKey, boolean stripKeys) {
- return config -> {
- Map<String, String> area = new HashMap<>();
- String lookupKey = areaKey + '.';
- area.putAll(
- config.getProperties().entrySet().stream()
- .filter(e -> e.getKey().startsWith(lookupKey))
- .collect(Collectors.toMap(
- e -> stripKeys ? e.getKey().substring(areaKey.length() + 1) : e.getKey(),
- Map.Entry::getValue)));
- return Configuration.from(PropertySourceBuilder.of("area (recursive): " + areaKey).addMap(area).build());
- };
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/config/AbstractConfiguration.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/config/AbstractConfiguration.java b/dormant/core/src/main/java/org/apache/tamaya/core/config/AbstractConfiguration.java
deleted file mode 100644
index 8289d64..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/config/AbstractConfiguration.java
+++ /dev/null
@@ -1,55 +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.util.Optional;
-
-import org.apache.tamaya.*;
-import org.apache.tamaya.core.properties.AbstractPropertySource;
-import old.PropertyAdapterProviderSpi;
-import org.apache.tamaya.spi.ServiceContext;
-
-/**
- * Abstract implementation class for {@link org.apache.tamaya.Configuration}, which supports optimistic
- * locking and mutability.
- */
-public abstract class AbstractConfiguration extends AbstractPropertySource implements Configuration{
-
- private static final long serialVersionUID = 503764580971917964L;
-
- private final Object LOCK = new Object();
-
- protected AbstractConfiguration(String name){
- super(name);
- }
-
-
- @Override
- public <T> Optional<T> get(String key, Class<T> type){
- PropertyAdapterProviderSpi as = ServiceContext.getInstance().getSingleton(PropertyAdapterProviderSpi.class);
- PropertyAdapter<T> adapter = as.getPropertyAdapter(type);
- if(adapter == null){
- throw new ConfigException(
- "Can not adapt config property '" + key + "' to " + type.getName() + ": no such " +
- "adapter.");
- }
- return getAdapted(key, adapter);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigFunctions.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigFunctions.java b/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigFunctions.java
deleted file mode 100644
index 7306fff..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigFunctions.java
+++ /dev/null
@@ -1,239 +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 old.MappedConfiguration;
-import org.apache.tamaya.ConfigQuery;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.properties.PropertySourceBuilder;
-
-import java.util.*;
-import java.util.function.Predicate;
-import java.util.function.UnaryOperator;
-import java.util.stream.Collectors;
-
-/**
- * Accessor that provides useful functions along with configuration.
- */
-public final class ConfigFunctions {
- /**
- * Private singleton constructor.
- */
- private ConfigFunctions() {
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given area (non recursive). Hereby
- * the area key is stripped away fromMap the resulting key.
- *
- * @param areaKey the area key, not null
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<Configuration> selectArea(String areaKey) {
- return selectArea(areaKey, true);
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given area (non recursive).
- *
- * @param areaKey the area key, not null
- * @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<Configuration> selectArea(String areaKey, boolean stripKeys) {
- return config -> {
- Map<String, String> area = new HashMap<>();
- area.putAll(
- config.getProperties().entrySet().stream()
- .filter(e -> isKeyInArea(e.getKey(), areaKey))
- .collect(Collectors.toMap(
- e -> stripKeys ? e.getKey().substring(areaKey.length() + 1) : e.getKey(),
- Map.Entry::getValue)));
- return PropertySourceBuilder.of("area: " + areaKey).addMap(area).build().toConfiguration();
- };
- }
-
- /**
- * Calculates the current area key and compares it with the given key.
- *
- * @param key the fully qualified entry key, not null
- * @param areaKey the area key, not null
- * @return true, if the entry is exact in this area
- */
- public static boolean isKeyInArea(String key, String areaKey) {
- int lastIndex = key.lastIndexOf('.');
- String curAreaKey = lastIndex > 0 ? key.substring(0, lastIndex) : "";
- return curAreaKey.equals(areaKey);
- }
-
- /**
- * Return a query to evaluate the set with all fully qualifies area names. This method should return the areas as accurate as possible,
- * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @return s set with all areas, never {@code null}.
- */
- public static ConfigQuery<Set<String>> getAreas() {
- return config -> {
- final Set<String> areas = new HashSet<>();
- config.getProperties().keySet().forEach(s -> {
- int index = s.lastIndexOf('.');
- if (index > 0) {
- areas.add(s.substring(0, index));
- } else {
- areas.add("<root>");
- }
- });
- return areas;
- };
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified area names, containing the transitive closure also including all
- * subarea names, regardless if properties are accessible or not. This method should return the areas as accurate
- * as possible, but may not provide a complete set of areas that are finally accessible, especially when the
- * underlying storage does not support key iteration.
- *
- * @return s set with all transitive areas, never {@code null}.
- */
- public static ConfigQuery<Set<String>> getTransitiveAreas() {
- return config -> {
- final Set<String> transitiveAreas = new HashSet<>();
- config.query(getAreas()).forEach(s -> {
- int index = s.lastIndexOf('.');
- if (index < 0) {
- transitiveAreas.add("<root>");
- } else {
- while (index > 0) {
- s = s.substring(0, index);
- transitiveAreas.add(s);
- index = s.lastIndexOf('.');
- }
- }
- });
- return transitiveAreas;
- };
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified area names, containing only the
- * areas that match the predicate and have properties attached. This method should return the areas as accurate as possible,
- * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param predicate A predicate to deternine, which areas should be returned, not {@code null}.
- * @return s set with all areas, never {@code null}.
- */
- public static ConfigQuery<Set<String>> getAreas(final Predicate<String> predicate) {
- return config -> {
- return config.query(getAreas()).stream().filter(predicate).collect(Collectors.toCollection(TreeSet::new));
- };
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified area names, containing the transitive closure also including all
- * subarea names, regardless if properties are accessible or not. This method should return the areas as accurate as possible,
- * but may not provide a complete set of areas that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param predicate A predicate to deternine, which areas should be returned, not {@code null}.
- * @return s set with all transitive areas, never {@code null}.
- */
- public static ConfigQuery<Set<String>> getTransitiveAreas(Predicate<String> predicate) {
- return config -> {
- return config.query(getTransitiveAreas()).stream().filter(predicate).collect(Collectors.toCollection(TreeSet::new));
- };
- }
-
- /**
- * Return a query to evaluate to evaluate if an area exists. In case where the underlying storage implementation does not allow
- * querying the keys available, {@code false} should be returned.
- *
- * @param areaKey the configuration area (sub)path.
- * @return {@code true}, if such a node exists.
- */
- public static ConfigQuery<Boolean> containsArea(String areaKey) {
- return config -> {
- return config.query(getAreas()).contains(areaKey);
- };
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given area (recursive). Hereby
- * the area key is stripped away fromMap the resulting key.
- *
- * @param areaKey the area key, not null
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<Configuration> selectAreaRecursive(String areaKey) {
- return selectAreaRecursive(areaKey, true);
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given area (recursive).
- *
- * @param areaKey the area key, not null
- * @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<Configuration> selectAreaRecursive(String areaKey, boolean stripKeys) {
- return config -> {
- Map<String, String> area = new HashMap<>();
- String lookupKey = areaKey + '.';
- area.putAll(
- config.getProperties().entrySet().stream()
- .filter(e -> e.getKey().startsWith(lookupKey))
- .collect(Collectors.toMap(
- e -> stripKeys ? e.getKey().substring(areaKey.length() + 1) : e.getKey(),
- Map.Entry::getValue)));
- return PropertySourceBuilder.of("area (recursive): " + areaKey).addMap(area).build().toConfiguration();
- };
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given area (non recursive). Hereby
- * the area key is stripped away fromMap the resulting key.
- *
- * @param areaKey the area key, not null
- * @param mappedAreaKey the target key, not null
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<Configuration> mapArea(String areaKey, String mappedAreaKey) {
- return mapKeys(key -> key.startsWith(areaKey + '.') ?
- mappedAreaKey + key.substring(areaKey.length()) : key);
- }
-
- /**
- * Creates a {@link UnaryOperator} that creates a {@link org.apache.tamaya.Configuration} that maps any keys as
- * defined by the {@code keyMapper} given. If the {@code keyMapper} returns
- * {@code null} for a keys, it is removed from the resulting map.
- *
- * @param keyMapper the key mapper, not null
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<Configuration> mapKeys(UnaryOperator<String> keyMapper) {
- return (c) -> new MappedConfiguration(c, keyMapper);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/internal/MetaConfig.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/MetaConfig.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/MetaConfig.java
deleted file mode 100644
index 6233a93..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/MetaConfig.java
+++ /dev/null
@@ -1,70 +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.internal;
-
-import org.apache.tamaya.core.properties.ConfigurationFormat;
-import org.apache.tamaya.core.resource.Resource;
-import org.apache.tamaya.spi.ServiceContext;
-import org.apache.tamaya.core.resource.ResourceLoader;
-
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Singleton to read the configuration for the configuration system
- * fromMap {@code META-INF/config.properties}.
- * Created by Anatole on 17.10.2014.
- */
-public final class MetaConfig {
-
- private static final Logger LOG = Logger.getLogger(MetaConfig.class.getName());
-
- private static final MetaConfig INSTANCE = new MetaConfig();
-
- private Map<String,String> properties = new HashMap<>();
-
- private MetaConfig(){
- List<Resource> resources = ServiceContext.getInstance().getService(ResourceLoader.class).get().getResources(MetaConfig.class.getClassLoader(),
- "classpath:META-INF/config.properties");
- for(Resource res:resources){
- List<ConfigurationFormat> formats = ConfigurationFormat.getFormats(res);
- for(ConfigurationFormat format:formats) {
- try {
-
- Map<String, String> read = format.readConfiguration(res);
- properties.putAll(read);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e, () -> "Error reading meta configuration fromMap " + res);
- }
- }
- }
- }
-
- public static String getKey(String key){
- return INSTANCE.properties.get(key);
- }
-
- public static String getOrDefault(String key, String defaultValue){
- return INSTANCE.properties.getOrDefault(key, defaultValue);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FallbackSimpleConfigProvider.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FallbackSimpleConfigProvider.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FallbackSimpleConfigProvider.java
deleted file mode 100644
index dc34c55..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FallbackSimpleConfigProvider.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.apache.tamaya.core.internal.config;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.properties.AggregationPolicy;
-import org.apache.tamaya.core.properties.PropertySourceBuilder;
-import old.ConfigurationProviderSpi;
-import org.apache.tamaya.core.properties.PropertySourcesBuilder;
-
-/**
- * Implementation of a default config provider used as fallback, if no {@link old.ConfigurationProviderSpi}
- * instance is registered for providing the {@code default} {@link org.apache.tamaya.Configuration}. The providers loads the follwing
- * config format:
- * <ul>
- * <li>Classpath: META-INF/cfg/default/**/*.xml, META-INF/cfg/default/**/*.properties, META-INF/cfg/default/**/*.ini</li>
- * <li>Classpath: META-INF/cfg/config/#42;#42;/#42;.xml, META-INF/cfg/config/#42;#42;/#42;.properties, META-INF/cfg/config/#42;#42;/#42;.ini</li>
- * <li>Files: defined by the system property -Dconfig.dir</li>
- * <li>system properties</li>
- * </ul>
- */
-public class FallbackSimpleConfigProvider implements ConfigurationProviderSpi {
-
- private static final String DEFAULT_CONFIG_NAME = "default";
-
- /**
- * The loaded configuration instance.
- */
- private volatile Configuration configuration;
-
- @Override
- public String getConfigName() {
- return DEFAULT_CONFIG_NAME;
- }
-
- @Override
- public Configuration getConfiguration() {
- Configuration cfg = configuration;
- if (cfg == null) {
- reload();
- cfg = configuration;
- }
- return cfg;
- }
-
-
- @Override
- public void reload() {
- this.configuration = Configuration.from(
- PropertySourcesBuilder.of()
- .addPaths("META-INF/cfg/default/**/*.xml", "META-INF/cfg/default/**/*.properties", "META-INF/cfg/default/**/*.ini")
- .build())
- .addProviders(PropertySourcesBuilder.of("CL default")
- .withAggregationPolicy(AggregationPolicy.LOG_ERROR)
- .addPaths("META-INF/cfg/config/**/*.xml", "META-INF/cfg/config/**/*.properties", "META-INF/cfg/config/**/*.ini")
- .build())
- .addSystemProperties()
- .addEnvironmentProperties()
- .build());
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileChangeListener.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileChangeListener.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileChangeListener.java
deleted file mode 100644
index e1a3026..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileChangeListener.java
+++ /dev/null
@@ -1,138 +0,0 @@
-package org.apache.tamaya.core.internal.config;
-
-import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE;
-import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
-import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
-
-import java.io.IOException;
-import java.nio.file.FileSystem;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardWatchEventKinds;
-import java.nio.file.WatchEvent;
-import java.nio.file.WatchKey;
-import java.nio.file.WatchService;
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.apache.tamaya.ConfigException;
-import old.ConfigurationProviderSpi;
-
-/**
- * Class that has the responsibility to watch the folder and then commit the {@link ConfigurationProviderSpi}
- * to commit the Configuration from the properties or xml files, another ones will be ignored.
- * @see FilesPropertiesConfigProvider
- * This listener will wait to events and wait to one second to watch again.
- * <p>If new file was created or modified will commit from this file.</p>
- * <p>If a file was removed then the listener will load using all files left.</p>
- * @author otaviojava
- */
-class FileChangeListener implements Runnable {
-
- private static final Logger LOGGER = Logger.getLogger(FileChangeListener.class.getName());
-
- private WatchService watchService;
-
- private FileChangeObserver observer;
-
- private Map<String, String> configurationMap;
-
- private Path directory;
-
- private FileReader fileReader = new FileReader();
-
- public FileChangeListener(FileChangeObserver observer, Map<String, String> mapConfiguration, Path directory) {
- this.observer = observer;
- this.configurationMap = mapConfiguration;
- this.directory = directory;
- this.watchService = getWatchService();
-
- if (Objects.nonNull(watchService) && Objects.nonNull(directory)) {
- try {
- directory.register(watchService, ENTRY_DELETE, ENTRY_MODIFY,
- ENTRY_CREATE);
- } catch (IOException e) {
- throw new FileChangeListenerException("An error happened when does try to registry to watch the folder", e);
- }
- }
- }
-
-
- @Override
- public void run() {
- if (Objects.isNull(watchService) || Objects.isNull(directory)) {
- return;
- }
- while (true) {
- watchFolder();
- }
- }
-
-
- private void watchFolder() {
- try {
- WatchKey watckKey = watchService.take();
- boolean needUpdate = false;
- for (WatchEvent<?> event : watckKey.pollEvents()) {
- Path keyDirectory = (Path) watckKey.watchable();
- if(listenerPath(event, keyDirectory)) {
- needUpdate = true;
- }
- }
-
- if (needUpdate) {
- observer.update(configurationMap);
- }
- watckKey.reset();
- Thread.sleep(1_000L);
- } catch (Exception e) {
- throw new FileChangeListenerException("An error happened when does try to watch the folder", e);
- }
- }
-
- private boolean listenerPath(WatchEvent<?> event, Path keyDirectory) {
- boolean wasModified = false;
- Path path = keyDirectory.resolve((Path)event.context());
- if(fileReader.isObservavleFile(path)) {
-
- if (event.kind() == ENTRY_CREATE || event.kind() == ENTRY_MODIFY) {
- wasModified = true;
- configurationMap.putAll(fileReader.runFile(path.toAbsolutePath()));
- LOGGER.info("An event was detected in file: " + path.getFileName());
- }
-
- if (event.kind() == StandardWatchEventKinds.ENTRY_DELETE) {
- wasModified = true;
- configurationMap = fileReader.runFiles(directory);
- LOGGER.info("A remotion event was detected in file: " + path.getFileName());
- }
-
- } else {
- LOGGER.info("Ignoring the file: " + path.getFileName() + " because is not a properties or xml file");
- }
- return wasModified;
- }
-
- private WatchService getWatchService() {
- try {
- FileSystem fileSystem = Paths.get(".").getFileSystem();
- return fileSystem.newWatchService();
- } catch (IOException e) {
- LOGGER.log(Level.WARNING, "The file System does not supports WatchService", e);
- return null;
- }
-
- }
-
- class FileChangeListenerException extends ConfigException {
-
- private static final long serialVersionUID = -8965486770881001513L;
-
- public FileChangeListenerException(String message, Throwable cause) {
- super(message, cause);
- }
-
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileChangeObserver.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileChangeObserver.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileChangeObserver.java
deleted file mode 100644
index a7d4ba9..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileChangeObserver.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.tamaya.core.internal.config;
-
-import java.util.Map;
-
-/**
- * Observer to be used in {@link FileChangeListener} to commit all configurations and provider.
- * @author otaviojava
- */
-interface FileChangeObserver {
-
- void update(Map<String, String> configurationMap);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileConfiguration.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileConfiguration.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileConfiguration.java
deleted file mode 100644
index 4f76180..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileConfiguration.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.apache.tamaya.core.internal.config;
-
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-import org.apache.tamaya.Configuration;
-
-/**
- * Implementation of Configuration which the information is from xml or properties files.
- * Once the File modified, it will commit automatically by provider.
- * @see FilesPropertiesConfigProvider
- * @see FileChangeObserver
- * @author otaviojava
- */
-class FileConfiguration implements Configuration, FileChangeObserver {
-
- private Map<String, String> configurationMap;
-
- public FileConfiguration(Map<String, String> configurationMap) {
- this.configurationMap = configurationMap;
- }
-
- @Override
- public Optional<String> get(String key) {
- return Optional.ofNullable(configurationMap.get(key));
- }
-
- @Override
- public String getName() {
- return "files.config";
- }
-
- @Override
- public Map<String, String> getProperties() {
- return configurationMap;
- }
-
- @Override
- public void update(Map<String, String> configurationMap) {
- synchronized (this) {
- this.configurationMap = configurationMap;
- }
- }
-
- @Override
- public String toString() {
- return "org.apache.tamaya.core.internal.config.FileConfiguration: " + configurationMap.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(configurationMap);
- }
-
- @Override
- public boolean equals(Object obj) {
- if(this == obj) {
- return true;
- }
- if(Configuration.class.isInstance(obj)) {
- Configuration other = Configuration.class.cast(obj);
- return Objects.equals(configurationMap, other.getProperties());
- }
-
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileReader.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileReader.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileReader.java
deleted file mode 100644
index 287ccc4..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FileReader.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.apache.tamaya.core.internal.config;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.InvalidPropertiesFormatException;
-import java.util.Map;
-import java.util.Properties;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-/**
- * Class to read a file and creates a {@link Map} of {@link String}.
- * The implementation of {@link Map} will {@link HashMap}
- * @author otaviojava
- */
-class FileReader {
-
- private static final String EXTENSIONS_ACCEPTED = "*.{xml,properties}";
-
- public Map<String, String> runFiles(Path directory) {
- Properties properties = createProperties(directory);
- return properties
- .stringPropertyNames()
- .stream()
- .collect(
- Collectors.toMap(Function.identity(),
- properties::getProperty));
- }
-
- public Map<String, String> runFile(Path path) {
- Properties properties = new Properties();
- try {
- loadFile(properties, path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return properties
- .stringPropertyNames()
- .stream()
- .collect(
- Collectors.toMap(Function.identity(),
- properties::getProperty));
- }
-
- private Properties createProperties(Path directory) {
- Properties properties = new Properties();
-
- try {
- for (Path path : Files.newDirectoryStream(directory, EXTENSIONS_ACCEPTED)) {
- loadFile(properties, path);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return properties;
- }
-
- private void loadFile(Properties properties, Path path) throws IOException,
- InvalidPropertiesFormatException {
- if (isXmlExtension(path)) {
- properties.loadFromXML(Files.newInputStream(path));
- } else {
- properties.load(Files.newInputStream(path));
- }
-}
-
- private boolean isXmlExtension(Path path) {
- return path.toString().toLowerCase().endsWith(".xml");
- }
-
- private boolean isPropertiesExtension(Path path) {
- return path.toString().toLowerCase().endsWith(".properties");
- }
-
- public boolean isObservavleFile(Path path) {
- return isPropertiesExtension(path) || isXmlExtension(path);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FilesPropertiesConfigProvider.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FilesPropertiesConfigProvider.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FilesPropertiesConfigProvider.java
deleted file mode 100644
index b171d39..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/FilesPropertiesConfigProvider.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.apache.tamaya.core.internal.config;
-
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import old.ConfigurationProviderSpi;
-
-/**
- * This implementation run in a folder and once found xml and properties files
- * will create the Configuration, when one file is created, deleted or modified the configuration will commit
- * automatically.
- * The default folder is META-INF/configuration, but you can change using the absolute path in
- * "-Dtamaya.configbase" parameter.
- * @author otaviojava
- */
-public class FilesPropertiesConfigProvider implements ConfigurationProviderSpi, FileChangeObserver {
-
- private static final String DEFAULT_CONFIG_NAME = "files.configuration";
-
- private Map<String, String> configurationMap = Collections.emptyMap();
-
- private ExecutorService executor = Executors.newSingleThreadExecutor();
-
- private List<FileChangeObserver> fileChangeObservers = new ArrayList<>();
-
- public FilesPropertiesConfigProvider() {
- Path directory = getDirectory();
- if (Objects.nonNull(directory)) {
- configurationMap = new FileReader().runFiles(directory);
- Runnable runnable = new FileChangeListener(this, configurationMap, directory);
- executor.execute(runnable);
- } else {
- executor.shutdown();
- }
- }
-
- @Override
- public String getConfigName() {
- return DEFAULT_CONFIG_NAME;
- }
-
- private Path getDirectory() {
- String absolutePath = System.getProperty("tamaya.configbase");
-
- if(Objects.nonNull(absolutePath)) {
- Path path = Paths.get(absolutePath);
- if(Files.isDirectory(path)) {
- return path;
- }
- }
-
- URL resource = FilesPropertiesConfigProvider.class.getResource("/META-INF/configuration/");
- if (Objects.nonNull(resource)) {
- try {
- return Paths.get(resource.toURI());
- } catch (URISyntaxException e) {
- throw new ConfigException("An error to find the directory to watch", e);
- }
- }
- return null;
- }
-
-
- @Override
- public Configuration getConfiguration() {
- return new FileConfiguration(Collections.unmodifiableMap(configurationMap));
- }
-
- @Override
- public void reload() {
- Path directory = getDirectory();
- if (Objects.nonNull(directory)) {
- configurationMap = new FileReader().runFiles(directory);
- }
- }
-
- @Override
- public void update(Map<String, String> configurationMap) {
- synchronized (this) {
- this.configurationMap = configurationMap;
- Map<String, String> unmodifiableMap = Collections.unmodifiableMap(configurationMap);
- fileChangeObservers.forEach(fi -> fi.update(unmodifiableMap));
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/DefaultConfigurationFormatSpi.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/DefaultConfigurationFormatSpi.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/DefaultConfigurationFormatSpi.java
deleted file mode 100644
index c4b7ad2..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/format/DefaultConfigurationFormatSpi.java
+++ /dev/null
@@ -1,38 +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.internal.format;
-
-import org.apache.tamaya.core.resource.Resource;
-import org.apache.tamaya.core.properties.ConfigurationFormat;
-import org.apache.tamaya.core.spi.ConfigurationFormatSpi;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-import org.apache.tamaya.spi.ServiceContext;
-
-/**
- * Singleton accessor to access registered reader mechanism.
- */
-public final class DefaultConfigurationFormatSpi implements ConfigurationFormatSpi {
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/properties/FrozenPropertySource.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/properties/FrozenPropertySource.java b/dormant/core/src/main/java/org/apache/tamaya/core/properties/FrozenPropertySource.java
deleted file mode 100644
index 2fe1237..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/properties/FrozenPropertySource.java
+++ /dev/null
@@ -1,87 +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.spi.PropertySource;
-
-import java.io.Serializable;
-import java.lang.Override;
-import java.util.Collections;
-import java.util.Map;
-
-/**
- * Configuration implementation that stores all current values current a given (possibly dynamic, contextual and non remote
- * capable instance) and is fully serializable.
- */
-public final class FrozenPropertySource implements PropertySource, Serializable{
- private static final long serialVersionUID = -6373137316556444171L;
-
- private int ordinal;
- private String name;
- private Map<String,String> properties;
-
- /**
- * Constructor.
- * @param propertySource The base configuration.
- */
- private FrozenPropertySource(PropertySource propertySource){
- this.name = propertySource.getName();
- this.ordinal = propertySource.ordinal();
- this.properties = Collections.unmodifiableMap(new HashMap<>(propertySource.getProperties()));
- }
-
- public static final FrozenPropertySource of(PropertySource propertySource){
- if(propertySource instanceof FrozenPropertySource){
- return propertySource;
- }
- return new FrozenPropertySource(propertySource);
- }
-
- @Override
- public Map<String,String> getProperties(){
- return properties;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- FrozenPropertySource that = (FrozenPropertySource) o;
-
- if (!name.equals(that.name)) return false;
- if (!properties.equals(that.properties)) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = name.hashCode();
- result = 31 * result + properties.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return "FrozenPropertySource{" +
- ", name=" + name +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/46ede97c/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.java b/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.java
deleted file mode 100644
index f089f42..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.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.properties;
-
-import org.apache.tamaya.spi.PropertySource;
-
-import java.util.*;
-import java.util.function.Predicate;
-import java.util.function.UnaryOperator;
-
-/**
- * Accessor that provides useful functions along with configuration.
- */
-public final class PropertySourceFunctions {
- /**
- * Private singleton constructor.
- */
- private PropertySourceFunctions() {
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given area (non recursive). Hereby
- * the area key is stripped away fromMap the resulting key.
- *
- * @param areaKey the area key, not null
- * @param mappedAreaKey the target key, not null
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<PropertySource> mapArea(String areaKey, String mappedAreaKey) {
- return mapKeys(key -> key.startsWith(areaKey + '.') ?
- mappedAreaKey + key.substring(areaKey.length()) : key);
- }
-
- /**
- * Creates a {@link java.util.function.UnaryOperator} that creates a {@link org.apache.tamaya.Configuration} that maps any keys as
- * defined by the {@code keyMapper} given. If the {@code keyMapper} returns
- * {@code null} for a keys, it is removed from the resulting map.
- *
- * @param keyMapper the key mapper, not null
- * @return the area configuration, with the areaKey stripped away.
- */
- public static UnaryOperator<PropertySource> mapKeys(UnaryOperator<String> keyMapper) {
- return (c) -> new MappedPropertySource(c, keyMapper);
- }
-
-
-
- /**
- * Intersetcs the current properties with the given {@link org.apache.tamaya.spi.PropertySource} instance.
- *
- * @param providers the maps to be intersected, not null.
- * @return the builder for chaining.
- */
- public UnaryOperator<PropertySource> intersect(PropertySource... providers) {
- if (providers.length == 0) {
- return this;
- }
- String name = this.currentName;
- if (currentName == null) {
- name = "<intersection> -> " + Arrays.toString(providers);
- }
- return addPropertySources(PropertySourceFactory.intersected(name, aggregationPolicy, Arrays.asList(providers)));
- }
-
-
- /**
- * Filters the current properties based on the given predicate..
- *
- * @param filter the filter to be applied, not null.
- * @return the new filtering instance.
- */
- public UnaryOperator<PropertySource> filter(Predicate<String> filter) {
- String name = this.currentName;
- if (currentName == null) {
- name = "<filtered> -> " + filter;
- }
- current = PropertySourceFactory.filtered(name, filter, current);
- this.currentName = null;
- return this;
- }
-
-
- /**
- * 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.
- */
- public PropertySourceBuilder replace(Map<String, String> replacementMap) {
- String name = this.currentName;
- if (currentName == null) {
- name = "<replacement> -> current=" + current.getName() + " with =" + replacementMap;
- }
- current = PropertySourceFactory.replacing(name, current, replacementMap);
- this.currentName = null;
- return this;
- }
-
-}