Repository: incubator-tamaya Updated Branches: refs/heads/master 63ef38981 -> 7a29ec3d1
TAMAYA-49: Added ConfigQuery, ConfigOperator as interfaces to Java 7 and 8. Fixed some typos. Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/3942d693 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/3942d693 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/3942d693 Branch: refs/heads/master Commit: 3942d693aa9f5f10f4b5fb67178c0e37775d2f97 Parents: 63ef389 Author: anatole <[email protected]> Authored: Tue Jan 13 08:58:43 2015 +0100 Committer: anatole <[email protected]> Committed: Tue Jan 13 08:58:43 2015 +0100 ---------------------------------------------------------------------- docs/API.adoc | 129 +++++++++---------- java7/api/pom.xml | 2 +- .../java/org/apache/tamaya/ConfigOperator.java | 37 ++++++ .../java/org/apache/tamaya/ConfigQuery.java | 36 ++++++ .../java/org/apache/tamaya/Configuration.java | 17 +++ .../apache/tamaya/spi/PropertyConverter.java | 7 + .../services/org.apache.tamaya.Configuration | 2 +- java7/pom.xml | 2 +- java8/api/pom.xml | 2 +- .../java/org/apache/tamaya/ConfigOperator.java | 38 ++++++ .../java/org/apache/tamaya/ConfigQuery.java | 37 ++++++ .../java/org/apache/tamaya/Configuration.java | 17 ++- .../apache/tamaya/ConfigurationProvider.java | 11 +- .../apache/tamaya/spi/PropertyConverter.java | 14 +- .../services/org.apache.tamaya.Configuration | 2 +- java8/core/pom.xml | 2 +- .../core/internal/DefaultConfiguration.java | 6 +- .../internal/DefaultConfigurationContext.java | 2 +- .../core/internal/DefaultServiceContext.java | 5 +- .../core/internal/PropertyConverterManager.java | 20 +-- .../core/propertysource/BasePropertySource.java | 6 +- .../EnvironmentPropertySource.java | 2 +- .../services/org.apache.tamaya.Configuration | 2 +- .../org.apache.tamaya.spi.ServiceContext | 2 +- .../test/internal/PropetiesFileLoaderTest.java | 2 +- .../org.apache.tamaya.spi.PropertyFilter | 2 +- .../org.apache.tamaya.spi.PropertySource | 2 +- ...org.apache.tamaya.spi.PropertySourceProvider | 2 +- .../test/resources/javaconfiguration.properties | 2 +- .../test/resources/overrideOrdinal.properties | 2 +- .../core/src/test/resources/testfile.properties | 2 +- java8/pom.xml | 2 +- 32 files changed, 301 insertions(+), 115 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/docs/API.adoc ---------------------------------------------------------------------- diff --git a/docs/API.adoc b/docs/API.adoc index 8c17784..891b03a 100644 --- a/docs/API.adoc +++ b/docs/API.adoc @@ -111,7 +111,6 @@ a.b2=abVal Now you can use +java.util.Properties+ to read this file and access the corresponding properties, e.g. [source,properties] -.Accessing some properties -------------------------------------------- Properties props = new Properties(); props.readProperties(...); @@ -155,15 +154,15 @@ Nevertheless most of these advantages can be mitigated easily, hereby still keep [[API Configuration]] === Configuration -+Configuration+ inherits all basic features from +PropertySource+, but additionally adds functionality for -type safety and external features of any interacting with configuration: ++Configuration+ is the main API provided by Tamaya. It allows reading of single property values or the whole +property map, but also supports type safe access. ==== Configuration (Java 7) The minimal API defined for Java version earlier than Java 8 looks as follows: [source,java] -.Interface Configuration +.Interface Configuration in Java 7 -------------------------------------------- public interface Configuration{ String get(String key); @@ -183,15 +182,16 @@ Hereby * +get(String, PropertyConverter)+ allow accessing any type, hereby also passing a +PropertyConverter+ explicitly that converts the configured literal value to the type required. * +with, query+ provide the extension points for adding additional functionality. -* +getProperties()+ provides access to all key/values. - +* +getProperties()+ provides access to all key/values, whereas entries from non scannable property sources may not + be included. ==== Configuration (Java 8) -The API for Java 8 adds additional support for optionals: +The API for Java 8 adds additional support for optionals and a static accessor +current()+, which replaces the ++ConfigurationProvider+ accessor singleton from Java 7. [source,java] -.Interface Configuration +.Interface Configuration in Java 8 -------------------------------------------- public interface Configuration extends PropertySource{ // java 7 inherited methods @@ -221,64 +221,30 @@ Hereby methods delegate to the +getAdapted+ method, additionally passing the required +PropertyAdapter+. * +get(String, PropertyConverter)+ allow accessing any type, hereby also passing a +PropertyConverter+ that converts the configured literal value to the type required. -* +with, query+ provide the extension points for adding additional functionality. -* +current()+ returns the _default_ +Configuration+ +* +with, query+ provide the extension points for adding additional functionality modelled by +ConfigOperator, + ConfigQuery+. +* +current()+ returns the _current_ +Configuration+ [[TypeConversion]] ==== Type Conversion (PropertyConverter) -Configuration extend +PropertySource+ and adds additional support for non String types. This is achieved -with the help of +PropertyConverter+ instances: +Configuration also provides support for non String types. Nevertheless internally configuration is modelled as +pure Strings only, so non String types must be created by conerting the String values into the required target type. +This is achieved with the help of +PropertyConverter+ instances: [source,java] -.PropertyConverter -------------------------------------------- -// @FunctionalInterface +// @FunctionalInterface in Java 8 public interface PropertyConverter<T>{ T convert(String value); } -------------------------------------------- +PropertyConverter+ instances can be implemented and registered by default using the +ServiceLoader+. -Access to converters is given by the +ConfigurationContext+. - -[[PropertySourceProvider]] -==== Property Source Provider - -Instances of this type can be used to register a multiple collection of +PropertySource+ instances at one -dynamically. - -[source,java] -.PropertySourceProvider --------------------------------------------- -// @FunctionalInterface -public interface PropertySourceProvider{ - Collection<PropertySource> getPropertySources(); -} --------------------------------------------- - -This allows to evaluate the property sources to be read dynamically, when the system is loading. - -[[PropertyFilters]] -==== Property Value Filtering - -Also filters can be registered (by default) using the +ServiceLoader+. Filters allow to replace or remove values -provided by the underlying property sources. A filter is defined as follows: - -[source,java] -.PropertyFilter --------------------------------------------- -// @FunctionalInterface -public interface PropertyConverter{ - String filterProperty(String key, String valueToBeFiltered); -} --------------------------------------------- - -This method is called each time a single entry is accessed, and for each property in a full properties result. -For enabling multiple resolution steps, filtering is done multiple times, until no further value change could -be registered. +Access to converters is given by the +ConfigurationContext+ (see SPI a bit later) +[[ExtensionPoints]] === Extension Points We are well aware of the fact that this library will not be able to cover all kinds of use cases. Therefore @@ -294,22 +260,22 @@ Both interfaces hereby are functional interfaces, defined in +java.util.function method references: [source,java] -.Applying a Configuration Query +.Applying a +ConfigurationQuery+ -------------------------------------------- ConfigSecurity securityContext = Configuration.current().query(ConfigSecurity::targetSecurityContext); -------------------------------------------- -NOTE: +ConfigSecurity+ is an arbitrary class. +NOTE: +ConfigSecurity+ is an arbitrary class only for demonstration purposes. -Or an operator calls looks as follows: +Or an operator calls basically looks quite similar: [source,java] -.Applying a Configuration Operators +.Applying a +ConfigurationOperator+ -------------------------------------------- Configuration secured = Configuration.current().with(ConfigSecurity::secure); -------------------------------------------- - +[[Mutability]] ==== Mutability In general Property sources can be modeled as mutable. Nevertheless the API does not support out of the box mutability, @@ -319,11 +285,12 @@ due to the following reasons: * Mutability is only rarely required * Mutability can be implemented in various ways -TBD +tbd +[[SPI]] == SPI -[SPI PropertySource] +[[PropertySource]] === PropertySource We have seen that constraining configuration aspects to simple literal key/value pairs provides us with an easy to @@ -338,14 +305,11 @@ To make implementation of a custom property source as convinient as possible onl identified to be necessary: [source,java] -.Interface PropertySource -------------------------------------------- public interface PropertySource{ - String get(String key); boolean isBrowseable(); Map<String, String> getProperties(); - } -------------------------------------------- @@ -361,11 +325,42 @@ provided by a data grid, a database, the JNDI tree or other resources. Or it can property sources with additional combination/aggregation rules in place. -[SPI PropertySourceProvider] -=== PropertySourceProvider +[[PropertySourceProvider]] +==== Property Source Provider + +Instances of this type can be used to register multiple instances of +PropertySource+. + +[source,java] +-------------------------------------------- +// @FunctionalInterface in Java 8 +public interface PropertySourceProvider{ + Collection<PropertySource> getPropertySources(); +} +-------------------------------------------- + +This allows to evaluate the property sources to be read/that are available dynamically. All property sources +are read out and added to the current chain of +PropertySource+ instances within the current +ConfigurationContext+, +refer also to [[ConfigurationContext]]. + +[[PropertyFilter]] +==== Property Value Filtering + +Also filters can be registered (by default) using the +ServiceLoader+. Filters allow to replace or remove values +provided by the underlying property sources. A filter is defined as follows: + +[source,java] +-------------------------------------------- +// @FunctionalInterface in Java 8 +public interface PropertyConverter{ + String filterProperty(String key, String valueToBeFiltered); +} +-------------------------------------------- + +Hereby: -[SPI PropertyFilter] -=== PropertyFilter +* returning +null+ will remove the key from the final result +* non null values are used as the current value of the key. Nevertheless for resolving multi-step dependencies + filter evaluation has to be continued as long as filters are still changing some of the values to be returned. + To prevent possible endless loops after a defined number of loops evaluation is stopped. -[SPI PropertyConverter] -=== PropertyConverter \ No newline at end of file +This method is called each time a single entry is accessed, and for each property in a full properties result. http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java7/api/pom.xml ---------------------------------------------------------------------- diff --git a/java7/api/pom.xml b/java7/api/pom.xml index 50f5576..9028d58 100644 --- a/java7/api/pom.xml +++ b/java7/api/pom.xml @@ -5,7 +5,7 @@ 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 current the License at +with the License. You may obtain aa_a copy current the License at http://www.apache.org/licenses/LICENSE-2.0 http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java7/api/src/main/java/org/apache/tamaya/ConfigOperator.java ---------------------------------------------------------------------- diff --git a/java7/api/src/main/java/org/apache/tamaya/ConfigOperator.java b/java7/api/src/main/java/org/apache/tamaya/ConfigOperator.java new file mode 100644 index 0000000..2295b07 --- /dev/null +++ b/java7/api/src/main/java/org/apache/tamaya/ConfigOperator.java @@ -0,0 +1,37 @@ +/* + * 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; + +/** + * Models a function that maps a given {@link org.apache.tamaya.Configuration} to another {@link org.apache.tamaya.Configuration}. This can be used + * to modell additional functionality and applying it to a given {@link org.apache.tamaya.Configuration} instance by calling + * the {@link org.apache.tamaya.Configuration#with(org.apache.tamaya.ConfigOperator)} method. + */ +public interface ConfigOperator { + + /** + * Creates a new {@link org.apache.tamaya.Configuration} based on the given Configuration. Operators basically acts similar to + * decorators, whereas operated instances may have non compatible behaviour, e.g. by applying security constraints + * or view restrictions. + * + * @param config the input configuration, not null. + * @return the operated configuration, never null. + */ + Configuration operate(Configuration config); +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java7/api/src/main/java/org/apache/tamaya/ConfigQuery.java ---------------------------------------------------------------------- diff --git a/java7/api/src/main/java/org/apache/tamaya/ConfigQuery.java b/java7/api/src/main/java/org/apache/tamaya/ConfigQuery.java new file mode 100644 index 0000000..9ef0179 --- /dev/null +++ b/java7/api/src/main/java/org/apache/tamaya/ConfigQuery.java @@ -0,0 +1,36 @@ +/* + * 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; + +/** + * Models a function that maps a given {@link Configuration} to something else. This can be used + * to model additional functionality and applying it to a given {@link Configuration} instance by + * calling the {@link Configuration#query(ConfigQuery)} method. + */ +public interface ConfigQuery<T> { + + /** + * Creates a result based on the given Configuration. Queries basically acts similar to + * operators, whereas they returns any kind of result. + * + * @param config the input configuration, not null. + * @return the query result. + */ + T query(Configuration config); +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java7/api/src/main/java/org/apache/tamaya/Configuration.java ---------------------------------------------------------------------- diff --git a/java7/api/src/main/java/org/apache/tamaya/Configuration.java b/java7/api/src/main/java/org/apache/tamaya/Configuration.java index 69fb580..bfa74c5 100644 --- a/java7/api/src/main/java/org/apache/tamaya/Configuration.java +++ b/java7/api/src/main/java/org/apache/tamaya/Configuration.java @@ -69,4 +69,21 @@ public interface Configuration { */ Map<String,String> getProperties(); + /** + * Extension point for adjusting configuration. + * + * @param operator A configuration operator, e.g. aa_a filter, or an adjuster + * combining configurations. + * @return the new adjusted configuration returned by the {@code operator}, never {@code null}. + */ + Configuration with(ConfigOperator operator); + + /** + * Query aa_a configuration. + * + * @param query the query, never {@code null}. + * @return the result returned by the {@code query} + */ + <T> T query(ConfigQuery<T> query); + } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java7/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java ---------------------------------------------------------------------- diff --git a/java7/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java b/java7/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java index 9493f67..2c494f8 100644 --- a/java7/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java +++ b/java7/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java @@ -26,6 +26,13 @@ package org.apache.tamaya.spi; */ public interface PropertyConverter<T>{ +// /** +// * Access the target type, this converter is producing. This is necessary to determine which converters are +// * to be used for converting a possible value. +// * @return the target type returned by a converter instance, never null. +// */ +// Class<T> getTargetType(); + /** * Convert the given configuration keys from it' String representation into the required target type. * @param value the configuration keys http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java7/api/src/test/resources/META-INF/services/org.apache.tamaya.Configuration ---------------------------------------------------------------------- diff --git a/java7/api/src/test/resources/META-INF/services/org.apache.tamaya.Configuration b/java7/api/src/test/resources/META-INF/services/org.apache.tamaya.Configuration index 1f42438..17a4562 100644 --- a/java7/api/src/test/resources/META-INF/services/org.apache.tamaya.Configuration +++ b/java7/api/src/test/resources/META-INF/services/org.apache.tamaya.Configuration @@ -5,7 +5,7 @@ # 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 current the License at +# with the License. You may obtain aa_a copy current the License at # # http://www.apache.org/licenses/LICENSE-2.0 # http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java7/pom.xml ---------------------------------------------------------------------- diff --git a/java7/pom.xml b/java7/pom.xml index a71ef92..0eff15f 100644 --- a/java7/pom.xml +++ b/java7/pom.xml @@ -5,7 +5,7 @@ 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 +with the License. You may obtain aa_a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/api/pom.xml ---------------------------------------------------------------------- diff --git a/java8/api/pom.xml b/java8/api/pom.xml index d0f9fb4..f5eb0c3 100644 --- a/java8/api/pom.xml +++ b/java8/api/pom.xml @@ -5,7 +5,7 @@ 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 current the License at +with the License. You may obtain aa_a copy current the License at http://www.apache.org/licenses/LICENSE-2.0 http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/api/src/main/java/org/apache/tamaya/ConfigOperator.java ---------------------------------------------------------------------- diff --git a/java8/api/src/main/java/org/apache/tamaya/ConfigOperator.java b/java8/api/src/main/java/org/apache/tamaya/ConfigOperator.java new file mode 100644 index 0000000..35c583c --- /dev/null +++ b/java8/api/src/main/java/org/apache/tamaya/ConfigOperator.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya; + +/** + * Models a function that maps a given {@link Configuration} to another {@link Configuration}. This can be used + * to modell additional functionality and applying it to a given {@link Configuration} instance by calling + * the {@link Configuration#with(ConfigOperator)} method. + */ +@FunctionalInterface +public interface ConfigOperator { + + /** + * Creates a new {@link Configuration} based on the given Configuration. Operators basically acts similar to + * decorators, whereas operated instances may have non compatible behaviour, e.g. by applying security constraints + * or view restrictions. + * + * @param config the input configuration, not null. + * @return the operated configuration, never null. + */ + Configuration operate(Configuration config); +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/api/src/main/java/org/apache/tamaya/ConfigQuery.java ---------------------------------------------------------------------- diff --git a/java8/api/src/main/java/org/apache/tamaya/ConfigQuery.java b/java8/api/src/main/java/org/apache/tamaya/ConfigQuery.java new file mode 100644 index 0000000..140ccba --- /dev/null +++ b/java8/api/src/main/java/org/apache/tamaya/ConfigQuery.java @@ -0,0 +1,37 @@ +/* + * 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; + +/** + * Models a function that maps a given {@link org.apache.tamaya.Configuration} to something else. This can be used + * to model additional functionality and applying it to a given {@link org.apache.tamaya.Configuration} instance by + * calling the {@link org.apache.tamaya.Configuration#query(org.apache.tamaya.ConfigQuery)} method. + */ +@FunctionalInterface +public interface ConfigQuery<T> { + + /** + * Creates a result based on the given Configuration. Queries basically acts similar to + * operators, whereas they returns any kind of result. + * + * @param config the input configuration, not null. + * @return the query result. + */ + T query(Configuration config); +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/api/src/main/java/org/apache/tamaya/Configuration.java ---------------------------------------------------------------------- diff --git a/java8/api/src/main/java/org/apache/tamaya/Configuration.java b/java8/api/src/main/java/org/apache/tamaya/Configuration.java index 45b5731..76b6e34 100644 --- a/java8/api/src/main/java/org/apache/tamaya/Configuration.java +++ b/java8/api/src/main/java/org/apache/tamaya/Configuration.java @@ -21,9 +21,12 @@ package org.apache.tamaya; import org.apache.tamaya.spi.PropertyConverter; import org.apache.tamaya.spi.ServiceContext; -import java.util.*; -import java.util.function.Function; -import java.util.function.UnaryOperator; +import java.util.Map; +import java.util.Optional; +import java.util.OptionalDouble; +import java.util.OptionalInt; +import java.util.OptionalLong; + /** * A configuration models aa_a aggregated set current properties, identified by aa_a unique key, but adds higher level access functions to @@ -199,8 +202,8 @@ public interface Configuration { * combining configurations. * @return the new adjusted configuration, never {@code null}. */ - default Configuration with(UnaryOperator<Configuration> operator) { - return operator.apply(this); + default Configuration with(ConfigOperator operator) { + return operator.operate(this); } @@ -210,8 +213,8 @@ public interface Configuration { * @param query the query, never {@code null}. * @return the result */ - default <T> T query(Function<Configuration,T> query) { - return query.apply(this); + default <T> T query(ConfigQuery<T> query) { + return query.query(this); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java ---------------------------------------------------------------------- diff --git a/java8/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java b/java8/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java index 199e686..6d37e57 100644 --- a/java8/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java +++ b/java8/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java @@ -21,13 +21,22 @@ import org.apache.tamaya.spi.ServiceContextManager; /** * Static access to the {@link org.apache.tamaya.Configuration} for the very application. * - * Exists for Java7 backward compatibility + * Exists for Java7 backward compatibility only. + * @deprecated Since Java 8, you better use {@link org.apache.tamaya.Configuration#current()}. */ +@Deprecated public final class ConfigurationProvider { private ConfigurationProvider() { // just to prevent initialisation } + /** + * Access the current configuration. + * + * @return the corresponding Configuration instance, never null. + * @deprecated Since Java 8, you better use {@link org.apache.tamaya.Configuration#current()}. + */ + @Deprecated public static Configuration getConfiguration() { return ServiceContextManager.getServiceContext().getService(Configuration.class).get(); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java ---------------------------------------------------------------------- diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java b/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java index 705cccd..af34195 100644 --- a/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java +++ b/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java @@ -24,13 +24,19 @@ package org.apache.tamaya.spi; * This is used for implementing type conversion from aa_a property (String) to aa_a certain target * type. Hereby the target type can be multivalued (eg collections) or complex if needed. */ -@FunctionalInterface public interface PropertyConverter<T>{ +// /** +// * Access the target type, this converter is producing. This is necessary to determine which converters are +// * to be used for converting a possible value. +// * @return the target type returned by a converter instance, never null. +// */ +// Class<T> getTargetType(); + /** - * Convert the given configuration keys from it' String representation into the required target type. - * @param value the configuration keys - * @return converted keys + * Convert the given configuration keys from it's String representation into the required target type. + * @param value the configuration value + * @return the converted value */ T convert(String value); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.Configuration ---------------------------------------------------------------------- diff --git a/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.Configuration b/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.Configuration index 1f42438..17a4562 100644 --- a/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.Configuration +++ b/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.Configuration @@ -5,7 +5,7 @@ # 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 current the License at +# with the License. You may obtain aa_a copy current the License at # # http://www.apache.org/licenses/LICENSE-2.0 # http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/pom.xml ---------------------------------------------------------------------- diff --git a/java8/core/pom.xml b/java8/core/pom.xml index 029b2ff..33ea94f 100644 --- a/java8/core/pom.xml +++ b/java8/core/pom.xml @@ -5,7 +5,7 @@ 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 current the License at +with the License. You may obtain aa_a copy current the License at http://www.apache.org/licenses/LICENSE-2.0 http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java ---------------------------------------------------------------------- diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java index e862d02..34ede4d 100644 --- a/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java +++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java @@ -82,7 +82,7 @@ public class DefaultConfiguration implements Configuration { } /** - * Apply filters to a single property value. + * Apply filters to aa_a single property value. * * @param key the key, used for logging, not null. * @param unfilteredValue the unfiltered property value. @@ -151,7 +151,7 @@ public class DefaultConfiguration implements Configuration { } /** - * Filter a full configuration property map. + * Filter aa_a full configuration property map. * * @param inputMap the unfiltered map * @return the filtered map. @@ -198,7 +198,7 @@ public class DefaultConfiguration implements Configuration { * {@link org.apache.tamaya.spi.ConfigurationContext}. * * @param key the property's absolute, or relative path, e.g. @code - * a/b/c/d.myProperty}. + * aa_a/b/c/d.myProperty}. * @param type The target type required, not null. * @param <T> the value type * @return the converted value, never null. http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java ---------------------------------------------------------------------- diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java index b6acae5..5373484 100644 --- a/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java +++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfigurationContext.java @@ -36,7 +36,7 @@ import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.StampedLock; /** - * Default Implementation of a simple ConfigurationContext. + * Default Implementation of aa_a simple ConfigurationContext. */ public class DefaultConfigurationContext implements ConfigurationContext { /** http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java ---------------------------------------------------------------------- diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java index d5b132a..42c928b 100644 --- a/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java +++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/DefaultServiceContext.java @@ -126,10 +126,11 @@ public final class DefaultServiceContext implements ServiceContext { } if (highestPriorityServiceCount > 1) { - throw new ConfigException(MessageFormat.format("Found {0} implementations for Service {1} with Priority {2}", + throw new ConfigException(MessageFormat.format("Found {0} implementations for Service {1} with Priority {2}: {3}", highestPriorityServiceCount, serviceType.getName(), - highestPriority)); + highestPriority, + services)); } return highestService; http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java ---------------------------------------------------------------------- diff --git a/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java index 5c7ae02..8aaf7ca 100644 --- a/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java +++ b/java8/core/src/main/java/org/apache/tamaya/core/internal/PropertyConverterManager.java @@ -97,7 +97,7 @@ public class PropertyConverterManager { } /** - * Registers a ew converter instance. + * Registers aa_a ew converter instance. * * @param targetType the target type, not null. * @param converter the converter, not null. @@ -121,10 +121,10 @@ public class PropertyConverterManager { } /** - * Allows to evaluate if a given target type is supported. + * Allows to evaluate if aa_a given target type is supported. * * @param targetType the target type, not null. - * @return true, if a converter for the given type is registered, or a default one can be created. + * @return true, if aa_a converter for the given type is registered, or aa_a default one can be created. */ public boolean isTargetTypeSupported(Class<?> targetType) { return converters.containsKey(targetType) @@ -132,9 +132,9 @@ public class PropertyConverterManager { } /** - * Get a map of all property converters currently registered. This will not contain the converters that - * may be created, when an instance is adapted, which provides a String constructor or compatible - * factory methods taking a single String instance. + * Get aa_a map of all property converters currently registered. This will not contain the converters that + * may be created, when an instance is adapted, which provides aa_a String constructor or compatible + * factory methods taking aa_a single String instance. * * @return the current map of instantiated and registered converters. * @see #createDefaultPropertyConverter(Class) @@ -151,7 +151,7 @@ public class PropertyConverterManager { /** * Get the list of all current registered converters for the given target type. - * If not converters are registered, they component tries to create and register a dynamic + * If not converters are registered, they component tries to create and register aa_a dynamic * converter based on String costructor or static factory methods available. * * @param targetType the target type, not null. @@ -187,11 +187,11 @@ public class PropertyConverterManager { } /** - * Creates a dynamic PropertyConverter for the given target type. + * Creates aa_a dynamic PropertyConverter for the given target type. * * @param targetType the target type * @param <T> the type class - * @return a new converter, or null. + * @return aa_a new converter, or null. */ protected <T> PropertyConverter<T> createDefaultPropertyConverter(Class<T> targetType) { PropertyConverter<T> converter = null; @@ -225,7 +225,7 @@ public class PropertyConverterManager { } /** - * Tries to evaluate a factory method that can be used to create an instance based on a String. + * Tries to evaluate aa_a factory method that can be used to create an instance based on aa_a String. * * @param type the target type * @param methodNames the possible static method names http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java ---------------------------------------------------------------------- diff --git a/java8/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java b/java8/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java index 7fe3a46..88e7efe 100644 --- a/java8/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java +++ b/java8/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java @@ -25,7 +25,7 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * A base class for {@link PropertySource}s. It provides a {@link #initializeOrdinal(int)} method that + * A base class for {@link PropertySource}s. It provides aa_a {@link #initializeOrdinal(int)} method that * reads the ordinal from the config source itself, allowing the ordinal to be "self-configured" by * the configuration read. */ @@ -54,7 +54,7 @@ public abstract class BasePropertySource implements PropertySource { * Initializing the ordinal of this {@link PropertySource} with the given defaultOrdinal. * * If {@link PropertySource#TAMAYA_ORDINAL} is present via {@link #get(String)} and the - * value is a valid {@link Integer} then, the defaultOrdinal will be overridden. + * value is aa_a valid {@link Integer} then, the defaultOrdinal will be overridden. * * @param defaultOrdinal of the {@link PropertySource} */ @@ -68,7 +68,7 @@ public abstract class BasePropertySource implements PropertySource { this.ordinal = Integer.valueOf(ordinal); } catch (NumberFormatException e) { LOG.log(Level.WARNING, - "Specified {0} is not a valid Integer value: {1} - using defaultOrdinal {2}", + "Specified {0} is not aa_a valid Integer value: {1} - using defaultOrdinal {2}", new Object[]{PropertySource.TAMAYA_ORDINAL, ordinal, defaultOrdinal}); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java ---------------------------------------------------------------------- diff --git a/java8/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java b/java8/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java index 596ea73..8f21c62 100644 --- a/java8/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java +++ b/java8/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java @@ -40,7 +40,7 @@ public class EnvironmentPropertySource extends BasePropertySource { @Override public Map<String, String> getProperties() { - return System.getenv(); // already a map and unmodifiable + return System.getenv(); // already aa_a map and unmodifiable } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.Configuration ---------------------------------------------------------------------- diff --git a/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.Configuration b/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.Configuration index 0db8402..1cb7f38 100644 --- a/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.Configuration +++ b/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.Configuration @@ -5,7 +5,7 @@ # 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 current the License at +# with the License. You may obtain aa_a copy current the License at # # http://www.apache.org/licenses/LICENSE-2.0 # http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext ---------------------------------------------------------------------- diff --git a/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext b/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext index 2721eff..3269d65 100644 --- a/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext +++ b/java8/core/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext @@ -5,7 +5,7 @@ # 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 current the License at +# with the License. You may obtain aa_a copy current the License at # # http://www.apache.org/licenses/LICENSE-2.0 # http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java ---------------------------------------------------------------------- diff --git a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java b/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java index 985b5d5..d651bea 100644 --- a/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java +++ b/java8/core/src/test/java/org/apache/tamaya/core/test/internal/PropetiesFileLoaderTest.java @@ -54,7 +54,7 @@ public class PropetiesFileLoaderTest { } { - // with a while which doesn't exist + // with aa_a while which doesn't exist Set<URL> urls = PropertiesFileLoader.resolvePropertiesFiles("nonexistingfile.properties"); Assert.assertNotNull(urls); Assert.assertTrue(urls.isEmpty()); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter ---------------------------------------------------------------------- diff --git a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter index 4e7d068..cd332be 100644 --- a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter +++ b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyFilter @@ -5,7 +5,7 @@ # 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 current the License at +# with the License. You may obtain aa_a copy current the License at # # http://www.apache.org/licenses/LICENSE-2.0 # http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource ---------------------------------------------------------------------- diff --git a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource index 1effc9e..7a934e0 100644 --- a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource +++ b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySource @@ -5,7 +5,7 @@ # 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 current the License at +# with the License. You may obtain aa_a copy current the License at # # http://www.apache.org/licenses/LICENSE-2.0 # http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider ---------------------------------------------------------------------- diff --git a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider index afc8910..2a329f0 100644 --- a/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider +++ b/java8/core/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertySourceProvider @@ -5,7 +5,7 @@ # 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 current the License at +# with the License. You may obtain aa_a copy current the License at # # http://www.apache.org/licenses/LICENSE-2.0 # http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/test/resources/javaconfiguration.properties ---------------------------------------------------------------------- diff --git a/java8/core/src/test/resources/javaconfiguration.properties b/java8/core/src/test/resources/javaconfiguration.properties index b461414..de099eb 100644 --- a/java8/core/src/test/resources/javaconfiguration.properties +++ b/java8/core/src/test/resources/javaconfiguration.properties @@ -4,7 +4,7 @@ # 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 +# with the License. You may obtain aa_a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/test/resources/overrideOrdinal.properties ---------------------------------------------------------------------- diff --git a/java8/core/src/test/resources/overrideOrdinal.properties b/java8/core/src/test/resources/overrideOrdinal.properties index 96935a8..4becac1 100644 --- a/java8/core/src/test/resources/overrideOrdinal.properties +++ b/java8/core/src/test/resources/overrideOrdinal.properties @@ -4,7 +4,7 @@ # 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 +# with the License. You may obtain aa_a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/core/src/test/resources/testfile.properties ---------------------------------------------------------------------- diff --git a/java8/core/src/test/resources/testfile.properties b/java8/core/src/test/resources/testfile.properties index abd7ee8..628b3f1 100644 --- a/java8/core/src/test/resources/testfile.properties +++ b/java8/core/src/test/resources/testfile.properties @@ -4,7 +4,7 @@ # 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 +# with the License. You may obtain aa_a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/3942d693/java8/pom.xml ---------------------------------------------------------------------- diff --git a/java8/pom.xml b/java8/pom.xml index 291b84b..1a6c6bc 100644 --- a/java8/pom.xml +++ b/java8/pom.xml @@ -5,7 +5,7 @@ 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 +with the License. You may obtain aa_a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
