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/01/03 12:59:21 UTC
[12/27] incubator-tamaya git commit: TAMAYA-19: Reorganized dormant
part for better focus of future discussions.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java b/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java
deleted file mode 100644
index f8b1c95..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationBuilder.java
+++ /dev/null
@@ -1,374 +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.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.BiFunction;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.PropertySource;
-import org.apache.tamaya.core.properties.AggregationPolicy;
-import org.apache.tamaya.core.properties.PropertySourceBuilder;
-
-/**
-* Builder for assembling non trivial {@link org.apache.tamaya.Configuration} instances.
-*/
-public final class ConfigurationBuilder {
-
- /**
- * The final meta info to be used, or null, if a default should be generated.
- */
- private PropertySourceBuilder builderDelegate;
-
- /**
- * Private singleton constructor.
- */
- private ConfigurationBuilder(String name) {
- this.builderDelegate = PropertySourceBuilder.of(name);
- }
-
- /**
- * Private singleton constructor.
- */
- private ConfigurationBuilder(String name, PropertySource source) {
- this.builderDelegate = PropertySourceBuilder.of(name, source);
- }
-
- /**
- * Private singleton constructor.
- */
- private ConfigurationBuilder(PropertySource source) {
- this.builderDelegate = PropertySourceBuilder.of(source);
- }
-
-
- /**
- * Creates a new builder instance.
- *
- * @param provider the base provider to be used, not null.
- * @return a new builder instance, never null.
- */
- public static ConfigurationBuilder of(PropertySource provider) {
- return new ConfigurationBuilder(provider);
- }
-
- /**
- * Creates a new builder instance.
- *
- * @param name the provider name, not null.
- * @return a new builder instance, never null.
- */
- public static ConfigurationBuilder of(String name) {
- return new ConfigurationBuilder(Objects.requireNonNull(name));
- }
-
- /**
- * Creates a new builder instance.
- *
- * @return a new builder instance, never null.
- */
- public static ConfigurationBuilder of() {
- return new ConfigurationBuilder("<noname>");
- }
-
-
-
-
- /**
- * Sets the aggregation policy to be used, when adding additional property sets. The policy will
- * be active a slong as the builder is used or it is reset to another keys.
- *
- * @param aggregationPolicy the aggregation policy, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder withAggregationPolicy(AggregationPolicy aggregationPolicy) {
- this.builderDelegate.withAggregationPolicy(aggregationPolicy);
- return this;
- }
-
- /**
- * Sets the meta info to be used for the next operation.
- *
- * @param name the name, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder withName(String name) {
- this.builderDelegate.withName(name);
- return this;
- }
-
- /**
- * Adds the given providers with the current active {@link AggregationPolicy}. By
- * default {@link AggregationPolicy#OVERRIDE} is used.
- * @see #withAggregationPolicy(AggregationPolicy)
- * @param providers providers to be added, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder addProviders(PropertySource... providers) {
- this.builderDelegate.addProviders(providers);
- return this;
- }
-
- /**
- * Adds the given providers with the current active {@link AggregationPolicy}. By
- * default {@link AggregationPolicy#OVERRIDE} is used.
- * @see #withAggregationPolicy(AggregationPolicy)
- * @param providers providers to be added, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder addProviders(List<PropertySource> providers) {
- this.builderDelegate.addProviders(providers);
- return this;
- }
-
-
- /**
- * Creates a new {@link org.apache.tamaya.PropertySource} using the given command line arguments and adds it
- * using the current aggregation policy in place.
- *
- * @param args the command line arguments, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder addArgs(String... args) {
- this.builderDelegate.addArgs(args);
- return this;
- }
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.PropertySource} 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 are aggregated using the current aggregation policy active.
- *
- * @param paths the paths to be resolved by the {@code PathResolverService} , not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder addPaths(String... paths) {
- this.builderDelegate.addPaths(paths);
- return this;
- }
-
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.PropertySource} 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 are aggregated using the current aggregation policy active.
- *
- * @param paths the paths to be resolved by the {@code PathResolverService} , not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder addPaths(List<String> paths) {
- this.builderDelegate.addPaths(paths);
- return this;
- }
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.PropertySource} by reading the according URL resources.
- * Properties read are aggregated using the current aggregation policy active.
- *
- * @param urls the urls to be read, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder addURLs(URL... urls) {
- this.builderDelegate.addURLs(urls);
- return this;
- }
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.PropertySource} by reading the according URL resources.
- * Properties read are aggregated using the current aggregation policy active.
- *
- * @param urls the urls to be read, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder addURLs(List<URL> urls) {
- this.builderDelegate.addURLs(urls);
- return this;
- }
-
-
- /**
- * Creates a new read-only {@link org.apache.tamaya.PropertySource} based on the given map.
- * Properties read are aggregated using the current aggregation policy active.
- *
- * @param map the map to be added, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder addMap(Map<String, String> map) {
- this.builderDelegate.addMap(map);
- return this;
- }
-
-
- /**
- * Add the current environment properties. Aggregation is based on the current {@link AggregationPolicy} acvtive.
- *
- * @return the builder for chaining.
- */
- public ConfigurationBuilder addEnvironmentProperties() {
- this.builderDelegate.addEnvironmentProperties();
- return this;
- }
-
- /**
- * Add the current system properties. Aggregation is based on the current {@link AggregationPolicy} acvtive.
- *
- * @return the builder for chaining.
- */
- public ConfigurationBuilder addSystemProperties() {
- this.builderDelegate.addSystemProperties();
- return this;
- }
-
- /**
- * Adds the given {@link org.apache.tamaya.PropertySource} instances using the current {@link AggregationPolicy}
- * active.
- *
- * @param providers the maps to be included, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder aggregate(PropertySource... providers) {
- this.builderDelegate.aggregate(providers);
- return this;
- }
-
-
- /**
- * Adds the given {@link org.apache.tamaya.PropertySource} instances using the current {@link AggregationPolicy}
- * active.
- *
- * @param providers the maps to be included, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder aggregate(List<PropertySource> providers) {
- this.builderDelegate.aggregate(providers);
- return this;
- }
-
-
- /**
- * Intersetcs the current properties with the given {@link org.apache.tamaya.PropertySource} instance.
- *
- * @param providers the maps to be intersected, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder intersect(PropertySource... providers) {
- this.builderDelegate.intersect(providers);
- return this;
- }
-
-
- /**
- * Subtracts with the given {@link org.apache.tamaya.PropertySource} instance from the current properties.
- *
- * @param providers the maps to be subtracted, not null.
- * @return the builder for chaining.
- */
- public ConfigurationBuilder subtract(PropertySource... providers) {
- this.builderDelegate.subtract(providers);
- return this;
- }
-
-
- /**
- * Filters the current properties based on the given predicate..
- *
- * @param filter the filter to be applied, not null.
- * @return the new filtering instance.
- */
- public ConfigurationBuilder filter(Predicate<String> filter) {
- this.builderDelegate.filter(filter);
- return this;
- }
-
- /**
- * Filters the current {@link org.apache.tamaya.Configuration} with the given valueFilter.
- * @param valueFilter the value filter, not null.
- * @return the (dynamically) filtered source instance, never null.
- */
- public ConfigurationBuilder filterValues(BiFunction<String, String, String> valueFilter){
- this.builderDelegate.filterValues(valueFilter);
- return this;
- }
-
- /**
- * Creates a new contextual {@link org.apache.tamaya.PropertySource}. Contextual maps delegate to different instances current PropertyMap depending
- * on the keys returned fromMap the isolationP
- *
- * @param mapSupplier the supplier creating new provider instances
- * @param isolationKeySupplier the supplier providing contextual keys based on the current environment.
- */
- public ConfigurationBuilder addContextual(Supplier<PropertySource> mapSupplier,
- Supplier<String> isolationKeySupplier) {
- this.builderDelegate.addContextual(mapSupplier, isolationKeySupplier);
- 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 ConfigurationBuilder replace(Map<String, String> replacementMap) {
- this.builderDelegate.replace(replacementMap);
- return this;
- }
-
- /**
- * Build a new property provider based on the input.
- * @return a new property provider, or null.
- */
- public PropertySource buildPropertySource(){
- return this.builderDelegate.build();
- }
-
- /**
- * Build a new property provider based on the input.
- * @return a new property provider, or null.
- */
- public Configuration build(){
- return this.buildPropertySource().toConfiguration();
- }
-
- /**
- * Creates a {@link org.apache.tamaya.PropertySource} instance that is serializable and immutable,
- * so it can be sent over a network connection.
- *
- * @return the freezed instance, never null.
- */
- public PropertySource buildFreezedPropertySource() {
- return this.builderDelegate.buildFrozen();
- }
-
- /**
- * Creates a {@link org.apache.tamaya.PropertySource} instance that is serializable and immutable,
- * so it can be sent over a network connection.
- *
- * @return the freezed instance, never null.
- */
- public Configuration buildFreezed() {
- return FreezedConfiguration.of(this.buildFreezedPropertySource().toConfiguration());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationFormat.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationFormat.java b/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationFormat.java
deleted file mode 100644
index 8feaf6a..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/config/ConfigurationFormat.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.config;
-
-import org.apache.tamaya.core.resource.Resource;
-import org.apache.tamaya.core.spi.ConfigurationFormatSpi;
-import org.apache.tamaya.spi.ServiceContext;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * Implementations current this class encapsulate the mechanism how to read a
- * resource URI including interpreting the format correctly (e.g. xml vs.
- * properties).
- */
-public interface ConfigurationFormat{
-
- /**
- * Returns a unique identifier that identifies each format.
- *
- * @return the unique format id, mever null.
- */
- public String getFormatName();
-
- /**
- * Check if the given {@link java.net.URI} and path xpression qualify that this format should be
- * able to read them, e.g. checking for compatible file endings.
- *
- * @param resource the configuration location, not null
- * @return {@code true} if the given resource is in a format supported by
- * this instance.
- */
- boolean isAccepted(Resource resource);
-
- /**
- * Reads a {@link org.apache.tamaya.PropertySource} fromMap the given URI, using this format.
- *
- * @param resource the configuration location, not null
- * @return the corresponding {@link java.util.Map}, never {@code null}.
- */
- Map<String,String> readConfiguration(Resource resource);
-
- /**
- * Access a {@link ConfigurationFormat}.
- *
- * @param formatName the format name
- * @return the corresponding {@link ConfigurationFormat}, or {@code null}, if
- * not available for the given environment.
- */
- public static ConfigurationFormat of(String formatName){
- return ServiceContext.getInstance().getSingleton(ConfigurationFormatSpi.class).getFormat(formatName);
- }
-
- /**
- * Get a collection current the keys current the registered {@link ConfigurationFormat} instances.
- *
- * @return a collection current the keys current the registered {@link ConfigurationFormat} instances.
- */
- public static Collection<String> getFormatNames(){
- return ServiceContext.getInstance().getSingleton(ConfigurationFormatSpi.class).getFormatNames();
- }
-
- /**
- * Evaluate the matching format for a given resource.
- *
- * @param resource The resource
- * @return a matching configuration format, or {@code null} if no matching format could be determined.
- */
- public static ConfigurationFormat from(Resource resource){
- return ServiceContext.getInstance().getSingleton(ConfigurationFormatSpi.class).getFormat(resource);
-
- }
-
- /**
- * Get an instance for reading configuration fromMap a {@code .properties} file,
- * as defined by {@link java.util.Properties#load(java.io.InputStream)}.
- *
- * @return a format instance for reading configuration fromMap a {@code .properties} file, never null.
- */
- public static ConfigurationFormat getPropertiesFormat(){
- return ServiceContext.getInstance().getSingleton(ConfigurationFormatSpi.class).getPropertiesFormat();
- }
-
- /**
- * Get an instance for reading configuration fromMap a {@code .xml} properties file,
- * as defined by {@link java.util.Properties#loadFromXML(java.io.InputStream)}.
- *
- * @return a format instance for reading configuration fromMap a {@code .xml} properties file, never null.
- */
- public static ConfigurationFormat getXmlPropertiesFormat(){
- return ServiceContext.getInstance().getSingleton(ConfigurationFormatSpi.class).getXmlPropertiesFormat();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java b/dormant/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
deleted file mode 100644
index 43d6957..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/config/FreezedConfiguration.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.config;
-
-import org.apache.tamaya.*;
-import org.apache.tamaya.core.properties.PropertySourceBuilder;
-
-import java.io.Serializable;
-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.
- */
-final class FreezedConfiguration extends AbstractConfiguration implements Serializable{
- private static final long serialVersionUID = -6373137316556444171L;
-
- private PropertySource properties;
-
- /**
- * Constructor.
- * @param config The base configuration.
- */
- private FreezedConfiguration(Configuration config){
- super(config.getName());
- this.properties = PropertySourceBuilder.of(config).buildFrozen();
- }
-
- public static final Configuration of(Configuration config){
- if(config instanceof FreezedConfiguration){
- return config;
- }
- return new FreezedConfiguration(config);
- }
-
- @Override
- public Map<String,String> getProperties(){
- return properties.getProperties();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- FreezedConfiguration that = (FreezedConfiguration) o;
-
- if (!properties.equals(that.properties)) return false;
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = properties.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return "FreezedConfiguration{" +
- "properties=" + properties +
- ", name=" + name +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/config/FrozenConfiguration.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/config/FrozenConfiguration.java b/dormant/core/src/main/java/org/apache/tamaya/core/config/FrozenConfiguration.java
new file mode 100644
index 0000000..43d6957
--- /dev/null
+++ b/dormant/core/src/main/java/org/apache/tamaya/core/config/FrozenConfiguration.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.config;
+
+import org.apache.tamaya.*;
+import org.apache.tamaya.core.properties.PropertySourceBuilder;
+
+import java.io.Serializable;
+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.
+ */
+final class FreezedConfiguration extends AbstractConfiguration implements Serializable{
+ private static final long serialVersionUID = -6373137316556444171L;
+
+ private PropertySource properties;
+
+ /**
+ * Constructor.
+ * @param config The base configuration.
+ */
+ private FreezedConfiguration(Configuration config){
+ super(config.getName());
+ this.properties = PropertySourceBuilder.of(config).buildFrozen();
+ }
+
+ public static final Configuration of(Configuration config){
+ if(config instanceof FreezedConfiguration){
+ return config;
+ }
+ return new FreezedConfiguration(config);
+ }
+
+ @Override
+ public Map<String,String> getProperties(){
+ return properties.getProperties();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ FreezedConfiguration that = (FreezedConfiguration) o;
+
+ if (!properties.equals(that.properties)) return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = properties.hashCode();
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "FreezedConfiguration{" +
+ "properties=" + properties +
+ ", name=" + name +
+ '}';
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/config/MappedConfiguration.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/config/MappedConfiguration.java b/dormant/core/src/main/java/org/apache/tamaya/core/config/MappedConfiguration.java
deleted file mode 100644
index 736b33e..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/config/MappedConfiguration.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.apache.tamaya.core.config;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.UnaryOperator;
-
-import org.apache.tamaya.Configuration;
-
-/**
- * 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/b56817f7/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
index 8d3ad15..6233a93 100644
--- 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
@@ -18,9 +18,9 @@
*/
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.properties.ConfigurationFormat;
import org.apache.tamaya.core.resource.ResourceLoader;
@@ -44,16 +44,18 @@ public final class MetaConfig {
private Map<String,String> properties = new HashMap<>();
private MetaConfig(){
- List<Resource> resources = ServiceContext.getInstance().getSingleton(ResourceLoader.class).getResources(MetaConfig.class.getClassLoader(),
+ List<Resource> resources = ServiceContext.getInstance().getService(ResourceLoader.class).get().getResources(MetaConfig.class.getClassLoader(),
"classpath:META-INF/config.properties");
for(Resource res:resources){
- try{
- ConfigurationFormat format = ConfigurationFormat.from(res);
- Map<String,String> read = format.readConfiguration(res);
- properties.putAll(read);
- }
- catch(Exception e){
- LOG.log(Level.SEVERE, e, () -> "Error reading meta configuration fromMap " + res);
+ 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);
+ }
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultConfigurationSpi.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultConfigurationSpi.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultConfigurationSpi.java
deleted file mode 100644
index 8b7180c..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/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 org.apache.tamaya.core.internal.config;
-
-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.el.DefaultExpressionEvaluator;
-import org.apache.tamaya.core.internal.inject.ConfigTemplateInvocationHandler;
-import org.apache.tamaya.core.internal.inject.ConfigurationInjector;
-import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
-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/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultPropertyAdapterSpi.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultPropertyAdapterSpi.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultPropertyAdapterSpi.java
deleted file mode 100644
index f1b14e0..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/DefaultPropertyAdapterSpi.java
+++ /dev/null
@@ -1,168 +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.config;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.ZoneId;
-import java.util.Currency;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.PropertyAdapter;
-import org.apache.tamaya.annotation.WithPropertyAdapter;
-import org.apache.tamaya.spi.PropertyAdapterSpi;
-
-/**
- * Default codecs singleton, which provides default codesc for all kind of classes out of the box, which will be
- * instantiatable from configuration, if one of the following is given:
- * <ul>
- * <li>static factory methods using a String as simgle argument, called {@code of, valueOf, getInstance, instance, parse}</li>
- * <li>have constructors taking a single String</li>
- * </ul>
- */
-@SuppressWarnings({"rawtypes", "unchecked"})
-public class DefaultPropertyAdapterSpi implements PropertyAdapterSpi {
-
-
- private Map<Class,PropertyAdapter> adapters = new ConcurrentHashMap<>();
-
- public DefaultPropertyAdapterSpi(){
- // Add default adapters
- register(char.class, (s) -> s.charAt(0));
- register(byte.class, Byte::parseByte);
- register(short.class, Short::parseShort);
- register(int.class, Integer::parseInt);
- register(long.class, Long::parseLong);
- register(boolean.class, Boolean::parseBoolean);
- register(float.class, Float::parseFloat);
- register(double.class, Double::parseDouble);
-
- register(Character.class, (s) -> s.charAt(0));
- register(Byte.class, Byte::valueOf);
- register(Short.class, Short::valueOf);
- register(Integer.class, Integer::valueOf);
- register(Long.class, Long::valueOf);
- register(Boolean.class, Boolean::valueOf);
- register(Float.class, Float::valueOf);
- register(Double.class, Double::valueOf);
- register(BigDecimal.class, BigDecimal::new);
- register(BigInteger.class, BigInteger::new);
-
- register(Currency.class, Currency::getInstance);
-
- register(LocalDate.class, LocalDate::parse);
- register(LocalTime.class, LocalTime::parse);
- register(LocalDateTime.class, LocalDateTime::parse);
- register(ZoneId.class, ZoneId::of);
- }
-
- @Override
- public <T> PropertyAdapter<T> register(Class<T> targetType, PropertyAdapter<T> adapter){
- return adapters.put(targetType, adapter);
- }
-
- @Override
- public <T> PropertyAdapter<T> getPropertyAdapter(Class<T> targetType, WithPropertyAdapter adapterAnnot){
- PropertyAdapter codec = null;
- Class<? extends PropertyAdapter> configuredCodec = null;
- if(adapterAnnot != null){
- configuredCodec = adapterAnnot.value();
- if(!configuredCodec.equals(PropertyAdapter.class)){
- try{
- codec = configuredCodec.newInstance();
- }
- catch(Exception e){
- throw new ConfigException("Invalid codec configured.", e);
- }
- }
- }
- if(codec == null){
- codec = adapters.get(targetType);
- }
- if(codec == null){
- codec = getDefaultPropertyAdapter(targetType);
- }
- if(codec == null){
- throw new ConfigException("No Codec found for " + targetType.getName());
- }
- return codec;
- }
-
- private <T> PropertyAdapter getDefaultPropertyAdapter(Class<T> targetType) {
- PropertyAdapter<T> decoder = null;
- Method factoryMethod = getFactoryMethod(targetType, "of", "valueOf", "instanceOf", "getInstance", "from", "parse");
- if(factoryMethod!=null){
- decoder = (s) -> {
- try{
- factoryMethod.setAccessible(true);
- return targetType.cast(factoryMethod.invoke(s));
- }
- catch (Exception e){
- throw new ConfigException("Failed to decode '"+s+"'", e);
- }
- };
- }
- if(decoder==null) {
- try {
- Constructor<T> constr = targetType.getDeclaredConstructor(String.class);
- decoder = (s) -> {
- try{
- constr.setAccessible(true);
- return constr.newInstance(s);
- }
- catch (Exception e){
- throw new ConfigException("Failed to decode '"+s+"'", e);
- }
- };
- } catch (Exception e) {
- // ignore, TODO log finest
- }
- }
- if(decoder!=null) {
- return register(targetType, decoder);
- }
- return null;
- }
-
- private Method getFactoryMethod(Class<?> type, String... methodNames) {
- Method m;
- for(String name:methodNames){
- try{
- m = type.getDeclaredMethod(name, String.class);
- return m;
- }
- catch(Exception e){
- // ignore, TODO log finest
- }
- }
- return null;
- }
-
- @Override
- public boolean isTargetTypeSupported(Class<?> targetType){
- return adapters.containsKey(targetType);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/EnvPropertiesConfigProvider.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/EnvPropertiesConfigProvider.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/EnvPropertiesConfigProvider.java
deleted file mode 100644
index 6fd4672..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/EnvPropertiesConfigProvider.java
+++ /dev/null
@@ -1,54 +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.config;
-
-import org.apache.tamaya.core.properties.PropertySourceBuilder;
-import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
-
-import org.apache.tamaya.Configuration;
-
-/**
- * Provides a {@link org.apache.tamaya.Configuration} named 'environment.properties'
- * containing the current environment properties.
- *
- * Created by Anatole on 29.09.2014.
- */
-public class EnvPropertiesConfigProvider implements ConfigurationProviderSpi{
-
- private Configuration envConfig;
-
- public EnvPropertiesConfigProvider(){
- envConfig = Configuration.from(PropertySourceBuilder.of("environment.properties").addEnvironmentProperties().build());
- }
-
- @Override
- public String getConfigName(){
- return "environment.properties";
- }
-
- @Override
- public Configuration getConfiguration(){
- return envConfig;
- }
-
- @Override
- public void reload() {
- // nothing todo here
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/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
index 7bcfb77..240fc8a 100644
--- 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
@@ -3,10 +3,11 @@ 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 org.apache.tamaya.core.spi.ConfigurationProviderSpi;
+import old.ConfigurationProviderSpi;
+import org.apache.tamaya.core.properties.PropertySourcesBuilder;
/**
- * Implementation of a default config provider used as fallback, if no {@link org.apache.tamaya.core.spi.ConfigurationProviderSpi}
+ * 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 resources:
* <ul>
@@ -44,12 +45,10 @@ public class FallbackSimpleConfigProvider implements ConfigurationProviderSpi {
@Override
public void reload() {
this.configuration = Configuration.from(
- PropertySourceBuilder.of(DEFAULT_CONFIG_NAME)
- .addProviders(PropertySourceBuilder.of("CL default")
- .withAggregationPolicy(AggregationPolicy.LOG_ERROR)
+ PropertySourcesBuilder.of()
.addPaths("META-INF/cfg/default/**/*.xml", "META-INF/cfg/default/**/*.properties", "META-INF/cfg/default/**/*.ini")
.build())
- .addProviders(PropertySourceBuilder.of("CL default")
+ .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())
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/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
index afd1199..cdb7b33 100644
--- 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
@@ -17,7 +17,7 @@ import java.util.Objects;
import org.apache.log4j.Logger;
import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
+import old.ConfigurationProviderSpi;
/**
* Class that has the responsibility to watch the folder and then commit the {@link ConfigurationProviderSpi}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/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
index c2cf7fa..b171d39 100644
--- 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
@@ -15,7 +15,7 @@ import java.util.concurrent.Executors;
import org.apache.tamaya.ConfigException;
import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
+import old.ConfigurationProviderSpi;
/**
* This implementation run in a folder and once found xml and properties files
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/SystemPropertiesConfigProvider.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/SystemPropertiesConfigProvider.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/SystemPropertiesConfigProvider.java
deleted file mode 100644
index cdd90b2..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/config/SystemPropertiesConfigProvider.java
+++ /dev/null
@@ -1,54 +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.config;
-
-import org.apache.tamaya.core.properties.PropertySourceBuilder;
-import org.apache.tamaya.core.spi.ConfigurationProviderSpi;
-
-import org.apache.tamaya.Configuration;
-
-/**
- * Provides a {@link org.apache.tamaya.Configuration} named 'system.properties'
- * containing the current system properties.
- *
- * Created by Anatole on 29.09.2014.
- */
-public class SystemPropertiesConfigProvider implements ConfigurationProviderSpi{
-
- private Configuration systemConfig;
-
- public SystemPropertiesConfigProvider(){
- systemConfig = Configuration.from(PropertySourceBuilder.of("system.properties").addSystemProperties().build());
- }
-
- @Override
- public String getConfigName(){
- return "system.properties";
- }
-
- @Override
- public Configuration getConfiguration(){
- return systemConfig;
- }
-
- @Override
- public void reload() {
- // nothing todo here
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/DefaultExpressionEvaluator.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/DefaultExpressionEvaluator.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/DefaultExpressionEvaluator.java
deleted file mode 100644
index 457aa6c..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/DefaultExpressionEvaluator.java
+++ /dev/null
@@ -1,144 +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.el;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.spi.ServiceContext;
-import org.apache.tamaya.core.spi.ExpressionEvaluator;
-import org.apache.tamaya.core.spi.ExpressionResolver;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Default expression evaluator that manages several instances of {@link org.apache.tamaya.core.spi.ExpressionResolver}.
- * Each resolver is identified by a resolver id. Each expression passed has the form resolverId:resolverExpression, which
- * has the advantage that different resolvers can be active in parallel.
- */
-public final class DefaultExpressionEvaluator implements ExpressionEvaluator{
-
- private Map<String, ExpressionResolver> resolvers = new ConcurrentHashMap<>();
-
- private ExpressionResolver defaultResolver;
-
- public DefaultExpressionEvaluator() {
- for(ExpressionResolver resolver: ServiceContext.getInstance().getServices(ExpressionResolver.class)){
- resolvers.put(resolver.getResolverId(), resolver);
- }
- defaultResolver = ServiceContext.getInstance().getSingleton(ExpressionResolver.class);
- }
-
- /**
- * Resolves an expression in the form current <code>${resolverId:expression}</code>. The expression can be
- * part current any type current literal text. Also multiple expression, with different resolver ids are supported.
- * All control characters (${}\) can be escaped.<br>
- * So all the following are valid expressions:
- * <ul>
- * <li><code>${resolverId:expression}</code></li>
- * <li><code>bla bla ${resolverId:expression}</code></li>
- * <li><code>${resolverId:expression} bla bla</code></li>
- * <li><code>bla bla ${resolverId:expression} bla bla</code></li>
- * <li><code>${resolverId:expression}${resolverId2:expression2}</code></li>
- * <li><code>foo ${resolverId:expression}${resolverId2:expression2}</code></li>
- * <li><code>foo ${resolverId:expression} bar ${resolverId2:expression2}</code></li>
- * <li><code>${resolverId:expression}foo${resolverId2:expression2}bar</code></li>
- * <li><code>foor${resolverId:expression}bar${resolverId2:expression2}more</code></li>
- * <li><code>\${resolverId:expression}foo${resolverId2:expression2}bar</code> (first expression is escaped).</li>
- * </ul>
- *
- * @param expression the expression to be evaluated, not null
- * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}.
- * If no such config is passed, the default configurations provided by the current
- * registered providers are used.
- * @return the evaluated expression.
- * @throws org.apache.tamaya.ConfigException if resolution fails.
- */
- @Override
- public String evaluate(String expression, Configuration... configurations) {
- StringTokenizer tokenizer = new StringTokenizer(expression, "${}\\", true);
- boolean escaped = false;
- StringBuilder resolvedValue = new StringBuilder();
- StringBuilder current = new StringBuilder();
- while (tokenizer.hasMoreTokens()) {
- String token = tokenizer.nextToken();
- if (escaped) {
- switch (token) {
- case "n":
- current.append("\n");
- break;
- case "r":
- current.append("\r");
- break;
- case "t":
- current.append("\t");
- break;
- default:
- current.append(token);
- break;
- }
- escaped = false;
- continue;
- }
- switch (token) {
- case "\\":
- escaped = true;
- break;
- case "$":
- if (current.length() > 0) {
- resolvedValue.append(current);
- current.setLength(0);
- }
- if (!"{".equals(tokenizer.nextToken())) {
- throw new ConfigException("Invalid expression encountered: " + expression);
- }
- String subExpression = tokenizer.nextToken();
- if (!"}".equals(tokenizer.nextToken())) {
- throw new ConfigException("Invalid expression encountered: " + expression);
- }
- // evaluate sub-expression
- current.append(evaluteInternal(subExpression));
- break;
- default:
- current.append(token);
- }
- }
- if (current.length() > 0) {
- resolvedValue.append(current);
- }
- return resolvedValue.toString();
- }
-
- private String evaluteInternal(String subExpression) {
- int sepPos = subExpression.indexOf(':');
- if (sepPos > 0) {
- String refID = subExpression.substring(0, sepPos);
- String expression = subExpression.substring(sepPos + 1);
- return Optional.ofNullable(this.resolvers.get(refID)).orElseThrow(
- () -> new ConfigException("Resolver not found: " + refID + " in " + subExpression)
- ).resolve(expression);
- } else {
- return Optional.ofNullable(this.defaultResolver).orElseThrow(
- () -> new ConfigException("No default Resolver set, but required by " + subExpression)
- ).resolve(subExpression);
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/EnvironmentPropertyResolver.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/EnvironmentPropertyResolver.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/EnvironmentPropertyResolver.java
deleted file mode 100644
index 68d37a4..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/EnvironmentPropertyResolver.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.internal.el;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.spi.ExpressionResolver;
-
-import java.util.Optional;
-
-/**
- * Property resolver implementation that interprets the resolver expressions as environment properties.
- */
-public final class EnvironmentPropertyResolver implements ExpressionResolver{
-
- @Override
- public String getResolverId() {
- return "env";
- }
-
- @Override
- public String resolve(String expression, Configuration... configurations){
- return Optional.ofNullable(System.getenv(expression)).orElseThrow(
- () -> new ConfigException("No such environment property: " + expression)
- );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/SystemPropertyResolver.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/SystemPropertyResolver.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/SystemPropertyResolver.java
deleted file mode 100644
index c6eb298..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/el/SystemPropertyResolver.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.core.internal.el;
-
-import java.util.Optional;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.spi.ExpressionResolver;
-
-/**
- * Property resolver implementation that interprets the resolver expression as system property name.
- */
-public final class SystemPropertyResolver implements ExpressionResolver{
-
- @Override
- public String getResolverId() {
- return "sys";
- }
-
- @Override
- public String resolve(String expression, Configuration... configurations){
- return Optional.ofNullable(System.getProperty(expression)).orElseThrow(
- () -> new ConfigException("No such system property: " + expression)
- );
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/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
index eac0a3b..c4b7ad2 100644
--- 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
@@ -32,47 +32,7 @@ import org.apache.tamaya.spi.ServiceContext;
*/
public final class DefaultConfigurationFormatSpi implements ConfigurationFormatSpi {
- public ConfigurationFormat getFormat(String formatName){
- Objects.requireNonNull(formatName);
- try {
- for (ConfigurationFormat configFormat : ServiceContext.getInstance().getServices(ConfigurationFormat.class)) {
- if(formatName.equals(configFormat.getFormatName())){
- return configFormat;
- }
- }
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- return null;
- }
- public Collection<String> getFormatNames(){
- Set<String> result = new HashSet<>();
- try {
- result.addAll(ServiceContext.getInstance().getServices(ConfigurationFormat.class).stream().map(ConfigurationFormat::getFormatName)
- .collect(Collectors.toList()));
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- return result;
- }
-
- public ConfigurationFormat getFormat(Resource resource) {
- Objects.requireNonNull(resource);
- try {
- for (ConfigurationFormat configFormat : ServiceContext.getInstance().getServices(ConfigurationFormat.class)) {
- if(configFormat.isAccepted(resource)){
- return configFormat;
- }
- }
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- return null;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigChangeCallbackMethod.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigChangeCallbackMethod.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigChangeCallbackMethod.java
deleted file mode 100644
index f929f8e..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigChangeCallbackMethod.java
+++ /dev/null
@@ -1,67 +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.inject;
-
-import org.apache.tamaya.core.properties.PropertyChangeSet;
-import org.apache.tamaya.Configuration;
-
-import java.lang.reflect.Method;
-import java.util.Optional;
-import java.util.function.Consumer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * This class holds a method object that is annotated to be a callback method to be called on configuration
- * changes.
- */
-public final class ConfigChangeCallbackMethod {
-
- private static final Logger LOG = Logger.getLogger(ConfigChangeCallbackMethod.class.getName());
-
- private Method callbackMethod;
-
- public ConfigChangeCallbackMethod(Method callbackMethod) {
- this.callbackMethod = Optional.of(callbackMethod).filter(
- (m) -> void.class.equals(m.getReturnType()) &&
- m.getParameterCount() == 1 &&
- m.getParameterTypes()[0].equals(PropertyChangeSet.class)).get();
- }
-
- public Consumer<PropertyChangeSet> createConsumer(Object instance, Configuration... configurations){
- // TODO consider also environment !
- return event -> {
- for(Configuration cfg:configurations){
- if(event.getPropertySource().getName().equals(cfg.getName())){
- return;
- }
- }
- call(instance, event);
- };
- }
-
- public void call(Object instance, PropertyChangeSet configChangeEvent) {
- try {
- callbackMethod.setAccessible(true);
- callbackMethod.invoke(instance, configChangeEvent);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, e, () -> "Error calling ConfigChange callback method " + callbackMethod.getDeclaringClass().getName() + '.' + callbackMethod.getName() + " on " + instance);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigTemplateInvocationHandler.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigTemplateInvocationHandler.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigTemplateInvocationHandler.java
deleted file mode 100644
index ff2c309..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigTemplateInvocationHandler.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.internal.inject;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.core.internal.inject.ConfiguredType;
-import org.apache.tamaya.core.internal.inject.InjectionUtils;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.util.Objects;
-
-/**
- * Invocation handler that handles request against a configuration template.
- */
-public final class ConfigTemplateInvocationHandler implements InvocationHandler {
-
- /*
- TODO
- the given method (in case of a template) can use different caching strategies:
- 1) no caching (always evaluate the values completely) - slow.
- 2) instance caching (a cache per instance).
- 3) classloader caching...
- 4) global shared cache.
- */
-
-
- /**
- * Any overriding configurations.
- */
- private Configuration[] configurations;
- /**
- * The configured type.
- */
- private ConfiguredType type;
-
- /**
- * Creates a new handler instance.
- * @param type the target type, not null.
- * @param configurations overriding configurations to be used for evaluating the values for injection into {@code instance}, not null.
- * If no such config is passed, the default configurationa provided by the current
- * registered providers are used.
- */
- public ConfigTemplateInvocationHandler(Class<?> type, Configuration... configurations) {
- this.configurations = Objects.requireNonNull(configurations).clone();
- this.type = new ConfiguredType(Objects.requireNonNull(type));
- if (!type.isInterface()) {
- throw new IllegalArgumentException("Can only proxy interfaces as configuration templates.");
- }
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- if ("toString".equals(method.getName())) {
- return "Configured Proxy -> " + this.type.getType().getName();
- }
- String configValue = InjectionUtils.getConfigValue(method, configurations);
- return InjectionUtils.adaptValue(method, method.getReturnType(), configValue);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigurationInjector.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigurationInjector.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigurationInjector.java
deleted file mode 100644
index 8a51375..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfigurationInjector.java
+++ /dev/null
@@ -1,61 +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.inject;
-
-import org.apache.tamaya.Configuration;
-
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Simple injector singleton that also registers instances configured using weak references.
- */
-@SuppressWarnings("rawtypes")
-public final class ConfigurationInjector {
-
- private static final ConfigurationInjector INSTANCE = new ConfigurationInjector();
-
- private Map<Class, ConfiguredType> configuredTypes = new ConcurrentHashMap<>();
-
- /**
- * Extract the configuration annotation config and registers it per class, for later reuse.
- * @param type the type to be configured.
- * @return the configured type registered.
- */
- public static ConfiguredType registerType(Class<?> type){
- return INSTANCE.configuredTypes.computeIfAbsent(type, ConfiguredType::new);
- }
-
- /**
- * Configured the current instance and reigsterd necessary listener to forward config change events as
- * defined by the current annotations in place.
- * @param instance the instance to be configured
- * @param configurations Configuration instances that replace configuration served by services. This allows
- * more easily testing and adaption.
- */
- public static void configure(Object instance, Configuration... configurations){
- Class type = Objects.requireNonNull(instance).getClass();
- ConfiguredType configuredType = registerType(type);
- Objects.requireNonNull(configuredType).configure(instance, configurations);
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
deleted file mode 100644
index 51c3904..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredField.java
+++ /dev/null
@@ -1,126 +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.inject;
-
-import java.lang.reflect.Field;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.annotation.ConfiguredProperties;
-import org.apache.tamaya.annotation.ConfiguredProperty;
-import org.apache.tamaya.annotation.DefaultAreas;
-import org.apache.tamaya.core.internal.Utils;
-
-/**
- * Small class that contains and manages all information anc access to a configured field and a concrete instance current
- * it (referenced by a weak reference). It also implements all aspects current keys filtering, converting any applying the
- * final keys by reflection.
- */
-public class ConfiguredField {
-
-
- /**
- * The configured field instance.
- */
- private Field annotatedField;
-
- /**
- * Models a configured field and provides mechanisms for injection.
- *
- * @param field the field instance.
- */
- public ConfiguredField(Field field) {
- Objects.requireNonNull(field);
- this.annotatedField = field;
- }
-
- /**
- * Evaluate the initial keys fromMap the configuration and applyChanges it to the field.
- *
- * @param target the target instance.
- * @param configurations Configuration instances that replace configuration served by services. This allows
- * more easily testing and adaption.
- * @throws ConfigException if evaluation or conversion failed.
- */
- public void applyInitialValue(Object target, Configuration... configurations) throws ConfigException {
- String configValue = InjectionUtils.getConfigValue(this.annotatedField, configurations);
- applyValue(target, configValue, false, configurations);
- }
-
-
- /**
- * This method reapplies a changed configuration keys to the field.
- *
- * @param target the target instance, not null.
- * @param configValue the new keys to be applied, null will trigger the evaluation current the configured default keys.
- * @param resolve set to true, if expression resolution should be applied on the keys passed.
- * @throws ConfigException if the configuration required could not be resolved or converted.
- */
- public void applyValue(Object target, String configValue, boolean resolve, Configuration... configurations) throws ConfigException {
- Objects.requireNonNull(target);
- try {
- if (resolve && configValue != null) {
- // net step perform exression resolution, if any
- configValue = Configuration.evaluateValue(configValue, configurations);
- }
- // Check for adapter/filter
- Object value = InjectionUtils.adaptValue(this.annotatedField, this.annotatedField.getType(), configValue);
- annotatedField.setAccessible(true);
- annotatedField.set(target, value);
- } catch (Exception e) {
- throw new ConfigException("Failed to annotation configured field: " + this.annotatedField.getDeclaringClass()
- .getName() + '.' + annotatedField.getName(), e);
- }
- }
-
-
- /**
- * This method checks if the given (qualified) configuration key is referenced fromMap this field.
- * This is useful to determine, if a key changed in a configuration should trigger any change events
- * on the related instances.
- *
- * @param key the (qualified) configuration key, not null.
- * @return true, if the key is referenced.
- */
- public boolean matchesKey(String configName, String key) {
- Collection<ConfiguredProperty> configuredProperties = Utils.getAnnotations(this.annotatedField, ConfiguredProperty.class,
- ConfiguredProperties.class );
- for(ConfiguredProperty prop: configuredProperties){
- String currentName = prop.config().trim();
- if(currentName.isEmpty()){
- if(!"default".equals(configName)){
- continue;
- }
- }
- else if(!currentName.equals(configName)){
- continue;
- }
- DefaultAreas areasAnnot = this.annotatedField.getDeclaringClass().getAnnotation(DefaultAreas.class);
- List<String> keys = InjectionUtils.evaluateKeys(this.annotatedField, areasAnnot, prop);
- if( keys.contains(key)){
- return true;
- }
- }
- return false;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b56817f7/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredSetterMethod.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredSetterMethod.java b/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredSetterMethod.java
deleted file mode 100644
index 90497ae..0000000
--- a/dormant/core/src/main/java/org/apache/tamaya/core/internal/inject/ConfiguredSetterMethod.java
+++ /dev/null
@@ -1,136 +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.inject;
-
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.function.Consumer;
-
-import org.apache.tamaya.core.properties.PropertyChangeSet;
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.annotation.*;
-import org.apache.tamaya.core.internal.Utils;
-
-/**
- * Small class that contains and manages all information and access to a configured field and a concrete instance current
- * it (referenced by a weak reference). It also implements all aspects current keys filtering, conversions any applying the
- * final keys by reflection.
- */
-public class ConfiguredSetterMethod {
-
- /**
- * The configured field instance.
- */
- private Method setterMethod;
-
- /**
- * Models a configured field and provides mechanisms for injection.
- *
- * @param method the method instance.
- */
- public ConfiguredSetterMethod(Method method) {
- this.setterMethod = Optional.of(method).filter(
- (m) -> void.class.equals(m.getReturnType()) &&
- m.getParameterCount() == 1).get();
- }
-
- public Consumer<PropertyChangeSet> createConsumer(Object instance, Configuration... configurations){
- // TODO consider environment as well
- return event -> {
- for(Configuration cfg:configurations){
- if(event.getPropertySource().getName().equals(cfg.getName())){
- // ignore these changes, since this config is overridden.
- return;
- }
- }
- String configValue = InjectionUtils.getConfigValue(setterMethod, configurations);
- applyValue(instance,configValue, false, configurations);
- };
- }
-
-
- /**
- * Evaluate the initial keys fromMap the configuration and applyChanges it to the field.
- *
- * @param target the target instance.
- * @param configurations Configuration instances that replace configuration served by services. This allows
- * more easily testing and adaption.
- * @throws ConfigException if evaluation or conversion failed.
- */
- public void applyInitialValue(Object target, Configuration... configurations) throws ConfigException {
- String configValue = InjectionUtils.getConfigValue(this.setterMethod, configurations);
- applyValue(target, configValue, false, configurations);
- }
-
- /**
- * This method reapplies a changed configuration keys to the field.
- *
- * @param target the target instance, not null.
- * @param configValue the new keys to be applied, null will trigger the evaluation current the configured default keys.
- * @param resolve set to true, if expression resolution should be applied on the keys passed.
- * @throws org.apache.tamaya.ConfigException if the configuration required could not be resolved or converted.
- */
- public void applyValue(Object target, String configValue, boolean resolve, Configuration... configurations) throws ConfigException {
- Objects.requireNonNull(target);
- try {
- if (resolve && configValue != null) {
- // net step perform exression resolution, if any
- configValue = Configuration.evaluateValue(configValue, configurations);
- }
- // Check for adapter/filter
- Object value = InjectionUtils.adaptValue(this.setterMethod, this.setterMethod.getParameterTypes()[0], configValue);
- setterMethod.setAccessible(true);
- setterMethod.invoke(target, value);
- } catch (Exception e) {
- throw new ConfigException("Failed to annotation configured method: " + this.setterMethod.getDeclaringClass()
- .getName() + '.' + setterMethod.getName(), e);
- }
- }
-
-
-
- /**
- * This method checks if the given (qualified) configuration key is referenced fromMap this field.
- * This is useful to determine, if a key changed in a configuration should trigger any change events
- * on the related instances.
- *
- * @param key the (qualified) configuration key, not null.
- * @return true, if the key is referenced.
- */
- public boolean matchesKey(String key) {
- DefaultAreas areasAnnot = this.setterMethod.getDeclaringClass().getAnnotation(DefaultAreas.class);
- Collection<ConfiguredProperty> configuredProperties =
- Utils.getAnnotations(this.setterMethod, ConfiguredProperty.class, ConfiguredProperties.class);
- for(ConfiguredProperty prop: configuredProperties) {
- if (InjectionUtils.evaluateKeys(this.setterMethod, areasAnnot, prop).contains(key)) {
- return true;
- }
- }
- if (InjectionUtils.evaluateKeys(this.setterMethod, areasAnnot).contains(key)) {
- return true;
- }
- return false;
- }
-
-
-
-}