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/09/29 09:01:10 UTC
[05/21] incubator-tamaya git commit: TAMAYA-113: Remove Java 8
related parts - basic work done.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/main/java/org/apache/tamaya/TypeLiteral.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/TypeLiteral.java b/java8/api/src/main/java/org/apache/tamaya/TypeLiteral.java
deleted file mode 100644
index 5aa4f4c..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/TypeLiteral.java
+++ /dev/null
@@ -1,202 +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;
-
-import java.io.Serializable;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-
-/**
- * <p>Class for instantiation of objects that represent parameterized types
- * with current parameters.</p>
- * <p>
- * <p>An object that represents a parameterized type may be obtained by
- * subclassing <tt>TypeLiteral</tt>.</p>
- * <p>
- * <pre>
- * TypeLiteral<List<Integer>> stringListType = new TypeLiteral<List<Integer>>() {};
- * </pre>
- *
- * @param <T> the type, including all type parameters
- */
-public class TypeLiteral<T> implements Serializable {
-
- private static final long serialVersionUID = 1L;
- private static final Type[] EMPTY_TYPE_ARRAY = new Type[0];
- /** The current defined type. */
- private Type definedType;
-
- /**
- * Constructor.
- * @param definedType the defined type.
- */
- protected TypeLiteral(Type definedType) {
- this.definedType = definedType;
- }
-
- /**
- * Constructor only for directly implemeting a TypeLiteral hereby dynamically implementing a generic interface.
- */
- protected TypeLiteral() {
- this.definedType = getDefinedType(this.getClass());
- }
-
- /**
- * Creates a new TypeLiteral based on a given type.
- *
- * @param type the type , not null.
- * @param <R> the literal generic type.
- * @return the corresponding TypeLiteral, never null.
- */
- public static <R> TypeLiteral<R> of(Type type) {
- return new TypeLiteral<>(type);
- }
-
- /**
- * Checks the current implemented generic interfaces and evaluates the given single type parameter.
- *
- * @param clazz the class to check, not null.
- * @param interfaceType the interface type to be checked, not null.
- * @return the generic type parameter, or null, if it cannot be evaluated.
- */
- public static Type[] getGenericInterfaceTypeParameters(Class<?> clazz, Class<?> interfaceType) {
- for (Type type : clazz.getGenericInterfaces()) {
- if (type instanceof ParameterizedType) {
- ParameterizedType parameterizedType = (ParameterizedType) type;
- if(parameterizedType.getRawType().equals(interfaceType)){
- return parameterizedType.getActualTypeArguments();
- }
- }
- }
- return EMPTY_TYPE_ARRAY;
- }
-
- /**
- * Method that checks the class's type for a generic interface implementation type.
- *
- * @param type the type, not null.
- * @return the generic type parameter of the given single type generic interfaceType, or null.
- */
- public static Type[] getTypeParameters(Type type) {
- if (type instanceof ParameterizedType) {
- ParameterizedType parameterizedType = (ParameterizedType) type;
- return parameterizedType.getActualTypeArguments();
- }
- return EMPTY_TYPE_ARRAY;
- }
-
- public final Type getType() {
- return definedType;
- }
-
- /**
- * Returns basic raw Java type.
- *
- * @return the actual type represented by this object
- */
- public final Class<T> getRawType() {
- Class<T> rawType = null;
-
- if (this.definedType instanceof Class) {
- rawType = (Class<T>) this.definedType;
- } else if (this.definedType instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) this.definedType;
- rawType = (Class<T>) pt.getRawType();
-
- } else if (this.definedType instanceof GenericArrayType) {
- rawType = (Class<T>) Object[].class;
- } else {
- throw new RuntimeException("Illegal type for the Type Literal Class");
- }
-
- return rawType;
- }
-
-
- protected Type getDefinedType(Class<?> clazz) {
- Type type = null;
-
- if (clazz == null) {
- throw new RuntimeException("Class parameter clazz can not be null");
- }
-
- Type superClazz = clazz.getGenericSuperclass();
-
- if (superClazz.equals(Object.class)) {
- throw new RuntimeException("Super class must be parametrized type");
- } else if (superClazz instanceof ParameterizedType) {
- ParameterizedType pt = (ParameterizedType) superClazz;
- Type[] actualArgs = pt.getActualTypeArguments();
-
- if (actualArgs.length == 1) {
- type = actualArgs[0];
-
- } else {
- throw new RuntimeException("More than one parametric type");
- }
-
- } else {
- type = getDefinedType((Class<?>) superClazz);
- }
-
- return type;
- }
-
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((definedType == null) ? 0 : definedType.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- TypeLiteral other = (TypeLiteral) obj;
- if (definedType == null) {
- if (other.definedType != null) {
- return false;
- }
- } else if (!definedType.equals(other.definedType)) {
- return false;
- }
- return true;
- }
-
-
- @Override
- public String toString() {
- return "TypeLiteral{" +
- "type=" + definedType +
- '}';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java b/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java
deleted file mode 100644
index 24efdeb..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java
+++ /dev/null
@@ -1,152 +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.spi;
-
-import org.apache.tamaya.TypeLiteral;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Predicate;
-import java.util.stream.Collectors;
-
-/**
- * Central SPI for programmatically dealing with the setup of the configuration system.
- * This includes adding and enlisting {@link org.apache.tamaya.spi.PropertySource}s,
- * managing {@link PropertyConverter}s, ConfigFilters, etc.
- */
-public interface ConfigurationContext {
-
- /**
- * This method returns the current list of registered PropertySources ordered via their ordinal.
- * PropertySources with a lower ordinal come last. The PropertySource with the
- * highest ordinal comes first.
- * If two PropertySources have the same ordinal number they will get sorted
- * using their class name just to ensure the user at least gets the same ordering
- * after a JVM restart, hereby names before are added last.
- * PropertySources are loaded when this method is called the first time, which basically is
- * when the first time configuration is accessed.
- *
- * @return a sorted list of registered PropertySources. The returned list need not be modifiable
- */
- List<PropertySource> getPropertySources();
-
- /**
- * This method returns a subset ot the currently registered PropertySources.
- *
- * @param selector the selector query, not null.
- * @return a collectino of selected PropertySources.
- */
- default Collection<PropertySource> getPropertySources(Predicate<PropertySource> selector){
- return getPropertySources().stream().filter(selector).collect(Collectors.toList());
- }
-
- /**
- * <p>
- * This method returns the Map of registered PropertyConverters
- * per type.
- * The List for each type is ordered via their {@link javax.annotation.Priority} and
- * class name.
- * </p>
- * <p>
- * A simplified scenario could be like:
- * <pre>
- * {
- * Date.class -> {StandardDateConverter, TimezoneDateConverter, MyCustomDateConverter }
- * Boolean.class -> {StandardBooleanConverter, FrenchBooleanConverter}
- * Integer.class -> {DynamicDefaultConverter}
- * }
- * </pre>
- * </p>
- *
- * @return map with sorted list of registered PropertySources per type.
- */
- Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters();
-
- /**
- * <p>
- * This method returns the registered PropertyConverters for a given type.
- * The List for each type is ordered via their {@link javax.annotation.Priority}.
- * </p>
- * <p>
- * <p>
- * PropertyConverters with a higher Priority come first. The PropertyConverter with the
- * lowest Priority comes last.
- * If two PropertyConverter have the same ordinal number they will get sorted
- * using their class name just to ensure the user at least gets the same ordering
- * after a JVM restart.
- * </p>
- * <p>
- * <p>
- * Additionally if a PropertyProvider is accessed, which is not registered the implementation
- * should try to figure out, if there could be a default implementation as follows:
- * <ol>
- * <le>Look for static factory methods: {@code of(String), valueOf(String), getInstance(String),
- * instanceOf(String), fomr(String)}</le>
- * <le>Look for a matching constructor: {@code T(String)}.</le>
- * </ol>
- * If a correspoding factory method or constructor could be found, a corresponding
- * PropertyConverter should be created and registered automatically for the given
- * type.
- * </p>
- * <p>
- * <p>
- * The scenario could be like:
- * <pre>
- * {
- * Date.class -> {MyCustomDateConverter,StandardDateConverter, TimezoneDateConverter}
- * Boolean.class -> {StandardBooleanConverter, FrenchBooleanConverter}
- * Integer.class -> {DynamicDefaultConverter}
- * }
- * </pre>
- * </p>
- * <p>
- * <p>
- * The converters returned for a type should be used as a chain, whereas the result of the
- * first converter that is able to convert the configured value, is taken as the chain's result.
- * No more converters are called after a converter has successfully converted the input into
- * the required target type.
- * </p>
- *
- * @return a sorted list of registered PropertySources per type.
- */
- <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> type);
-
- /**
- * Access the current PropertyFilter instances.
- *
- * @return the list of registered PropertyFilters, never null.
- */
- List<PropertyFilter> getPropertyFilters();
-
- /**
- * Access the {@link org.apache.tamaya.spi.PropertyValueCombinationPolicy} used to evaluate the final
- * property values.
- * @return the {@link org.apache.tamaya.spi.PropertyValueCombinationPolicy} used, never null.
- */
- PropertyValueCombinationPolicy getPropertyValueCombinationPolicy();
-
- /**
- * Creates a new updates instance for changing the current ConfigurationContext.
- * @throws java.lang.UnsupportedOperationException if this ConfigurationContext is not updateable.
- * @return a new ConfigurationContextUpdates instance.
- */
- ConfigurationContextBuilder toBuilder();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java b/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java
deleted file mode 100644
index e070450..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java
+++ /dev/null
@@ -1,193 +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.spi;
-
-import org.apache.tamaya.TypeLiteral;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.function.Predicate;
-
-/**
- * A builder for creating new or adapting instances of {@link org.apache.tamaya.spi.ConfigurationContext}.
- * Builders can be obtained in exactly two ways:
- * <ol>
- * <li>By accessing a preinitialized builder from an existing {@link org.apache.tamaya.spi.ConfigurationContext},
- * by calling {@link ConfigurationContext#toBuilder()}.</li>
- * <li>By accessing an empty builder instance from
- * {@link org.apache.tamaya.ConfigurationProvider#getConfigurationContextBuilder()}.</li>
- * </ol>
- * After all changes are applied to a builder a new {@link org.apache.tamaya.spi.ConfigurationContext} instance can
- * be created and can be applied by calling
- * {@link org.apache.tamaya.ConfigurationProvider#setConfigurationContext(ConfigurationContext)}. Since this method can
- * throw an UnsupportedOperationException, you should check before if changing the current ConfigurationContext
- * programmatically is supported by calling
- * {@link org.apache.tamaya.ConfigurationProvider#isConfigurationContextSettable()}.
- */
-public interface ConfigurationContextBuilder {
-
- /**
- * Init this builder instance with the given {@link org.apache.tamaya.spi.ConfigurationContext} instance. This
- * method will replace any existing data in the current builder with the data contained in the given
- * {@link org.apache.tamaya.spi.ConfigurationContext}.
- *
- * @param context the {@link org.apache.tamaya.spi.ConfigurationContext} instance to be used, not null.
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder setContext(ConfigurationContext context);
-
- /**
- * This method can be used for programmatically adding {@link org.apache.tamaya.spi.PropertySource}s.
- * It is not needed for normal 'usage' by end users, but only for Extension Developers!
- *
- * @param propertySourcesToAdd the PropertySources to add
- * @return this builder, for chaining, never null.
- */
- default ConfigurationContextBuilder addPropertySources(PropertySource... propertySourcesToAdd) {
- return addPropertySources(Arrays.asList(propertySourcesToAdd));
- }
-
-
- /**
- * This method can be used for programmatically adding {@link org.apache.tamaya.spi.PropertySource}s.
- * It is not needed for normal 'usage' by end users, but only for Extension Developers!
- *
- * @param propertySourcesToAdd the PropertySources to add
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder addPropertySources(Collection<PropertySource> propertySourcesToAdd);
-
- /**
- * This method can be used for programmatically adding {@link org.apache.tamaya.spi.PropertySource}s.
- * It is not needed for normal 'usage' by end users, but only for Extension Developers!
- *
- * @param propertySourcesNames the PropertySource names of the sources to remove
- * @return this builder, for chaining, never null.
- */
- default ConfigurationContextBuilder removePropertySources(String... propertySourcesNames) {
- return removePropertySources(Arrays.asList(propertySourcesNames));
- }
-
- /**
- * This method can be used for programmatically adding {@link org.apache.tamaya.spi.PropertySource}s.
- * It is not needed for normal 'usage' by end users, but only for Extension Developers!
- *
- * @param propertySourcesNames the PropertySource names of the sources to remove
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder removePropertySources(Collection<String> propertySourcesNames);
-
- /**
- * Adds the given PropertyFilter instances.
- *
- * @param filters the filters to add
- * @return this builder, for chaining, never null.
- */
- default ConfigurationContextBuilder addPropertyFilters(PropertyFilter... filters) {
- return addPropertyFilters(Arrays.asList(filters));
- }
-
- /**
- * Adds the given PropertyFilter instances.
- *
- * @param filters the filters to add
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder addPropertyFilters(Collection<PropertyFilter> filters);
-
- /**
- * Removes the given PropertyFilter instances.
- *
- * @param filters the filters to remove
- * @return this builder, for chaining, never null.
- */
- default ConfigurationContextBuilder removePropertyFilters(PropertyFilter... filters) {
- return removePropertyFilters(Arrays.asList(filters));
- }
-
- /**
- * Removes the given PropertyFilter instances.
- *
- * @param selector the selector query, not null.
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder removePropertyFilters(Predicate<PropertyFilter> selector);
-
- /**
- * Removes the given PropertyFilter instances.
- *
- * @param filters the filters to remove
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder removePropertyFilters(Collection<PropertyFilter> filters);
-
- /**
- * Remove the property sources selected by the given selector predicate.
- *
- * @param selector the selector query, not null.
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder removePropertySources(Predicate<PropertySource> selector);
-
- /**
- * This method can be used for programmatically adding {@link PropertyConverter}s.
- * It is not needed for normal 'usage' by end users, but only for Extension Developers!
- *
- * @param typeToConvert the type which the converter is for
- * @param propertyConverter the PropertyConverters to add for this type
- * @return this builder, for chaining, never null.
- */
- <T> ConfigurationContextBuilder addPropertyConverter(TypeLiteral<T> typeToConvert,
- PropertyConverter<T> propertyConverter);
-
- /**
- * Removes the given PropertyConverter instances.
- *
- * @param typeToConvert the type which the converter is for
- * @param converters the converters to remove
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert,
- PropertyConverter<?>... converters);
-
- /**
- * Removes the given PropertyConverter instances.
- *
- * @param typeToConvert the type which the converter is for
- * @param converters the converters to remove
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert,
- Collection<PropertyConverter<?>> converters);
-
- /**
- * Sets the {@link org.apache.tamaya.spi.PropertyValueCombinationPolicy} used to evaluate the final
- * property values.
- *
- * @param policy the {@link org.apache.tamaya.spi.PropertyValueCombinationPolicy} used, not null
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy policy);
-
- /**
- * Builds a {@link org.apache.tamaya.spi.ConfigurationContext} based on the data set.
- */
- ConfigurationContext build();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java b/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
deleted file mode 100644
index b2cc381..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
+++ /dev/null
@@ -1,77 +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.spi;
-
-import org.apache.tamaya.Configuration;
-
-/**
- * SPI that must be implemented to provide the component that manages all {@link org.apache.tamaya.Configuration}
- * instances in a system. In SE this may be a true singleton containing exact one {@link org.apache.tamaya.Configuration}
- * instance, whereas in Java EE and other more complex environments instances may be returned depending the current
- * runtime context.
- */
-public interface ConfigurationProviderSpi {
-
- /**
- * Access the current {@link org.apache.tamaya.Configuration}.
- *
- * @return the current {@link org.apache.tamaya.Configuration} instance, never null.
- */
- Configuration getConfiguration();
-
- /**
- * Get access to the current {@link org.apache.tamaya.spi.ConfigurationContext}.
- *
- * @return the current {@link org.apache.tamaya.spi.ConfigurationContext}, never null.
- */
- ConfigurationContext getConfigurationContext();
-
- /**
- * This method allows to replace the current {@link org.apache.tamaya.spi.ConfigurationContext} with a new
- * instance. This can be used to update the context with a new one, e.g. because some of the configuration
- * data has changed and must be updated. It is the responsibility of the ConfigurationProvider to trigger
- * corresponding update event for the current {@link org.apache.tamaya.spi.ConfigurationContext} or
- * {@link org.apache.tamaya.Configuration}.
- *
- * @param context the new ConfigurationContext to be applied.
- * @throws java.lang.UnsupportedOperationException if the current provider is read-only.
- */
- default void setConfigurationContext(ConfigurationContext context){
- throw new UnsupportedOperationException("By default a ConfigurationContext cannot not be switched later.");
- }
-
- /**
- * Method that allows to determine if a new {@link org.apache.tamaya.spi.ConfigurationContext} can be applied
- * programmatically.
- * @see #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)
- * @return true, if {@link #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)} is supported
- * by the current implementation.
- */
- default boolean isConfigurationContextSettable(){
- return false;
- }
-
- /**
- * Creates a new {@link org.apache.tamaya.spi.ConfigurationContextBuilder} instance.
- *
- * @return a new {@link org.apache.tamaya.spi.ConfigurationContextBuilder}, never null.
- */
- ConfigurationContextBuilder getConfigurationContextBuilder();
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/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
deleted file mode 100644
index b69953e..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java
+++ /dev/null
@@ -1,49 +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.spi;
-
-
-/**
- * Interface for an property that converts a configured String into something else.
- * This is used for implementing type conversion from a property (String) to a certain target
- * type. Hereby the target type can be multivalued (eg collections) or complex if needed.
- * @param <T> the result/target type of the converter.
- */
-public interface PropertyConverter<T> {
-
- /**
- * Convert the given configuration keys from it's String representation into the required target type.
- * <b>IMPORTANT NOTE: </b> Multiple instances of this type are ordered in a chain of converters that
- * try to parse/convert a configured value. The first non-null result returned by a converter is
- * used as the final result of the conversion. As a consequence implementations of this class must
- * only return non-null values that are the result of a successful conversion of an entry.
- *
- * @param value the configuration value, not null.
- * @return the converted value, or {@code null} if the value could not be converted. Returning a non-null
- * value will stop the conversion process and return the value as result (converted value).
- */
- T convert(String value);
-
- //X TODO probably add some diagnostic info which explains what kind of
- //X format(s) is supported.
- //X This could be useful if e.g. no converter in the chain felt responsible
- //X because a wrongly formatted configuration string had been used.
- //X This could probably also be handled via an additional Annotation on the converter.
- //X Collection<String> getSupportedFormats();
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java b/java8/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java
deleted file mode 100644
index 1fd8c36..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java
+++ /dev/null
@@ -1,49 +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.spi;
-
-
-/**
- * <p>Interface for filtering the current map of properties during the evaluation of the chain of PropertySources.
- * Filters can be registered using the {@link org.apache.tamaya.spi.ServiceContext}. The ordinal
- * hereby is defined by the corresponding {@code @Priority} annotation.</p>
- * <p>Filters </p>
- */
-public interface PropertyFilter {
-
- /**
- * <p>Maps the current {@code valueToBeFiltered} value to a new value. The resulting value will be used as the result
- * passed to the user.</p>
- * <p>If a filter is currently not available, it should just pass the input map to the method's
- * output.</p>
- * <p>Returning {@code null} will remove the entry and Optional.empty() will be returned to the user.</p>
- * <h3>Implementation specification</h3>
- * Implementations of this class must be
- * <ul>
- * <li>reentrant</li>
- * <li>thread-safe</li>
- * </ul>
- *
- * @param key the key accessed, not null.
- * @param valueToBeFiltered the value to be filtered, not null.
- * @return the filtered value, or {@code null} if the value should be removed alltogether.
- */
- String filterProperty(String key, String valueToBeFiltered);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/PropertySource.java b/java8/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
deleted file mode 100644
index b4303a0..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/spi/PropertySource.java
+++ /dev/null
@@ -1,153 +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.spi;
-
-
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * This interface models a provider that serves configuration properties. The contained
- * properties may be read fromMap single or several sources (composite).<br/>
- * PropertySources are the building blocks of the final configuration.
- * <p/>
- * <h3>Implementation Requirements</h3>
- * <p></p>Implementations current this interface must be
- * <ul>
- * <li>Thread safe.</li>
- * </ul>
- * </p>
- * <p>
- * <p>A PropertySourceProvider will get picked up via the
- * {@link java.util.ServiceLoader} mechanism and can be registered via
- * META-INF/services/org.apache.tamaya.spi.PropertySource
- * </p>
- * <p>
- * If you like to register multiple PropertySources at the same time
- * you can use the {@link org.apache.tamaya.spi.PropertySourceProvider}
- * interface.
- * </p>
- */
-public interface PropertySource {
-
- /**
- * property name to override default tamaya ordinals
- */
- static final String TAMAYA_ORDINAL = "tamaya.ordinal";
-
-
- /**
- * Lookup order:
- * TODO rethink whole default PropertySources and ordering:
- * TODO introduce default values or constants for ordinals
- * <ol>
- * <li>System properties (ordinal 400)</li>
- * <li>Environment properties (ordinal 300)</li>
- * <li>JNDI values (ordinal 200)</li>
- * <li>Properties file values (/META-INF/applicationConfiguration.properties) (ordinal 100)</li>
- * </ol>
- * <p/>
- * <p><b>Important Hints for custom implementations</b>:</p>
- * <p>
- * If a custom implementation should be invoked <b>before</b> the default implementations, use a value > 400
- * </p>
- * <p>
- * If a custom implementation should be invoked <b>after</b> the default implementations, use a value < 100
- * </p>
- * <p/>
- * <p>Reordering of the default order of the config-sources:</p>
- * <p>Example: If the properties file/s should be used <b>before</b> the other implementations,
- * you have to configure an ordinal > 400. That means, you have to add e.g. deltaspike_ordinal=401 to
- * /META-INF/apache-deltaspike.properties . Hint: In case of property files every file is handled as independent
- * config-source, but all of them have ordinal 400 by default (and can be reordered in a fine-grained manner.</p>
- *
- * @return the 'importance' aka ordinal of the configured values. The higher, the more important.
- */
- default int getOrdinal(){
- String configuredOrdinal = get(TAMAYA_ORDINAL);
- if(configuredOrdinal!=null){
- try{
- return Integer.parseInt(configuredOrdinal);
- } catch(Exception e){
- Logger.getLogger(getClass().getName()).log(Level.WARNING, e,
- () -> "Configured Ordinal is not an int number: " + configuredOrdinal);
- }
- }
- return getDefaultOrdinal();
- }
-
- /**
- * Returns the default ordinal used, when no ordinal is set, or the ordinal was not parseable to an int value.
- * @return the default ordinal used, by default 0.
- */
- default int getDefaultOrdinal(){
- return 0;
- }
-
- /**
- * Get the name of the property source. The name should be unique for the type of source, whereas multiple instances
- * of the same type (and thus name) may exist in a system. Give a {@link ConfigurationContext}
- * the name of a PropertySource is unique.
- *
- * @return the property source's name, never null.
- */
- String getName();
-
- /**
- * Access a property.
- * <p>
- * //X TODO discuss if the key can be null
- *
- * @param key the property's key, not null.
- * @return the value assigned to the property or {@code null}. An empty String will kind of 'erase' previous values.
- */
- default String get(String key){
- Objects.requireNonNull(key, "key must not be null");
- return getProperties().get(key);
- }
-
- /**
- * Access the current properties as Map. The resulting Map may not return all items accessible, e.g.
- * when the underlying storage does not support iteration of its entries.
- *
- * @return the a corresponding map, never null.
- * //X TODO or should we just do getPropertyKeys()? Think about security (key) vs easier merging (full map)?
- */
- Map<String, String> getProperties();
-
- /**
- * Determines if this config source could be scanned for its list of properties.
- * <p>
- * <p>
- * PropertySources which are not scannable might not be able to find all the
- * configured values to provide via {@link #getProperties()}. This can e.g. happen
- * if the underlying storage doesn't support listing.
- * </p>
- *
- * @return {@code true} if this PropertySource could be scanned for its list of properties,
- * {@code false} if it should not be scanned.
- */
- default boolean isScannable() {
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/main/java/org/apache/tamaya/spi/PropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/PropertySourceProvider.java b/java8/api/src/main/java/org/apache/tamaya/spi/PropertySourceProvider.java
deleted file mode 100644
index 81ddcdd..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/spi/PropertySourceProvider.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.spi;
-
-import java.util.Collection;
-
-/**
- * <p>Implement this interfaces to provide a PropertySource provider which
- * is able to register multiple PropertySources. This is e.g. needed if
- * there are multiple property files of a given config file name.</p>
- * <p>
- * <p>If a PropertySource like JNDI only exists once, then there is no need
- * to implement it via the PropertySourceProvider but should directly
- * expose a {@link PropertySource}.</p>
- * <p>
- * <p>A PropertySourceProvider will get picked up via the
- * {@link java.util.ServiceLoader} mechanism and must get registered via
- * META-INF/services/org.apache.tamaya.spi.PropertySourceProvider</p>
- */
-public interface PropertySourceProvider {
-
- /**
- * @return For each e.g. property file, we return a single PropertySource
- * or an empty list if no PropertySource exists.
- */
- Collection<PropertySource> getPropertySources();
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/main/java/org/apache/tamaya/spi/PropertyValueCombinationPolicy.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/PropertyValueCombinationPolicy.java b/java8/api/src/main/java/org/apache/tamaya/spi/PropertyValueCombinationPolicy.java
deleted file mode 100644
index 3c5fb42..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/spi/PropertyValueCombinationPolicy.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.spi;
-
-import java.util.Optional;
-
-/**
- * Policy that determines how the final value of a configuration entry is evaluated. An instances of this
- * interface can be registered to get control how multiple PropertySources are combined. This is useful in cases
- * where the default overriding policy as implemented in {@link #DEFAULT_OVERRIDING_COLLECTOR} is not matching
- * the need of the current application, e.g. then entries containing multiple values should be combined to new
- * values instead of overridden.
- */
-@FunctionalInterface
-public interface PropertyValueCombinationPolicy {
-
- /**
- * Default overriding collector, where each existing entry ({@code current} is overridden by a subsequent non-null
- * entry evaluated by {@code propertySource.get(key)}.
- */
- public final PropertyValueCombinationPolicy DEFAULT_OVERRIDING_COLLECTOR =
- (current, key, propertySource) -> Optional.ofNullable(propertySource.get(key))
- .filter(s -> !s.isEmpty())
- .orElse(current);
-
- /**
- * Method that is called for each value evaluated by a PropertySource for the given key. This method is called
- * either when a single key is accessed, e.g. by calling {@code org.apache.tamaya.Configuration.getXXX}, but also
- * when the full configuration property map is accessed by calling
- * {@link org.apache.tamaya.Configuration#getProperties()}.
- *
- * @param currentValue the current value, including null.
- * The collector should either combine the existing value with value from {@code currentValue}
- * or replace the value in {@code currentValue} with {@code valueRead}, hereby returning the
- * result to be used as new {@code currentValue}.
- * @param key The current key to be evaluated.
- * @param propertySource The PropertySource that may return an value for the given key. The PropertySource given
- * may be evaluated for additional meta-data, how the given values are to be combined.
- * Note that the value returned by a PropertySource can be null. In that case
- * {@code currentValue} should be returned in almost all cases.
- * @return the value to be used for future evaluation.
- */
- String collect(String currentValue, String key, PropertySource propertySource);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java b/java8/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java
deleted file mode 100644
index f248503..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java
+++ /dev/null
@@ -1,66 +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.spi;
-
-import java.util.List;
-
-
-/**
- * This class models the component that is managing the lifecycle current the
- * services used by the Configuration API.
- */
-public interface ServiceContext {
-
- /**
- * Get the current {@link ServiceContext}. If necessary the {@link ServiceContext} will be laziliy loaded.
- *
- * @return the {@link ServiceContext} to be used.
- */
- public static ServiceContext getInstance() {
- return ServiceContextManager.getServiceContext();
- }
-
- /**
- * @return ordinal of the ServiceContext. The one with the highest ordinal will be taken.
- */
- default int ordinal() {
- return 1;
- }
-
- /**
- * Access a service singleton via its type.
- * If multiple implementations for the very serviceType exist then
- * the one with the highest {@link javax.annotation.Priority} will be used.
- *
- * @param serviceType the service type.
- * @return The instance to be used, never {@code null}
- * @throws org.apache.tamaya.ConfigException if there are multiple service implementations with the maximum priority.
- */
- <T> T getService(Class<T> serviceType);
-
- /**
- * Access a list current services, given its type. The bootstrap mechanism should
- * order the instance for precedence, hereby the most significant should be
- * first in order.
- *
- * @param serviceType the service type.
- * @return The instance to be used, never {@code null}
- */
- <T> List<T> getServices(Class<T> serviceType);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
----------------------------------------------------------------------
diff --git a/java8/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java b/java8/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
deleted file mode 100644
index bcaca06..0000000
--- a/java8/api/src/main/java/org/apache/tamaya/spi/ServiceContextManager.java
+++ /dev/null
@@ -1,115 +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.spi;
-
-import org.apache.tamaya.ConfigException;
-
-import java.util.Objects;
-import java.util.ServiceLoader;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * This singleton provides access to the services available in the current {@link ServiceContext}. The
- * behaviour can be adapted, by calling {@link ServiceContextManager#set(ServiceContext)} before accessing any
- * services.
- */
-public final class ServiceContextManager {
-
- /** The logger used. */
- private static final Logger LOG = Logger.getLogger(ServiceContextManager.class.getName());
-
- /**
- * The ServiceProvider used.
- */
- private static volatile ServiceContext serviceContextProviderDelegate;
-
- /**
- * Private singletons constructor.
- */
- private ServiceContextManager() {
- }
-
- /**
- * Load the {@link ServiceContext} to be used.
- *
- * @return {@link ServiceContext} to be used for loading the services.
- */
- private static ServiceContext loadDefaultServiceProvider() {
- ServiceContext highestServiceContext = null;
- try {
- int highestOrdinal = 0;
- for (ServiceContext serviceContext : ServiceLoader.load(ServiceContext.class)) {
- if (serviceContext.ordinal() > highestOrdinal) {
- highestServiceContext = serviceContext;
- highestOrdinal = serviceContext.ordinal();
- }
- }
- } catch (Exception e) {
- throw new ConfigException("ServiceContext not loadable", e);
- }
- if (highestServiceContext == null) {
- throw new ConfigException("No ServiceContext found");
- }
- LOG.info("Using Service Context of type: " + highestServiceContext.getClass().getName());
- return highestServiceContext;
- }
-
- /**
- * Replace the current {@link ServiceContext} in use.
- *
- * @param serviceContextProvider the new {@link ServiceContext}, not null.
- */
- public static ServiceContext set(ServiceContext serviceContextProvider) {
- ServiceContext currentContext = ServiceContextManager.serviceContextProviderDelegate;
- Objects.requireNonNull(serviceContextProvider);
- synchronized (ServiceContextManager.class) {
- if (ServiceContextManager.serviceContextProviderDelegate == null) {
- ServiceContextManager.serviceContextProviderDelegate = serviceContextProvider;
- Logger.getLogger(ServiceContextManager.class.getName())
- .log(Level.INFO, "Using ServiceProvider: " + serviceContextProvider.getClass().getName());
- } else {
- Logger.getLogger(ServiceContextManager.class.getName())
- .log(Level.WARNING, "Replacing ServiceProvider " +
- ServiceContextManager.serviceContextProviderDelegate.getClass().getName() +
- " with: " + serviceContextProvider.getClass().getName());
- ServiceContextManager.serviceContextProviderDelegate = serviceContextProvider;
- }
- }
- return currentContext;
- }
-
- /**
- * Ge {@link ServiceContext}. If necessary the {@link ServiceContext} will be laziliy loaded.
- *
- * @return the {@link ServiceContext} used.
- */
- public static ServiceContext getServiceContext() {
- if (serviceContextProviderDelegate == null) {
- synchronized (ServiceContextManager.class) {
- if (serviceContextProviderDelegate == null) {
- serviceContextProviderDelegate = loadDefaultServiceProvider();
- }
- }
- }
- return serviceContextProviderDelegate;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/java/org/apache/tamaya/ConfigExceptionTest.java
----------------------------------------------------------------------
diff --git a/java8/api/src/test/java/org/apache/tamaya/ConfigExceptionTest.java b/java8/api/src/test/java/org/apache/tamaya/ConfigExceptionTest.java
deleted file mode 100644
index e5898cf..0000000
--- a/java8/api/src/test/java/org/apache/tamaya/ConfigExceptionTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-/**
- * Tests instantiating {@link org.apache.tamaya.ConfigException}.
- */
-public class ConfigExceptionTest {
-
- @Test
- public void testCreationMessage(){
- ConfigException ex = new ConfigException("test");
- assertNull(ex.getCause());
- assertEquals(ex.getMessage(), "test");
- }
-
- @Test
- public void testCreationMessageThrowable(){
- Exception e = new IllegalStateException("blabla");
- ConfigException ex = new ConfigException("test", e);
- assertTrue(ex.getCause() == e);
- assertEquals("test", ex.getMessage());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/java8/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java b/java8/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java
deleted file mode 100644
index 8870d22..0000000
--- a/java8/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java
+++ /dev/null
@@ -1,63 +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;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Simple tests for the }@link ConfigurationProvider} singleton class.
- */
-public class ConfigurationProviderTest {
-
- @Test
- public void testGetConfiguration() throws Exception {
- Configuration cfg = ConfigurationProvider.getConfiguration();
- assertNotNull(cfg);
- }
-
-// @Test
-// public void testSetConfigurationContext() throws Exception {
-// ConfigurationContextBuilder builder = ConfigurationProvider.getConfigurationContextBuilder();
-// ConfigurationContext ctx = builder.build();
-// ConfigurationContext prevCtx = ConfigurationProvider.getConfigurationContext();
-// assertNotNull(prevCtx);
-// ConfigurationProvider.setConfigurationContext(ctx);
-// assertTrue(ConfigurationProvider.getConfigurationContext() == ctx);
-// ConfigurationProvider.setConfigurationContext(prevCtx);
-// assertTrue(ConfigurationProvider.getConfigurationContext() == prevCtx);
-//
-// }
-//
-// @Test
-// public void testIsConfigurationContextSettable() throws Exception {
-// assertTrue(ConfigurationProvider.isConfigurationContextSettable());
-// }
-//
-// @Test
-// public void testGetConfigurationContextBuilder() throws Exception {
-// ConfigurationContextBuilder builder = ConfigurationProvider.getConfigurationContextBuilder();
-// assertNotNull(builder);
-// assertTrue(builder.build().getPropertyConverters().isEmpty());
-// assertTrue(builder.build().getPropertyFilters().isEmpty());
-// assertTrue(builder.build().getPropertySources().isEmpty());
-//
-// }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/java/org/apache/tamaya/ConfigurationTest.java
----------------------------------------------------------------------
diff --git a/java8/api/src/test/java/org/apache/tamaya/ConfigurationTest.java b/java8/api/src/test/java/org/apache/tamaya/ConfigurationTest.java
deleted file mode 100644
index 8490455..0000000
--- a/java8/api/src/test/java/org/apache/tamaya/ConfigurationTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Test class that tests the default methods implemented on {@link org.apache.tamaya.Configuration}. The provided
- * {@link org.apache.tamaya.TestConfiguration} is implemented with maximal use of the default methods.
- */
-public class ConfigurationTest {
-
- @Test
- public void testget() throws Exception {
- assertEquals(Boolean.TRUE, ConfigurationProvider.getConfiguration().getOptional("booleanTrue", Boolean.class).get());
- assertEquals(Boolean.FALSE, ConfigurationProvider.getConfiguration().getOptional("booleanFalse", Boolean.class).get());
- assertEquals((int) Byte.MAX_VALUE, (int) ConfigurationProvider.getConfiguration().getOptional("byte", Byte.class).get());
- assertEquals((int) Integer.MAX_VALUE, (int) ConfigurationProvider.getConfiguration().getOptional("int", Integer.class).get());
- assertEquals((long) Long.MAX_VALUE, (long) ConfigurationProvider.getConfiguration().getOptional("long", Long.class).get());
- assertEquals((double) Float.MAX_VALUE, (double) ConfigurationProvider.getConfiguration().getOptional("float", Float.class).get(), 0.0d);
- assertEquals((double) Double.MAX_VALUE, (double) ConfigurationProvider.getConfiguration().getOptional("double", Double.class).get(), 0.0d);
- }
-
- @Test
- public void testGetBoolean() throws Exception {
- assertTrue(ConfigurationProvider.getConfiguration().getBoolean("booleanTrue").isPresent());
- assertTrue(ConfigurationProvider.getConfiguration().getBoolean("booleanFalse").isPresent());
- assertFalse(ConfigurationProvider.getConfiguration().getBoolean("booleanFalse").get());
- assertTrue(ConfigurationProvider.getConfiguration().getBoolean("booleanTrue").get());
- assertFalse(ConfigurationProvider.getConfiguration().getBoolean("fooBar").isPresent());
- }
-
- @Test
- public void testGetInteger() throws Exception {
- assertEquals(Integer.MAX_VALUE, ConfigurationProvider.getConfiguration().getInteger("int").getAsInt());
- }
-
- @Test
- public void testGetLong() throws Exception {
- assertEquals(Long.MAX_VALUE, ConfigurationProvider.getConfiguration().getLong("long").getAsLong());
- }
-
- @Test
- public void testGetDouble() throws Exception {
- assertEquals(Double.MAX_VALUE, ConfigurationProvider.getConfiguration().getDouble("double").getAsDouble(), 0.0d);
- }
-
- @Test
- public void testWith() throws Exception {
- assertEquals(ConfigurationProvider.getConfiguration(), ConfigurationProvider.getConfiguration().with(c -> c));
- }
-
- @Test
- public void testQuery() throws Exception {
- assertEquals("myFooResult", ConfigurationProvider.getConfiguration().query(c -> "myFooResult"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/java/org/apache/tamaya/TestConfiguration.java
----------------------------------------------------------------------
diff --git a/java8/api/src/test/java/org/apache/tamaya/TestConfiguration.java b/java8/api/src/test/java/org/apache/tamaya/TestConfiguration.java
deleted file mode 100644
index ef7cccf..0000000
--- a/java8/api/src/test/java/org/apache/tamaya/TestConfiguration.java
+++ /dev/null
@@ -1,80 +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;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Test Configuration class, that is used to testdata the default methods provided by the API.
- */
-public class TestConfiguration implements Configuration {
-
- private static final Map<String, String> VALUES;
-
- static {
- VALUES = new HashMap<String, String>();
- VALUES.put("long", String.valueOf(Long.MAX_VALUE));
- VALUES.put("int", String.valueOf(Integer.MAX_VALUE));
- VALUES.put("double", String.valueOf(Double.MAX_VALUE));
- VALUES.put("float", String.valueOf(Float.MAX_VALUE));
- VALUES.put("short", String.valueOf(Short.MAX_VALUE));
- VALUES.put("byte", String.valueOf(Byte.MAX_VALUE));
- VALUES.put("booleanTrue", "true");
- VALUES.put("booleanFalse", "false");
- VALUES.put("String", "aStringValue");
- }
-
- @Override
- public String get(String key) {
- return VALUES.get(key);
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- if (type.getType().equals(Long.class)) {
- return (T) (Object) Long.MAX_VALUE;
- } else if (type.getType().equals(Integer.class)) {
- return (T) (Object) Integer.MAX_VALUE;
- } else if (type.getType().equals(Double.class)) {
- return (T) (Object) Double.MAX_VALUE;
- } else if (type.getType().equals(Float.class)) {
- return (T) (Object) Float.MAX_VALUE;
- } else if (type.getType().equals(Short.class)) {
- return (T) (Object) Short.MAX_VALUE;
- } else if (type.getType().equals(Byte.class)) {
- return (T) (Object) Byte.MAX_VALUE;
- } else if (type.getType().equals(Boolean.class)) {
- if ("booleanTrue".equals(key)) {
- return (T) (Object) Boolean.TRUE;
- } else if ("booleanFalse".equals(key)) {
- return (T) (Object) Boolean.FALSE;
- }
- } else if (type.getType().equals(String.class)) {
- return (T) (Object) "aStringValue";
- }
- return null;
- }
-
- @Override
- public Map<String, String> getProperties() {
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/java8/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java b/java8/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java
deleted file mode 100644
index 98820ca..0000000
--- a/java8/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya;
-
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.ConfigurationProviderSpi;
-
-/**
- * Test Configuration class, that is used to testdata the default methods provided by the API.
- */
-public class TestConfigurationProvider implements ConfigurationProviderSpi {
-
- private static final Configuration config = new TestConfiguration();
-
-
- @Override
- public Configuration getConfiguration() {
- return config;
- }
-
- @Override
- public ConfigurationContext getConfigurationContext() {
- return null;
- }
-
- @Override
- public ConfigurationContextBuilder getConfigurationContextBuilder() {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java
----------------------------------------------------------------------
diff --git a/java8/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java b/java8/api/src/test/java/org/apache/tamaya/TypeLiteralTest.java
deleted file mode 100644
index 79f6257..0000000
--- a/java8/api/src/test/java/org/apache/tamaya/TypeLiteralTest.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;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests for the {@link org.apache.tamaya.TypeLiteral} class.
- */
-public class TypeLiteralTest {
-
- @Test
- public void test_constrcutor(){
- TypeLiteral<List<String>> listTypeLiteral = new TypeLiteral<List<String>>(){};
- assertEquals(List.class, listTypeLiteral.getRawType());
- assertEquals(String.class, TypeLiteral.getTypeParameters(listTypeLiteral.getType())[0]);
- }
-
- @Test
- public void test_of(){
- class MyListClass extends ArrayList<String>{};
- TypeLiteral<MyListClass> listTypeLiteral = TypeLiteral.of(MyListClass.class);
- assertEquals(MyListClass.class, listTypeLiteral.getRawType());
- assertEquals(MyListClass.class, listTypeLiteral.getType());
- }
-
- @Test
- public void test_getTypeParameter(){
- TypeLiteral<List<String>> listTypeLiteral = new TypeLiteral<List<String>>(){};
- assertEquals(List.class, listTypeLiteral.getRawType());
- assertEquals(String.class, TypeLiteral.getTypeParameters(listTypeLiteral.getType())[0]);
- }
-
- @Test
- public void test_getGenericInterfaceTypeParameter(){
- class MyListClass extends ArrayList<String> implements List<String>{};
- assertEquals(String.class, TypeLiteral.getGenericInterfaceTypeParameters(MyListClass.class, List.class)[0]);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java
----------------------------------------------------------------------
diff --git a/java8/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java b/java8/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java
deleted file mode 100644
index 949170d..0000000
--- a/java8/api/src/test/java/org/apache/tamaya/spi/ServiceContextManagerTest.java
+++ /dev/null
@@ -1,131 +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.spi;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-
-import static org.junit.Assert.assertTrue;
-
-public class ServiceContextManagerTest {
-
- private static URLClassLoader classLoader;
- private static Field delegateField;
-
- @BeforeClass
- public static void init() throws Exception {
-
- // setup the environment for our ugly hacks
-
- // replace classloader with our own
- classLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(new UglyHackClassLoader(classLoader));
-
- // clear the caching field
- delegateField = ServiceContextManager.class.getDeclaredField("serviceContextProviderDelegate");
- delegateField.setAccessible(true);
-
- delegateField.set(null, null);
- }
-
- @AfterClass
- public static void clean() throws Exception {
-
- // clean our hacks
-
- delegateField.set(null, null);
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- @Test
- public void testGetServiceContext() {
-
- ServiceContext context = ServiceContextManager.getServiceContext();
- Assert.assertEquals(1, context.ordinal());
-
- }
-
- @Test
- public void testSetServiceContext(){
- ServiceContext ctx = new ServiceContext() {
- @Override
- public <T> T getService(Class<T> serviceType) {
- return null;
- }
-
- @Override
- public <T> List<T> getServices(Class<T> serviceType) {
- return Collections.emptyList();
- }
- };
- ServiceContext prevContext = ServiceContextManager.set(ctx);
- if(prevContext!=null) {
- ServiceContextManager.set(prevContext);
- assertTrue(ServiceContextManager.getServiceContext() == prevContext);
- }
- }
-
-
- // has to be public because ServiceLoader won't find it otherwise
- public static class ServiceContextWithOrdinal implements ServiceContext {
-
- @Override
- public int ordinal() {
- return 100;
- }
-
- @Override
- public <T> T getService(Class<T> serviceType) {
- return null;
- }
-
- @Override
- public <T> List<T> getServices(Class<T> serviceType) {
- return null;
- }
- }
-
- // to override the getResources method to use our own 'ServiceLoader'-file we have to this ugly hack
- private static class UglyHackClassLoader extends URLClassLoader {
-
- private UglyHackClassLoader(URLClassLoader urlClassLoader) {
- super(urlClassLoader.getURLs());
- }
-
-
- @Override
- public Enumeration<URL> getResources(String name) throws IOException {
- if ("META-INF/services/org.apache.tamaya.spi.ServiceContext".equals(name)) {
- return super.getResources("ServiceContextWithOrdinal");
- }
-
- return super.getResources(name);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java
----------------------------------------------------------------------
diff --git a/java8/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java b/java8/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java
deleted file mode 100644
index 28d9fac..0000000
--- a/java8/api/src/test/java/org/apache/tamaya/spi/ServiceContextTest.java
+++ /dev/null
@@ -1,91 +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.spi;
-
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-
-import static org.junit.Assert.*;
-
-public class ServiceContextTest {
-
- private ServiceContext serviceContext = new ServiceContext() {
-
- @Override
- public <T> T getService(Class<T> serviceType) {
- if (String.class.equals(serviceType)) {
- return serviceType.cast("ServiceContextTest");
- }
- return null;
- }
-
- @Override
- public <T> List<T> getServices(Class<T> serviceType) {
- if (String.class.equals(serviceType)) {
- List<String> list = new ArrayList<>();
- list.add("ServiceContextTest");
- return List.class.cast(list);
- }
- return Collections.EMPTY_LIST;
- }
- };
-
- @Test
- public void testOrdinal() throws Exception {
- assertEquals(1, serviceContext.ordinal());
- }
-
- @Test
- public void testgetService() throws Exception {
- assertEquals("ServiceContextTest", serviceContext.getService(String.class));
- assertTrue(serviceContext.getService(Integer.class)==null);
- }
-
- @Test
- public void testGetService() throws Exception {
- String service = serviceContext.getService(String.class);
- assertNotNull(service);
- assertTrue(service!=null);
- assertEquals("ServiceContextTest", service);
- Integer intService = serviceContext.getService(Integer.class);
- assertNull(intService);
- }
-
- @Test
- public void testGetServices() throws Exception {
- Collection<String> services = serviceContext.getServices(String.class);
- assertNotNull(services);
- assertFalse(services.isEmpty());
- assertEquals("ServiceContextTest", services.iterator().next());
- List<Integer> intServices = serviceContext.getServices(Integer.class);
- assertNotNull(intServices);
- assertTrue(intServices.isEmpty());
- }
-
- @Test
- public void testGetInstance() throws Exception {
- assertNotNull(ServiceContext.getInstance());
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java
----------------------------------------------------------------------
diff --git a/java8/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java b/java8/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java
deleted file mode 100644
index 720a5c4..0000000
--- a/java8/api/src/test/java/org/apache/tamaya/spi/TestServiceContext.java
+++ /dev/null
@@ -1,83 +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.spi;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceLoader;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * This class implements the (default) {@link org.apache.tamaya.spi.ServiceContext} interface and hereby uses the JDK
- * {@link java.util.ServiceLoader} to load the services required.
- */
-public final class TestServiceContext implements ServiceContext {
- /**
- * List current services loaded, per class.
- */
- private final ConcurrentHashMap<Class<?>, List<Object>> servicesLoaded = new ConcurrentHashMap<>();
- /**
- * Singletons.
- */
- private final Map<Class<?>, Object> singletons = new ConcurrentHashMap<>();
-
- @Override
- public <T> T getService(Class<T> serviceType) {
- T cached = serviceType.cast(singletons.get(serviceType));
- if (cached == null) {
- List<? extends T> services = getServices(serviceType);
- if (services.isEmpty()) {
- cached = null;
- } else {
- cached = services.get(0);
- }
- singletons.put(serviceType, cached);
- }
- return cached;
- }
-
- /**
- * Loads and registers services.
- *
- * @param serviceType The service type.
- * @param <T> the concrete type.
- * @return the items found, never {@code null}.
- */
- @Override
- public <T> List<T> getServices(Class<T> serviceType) {
- try {
- List<T> services = new ArrayList<>();
- for (T t : ServiceLoader.load(serviceType)) {
- services.add(t);
- }
- services = Collections.unmodifiableList(services);
- final List<T> previousServices = List.class.cast(servicesLoaded.putIfAbsent(serviceType, (List<Object>) services));
- return previousServices != null ? previousServices : services;
- } catch (Exception e) {
- Logger.getLogger(TestServiceContext.class.getName()).log(Level.WARNING,
- "Error loading services current type " + serviceType, e);
- return Collections.emptyList();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi
----------------------------------------------------------------------
diff --git a/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi b/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi
deleted file mode 100644
index b9c5ba5..0000000
--- a/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ConfigurationProviderSpi
+++ /dev/null
@@ -1,19 +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 current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.TestConfigurationProvider
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
----------------------------------------------------------------------
diff --git a/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext b/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
deleted file mode 100644
index 199956f..0000000
--- a/java8/api/src/test/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
+++ /dev/null
@@ -1,19 +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 current the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-org.apache.tamaya.spi.TestServiceContext
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b6dc2eed/java8/api/src/test/resources/ServiceContextWithOrdinal
----------------------------------------------------------------------
diff --git a/java8/api/src/test/resources/ServiceContextWithOrdinal b/java8/api/src/test/resources/ServiceContextWithOrdinal
deleted file mode 100644
index 4112c18..0000000
--- a/java8/api/src/test/resources/ServiceContextWithOrdinal
+++ /dev/null
@@ -1,25 +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.
-
-# this is just an ugly hack to test the loading of ServiceContexts
-# if we have more than one
-
-# this one is without overriding ordinal so it shall take the default
-org.apache.tamaya.spi.TestServiceContext
-
-# this one has a higher ordinal (100)
-org.apache.tamaya.spi.ServiceContextManagerTest$ServiceContextWithOrdinal
\ No newline at end of file