You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/09/15 17:26:30 UTC
[13/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/PropertyConverterManager.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/PropertyConverterManager.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/PropertyConverterManager.java
deleted file mode 100644
index e0e35f7..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/PropertyConverterManager.java
+++ /dev/null
@@ -1,427 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.ServiceContextManager;
-
-import javax.enterprise.inject.Vetoed;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.util.logging.Logger;
-
-/**
- * Manager that deals with {@link PropertyConverter} instances.
- * This class is thread-safe.
- */
-@Vetoed
-public class PropertyConverterManager {
- /**
- * The logger used.
- */
- private static final Logger LOG = Logger.getLogger(PropertyConverterManager.class.getName());
- /**
- * The registered converters.
- */
- private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> converters = new ConcurrentHashMap<>();
- /**
- * The transitive converters.
- */
- private final Map<TypeLiteral<?>, List<PropertyConverter<?>>> transitiveConverters = new ConcurrentHashMap<>();
- /**
- * The lock used.
- */
- private final ReadWriteLock lock = new ReentrantReadWriteLock();
-
- private static final Comparator<Object> PRIORITY_COMPARATOR = new Comparator<Object>() {
-
- @Override
- public int compare(Object o1, Object o2) {
- int prio = CDIAwareServiceContext.getPriority(o1) - CDIAwareServiceContext.getPriority(o2);
- if (prio < 0) {
- return 1;
- } else if (prio > 0) {
- return -1;
- } else {
- return o1.getClass().getSimpleName().compareTo(o2.getClass().getSimpleName());
- }
- }
- };
-
- /**
- * Constructor.
- */
- public PropertyConverterManager() {
- initConverters();
- }
-
- /**
- * Registers the default converters provided out of the box.
- */
- protected void initConverters() {
- for (PropertyConverter conv : ServiceContextManager.getServiceContext().getServices(PropertyConverter.class)) {
- Type type = TypeLiteral.getGenericInterfaceTypeParameters(conv.getClass(), PropertyConverter.class)[0];
- register(TypeLiteral.of(type), conv);
- }
- }
-
- /**
- * Registers a ew converter instance.
- *
- * @param targetType the target type, not null.
- * @param converter the converter, not null.
- * @param <T> the type.
- */
- public <T> void register(TypeLiteral<T> targetType, PropertyConverter<T> converter) {
- Objects.requireNonNull(converter);
- Lock writeLock = lock.writeLock();
- try {
- writeLock.lock();
- List converters = List.class.cast(this.converters.get(targetType));
- List<PropertyConverter<?>> newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.converters.put(targetType, Collections.unmodifiableList(newConverters));
- // evaluate transitive closure for all inherited supertypes and implemented interfaces
- // direct implemented interfaces
- for (Class<?> ifaceType : targetType.getRawType().getInterfaces()) {
- converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(ifaceType)));
- newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.transitiveConverters.put(TypeLiteral.of(ifaceType), Collections.unmodifiableList(newConverters));
- }
- Class<?> superClass = targetType.getRawType().getSuperclass();
- while (superClass != null && !superClass.equals(Object.class)) {
- converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(superClass)));
- newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.transitiveConverters.put(TypeLiteral.of(superClass), Collections.unmodifiableList(newConverters));
- for (Class<?> ifaceType : superClass.getInterfaces()) {
- converters = List.class.cast(this.transitiveConverters.get(TypeLiteral.of(ifaceType)));
- newConverters = new ArrayList<>();
- if (converters != null) {
- newConverters.addAll(converters);
- }
- newConverters.add(converter);
- Collections.sort(newConverters, PRIORITY_COMPARATOR);
- this.transitiveConverters.put(TypeLiteral.of(ifaceType), Collections.unmodifiableList(newConverters));
- }
- superClass = superClass.getSuperclass();
- }
- } finally {
- writeLock.unlock();
- }
- }
-
- /**
- * Allows to evaluate if 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.
- */
- public boolean isTargetTypeSupported(TypeLiteral<?> targetType) {
- if (converters.containsKey(targetType) || transitiveConverters.containsKey(targetType)) {
- return true;
- }
- return createDefaultPropertyConverter(targetType) != null;
- }
-
- /**
- * 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.
- *
- * @return the current map of instantiated and registered converters.
- * @see #createDefaultPropertyConverter(TypeLiteral)
- */
- public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
- Lock readLock = lock.readLock();
- try {
- readLock.lock();
- return new HashMap<>(this.converters);
- } finally {
- readLock.unlock();
- }
- }
-
- /**
- * <p>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
- * converter based on String costructor or static factory methods available.</p>
- *
- * <p>The converters provided are of the following type and returned in the following order:</p>
- * <ul>
- * <li>Converters mapped explicitly to the required target type are returned first, ordered
- * by decreasing priority. This means, if explicit converters are registered these are used
- * primarly for converting a value.</li>
- * <li>The target type of each explicitly registered converter also can be transitively mapped to
- * 1) all directly implemented interfaces, 2) all its superclasses (except Object), 3) all the interfaces
- * implemented by its superclasses. These groups of transitive converters is returned similarly in the
- * order as mentioned, whereas also here a priority based decreasing ordering is applied.</li>
- * <li>java.lang wrapper classes and native types are automatically mapped.</li>
- * <li>If no explicit converters are registered, for Enum types a default implementation is provided that
- * compares the configuration values with the different enum members defined (cases sensitive mapping).</li>
- * </ul>
- *
- * <p>So given that list above directly registered mappings always are tried first, before any transitive mapping
- * should be used. Also in all cases @Priority annotations are honored for ordering of the converters in place.
- * Transitive conversion is supported for all directly implemented interfaces (including inherited ones) and
- * the inheritance hierarchy (exception Object). Super interfaces of implemented interfaces are ignored.</p>
- *
- *
- * @param targetType the target type, not null.
- * @param <T> the type class
- * @return the ordered list of converters (may be empty for not convertible types).
- * @see #createDefaultPropertyConverter(TypeLiteral)
- */
- public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> targetType) {
- Lock readLock = lock.readLock();
- List<PropertyConverter<T>> converterList = new ArrayList<>();
- List<PropertyConverter<T>> converters;
- // direct mapped converters
- try {
- readLock.lock();
- converters = List.class.cast(this.converters.get(targetType));
- } finally {
- readLock.unlock();
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- // transitive converter
- try {
- readLock.lock();
- converters = List.class.cast(this.transitiveConverters.get(targetType));
- } finally {
- readLock.unlock();
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- // handling of java.lang wrapper classes
- TypeLiteral<T> boxedType = mapBoxedType(targetType);
- if (boxedType != null) {
- try {
- readLock.lock();
- converters = List.class.cast(this.converters.get(boxedType));
- } finally {
- readLock.unlock();
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- }
- if (converterList.isEmpty()) {
- // adding any converters created on the fly, e.g. for enum types.
- PropertyConverter<T> defaultConverter = createDefaultPropertyConverter(targetType);
- if (defaultConverter != null) {
- register(targetType, defaultConverter);
- try {
- readLock.lock();
- converters = List.class.cast(this.converters.get(targetType));
- } finally {
- readLock.unlock();
- }
- }
- if (converters != null) {
- converterList.addAll(converters);
- }
- }
- return converterList;
- }
-
- /**
- * Maps native types to the corresponding boxed types.
- *
- * @param targetType the native type.
- * @param <T> the type
- * @return the boxed type, or null.
- */
- private <T> TypeLiteral<T> mapBoxedType(TypeLiteral<T> targetType) {
- Type parameterType = targetType.getType();
- if (parameterType == int.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Integer.class));
- }
- if (parameterType == short.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Short.class));
- }
- if (parameterType == byte.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Byte.class));
- }
- if (parameterType == long.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Long.class));
- }
- if (parameterType == boolean.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class));
- }
- if (parameterType == char.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Character.class));
- }
- if (parameterType == float.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Float.class));
- }
- if (parameterType == double.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Double.class));
- }
- if (parameterType == int[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Integer[].class));
- }
- if (parameterType == short[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Short[].class));
- }
- if (parameterType == byte[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Byte[].class));
- }
- if (parameterType == long[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Long[].class));
- }
- if (parameterType == boolean.class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Boolean.class));
- }
- if (parameterType == char[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Character[].class));
- }
- if (parameterType == float[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Float[].class));
- }
- if (parameterType == double[].class) {
- return TypeLiteral.class.cast(TypeLiteral.of(Double[].class));
- }
- return null;
- }
-
- /**
- * Creates a dynamic PropertyConverter for the given target type.
- *
- * @param targetType the target type
- * @param <T> the type class
- * @return a new converter, or null.
- */
- protected <T> PropertyConverter<T> createDefaultPropertyConverter(final TypeLiteral<T> targetType) {
- if (Enum.class.isAssignableFrom(targetType.getRawType())) {
- return new EnumConverter<>(targetType.getRawType());
- }
- PropertyConverter<T> converter = null;
- final Method factoryMethod = getFactoryMethod(targetType.getRawType(), "of", "valueOf", "instanceOf", "getInstance", "from", "fromString", "parse");
- if (factoryMethod != null) {
- converter = new PropertyConverter<T>() {
- @Override
- public T convert(String value, ConversionContext context) {
- context.addSupportedFormats(PropertyConverter.class, "static T of(String)", "static T valueOf(String)",
- "static T getInstance(String)", "static T from(String)",
- "static T fromString(String)", "static T parse(String)");
- try {
- if (!Modifier.isStatic(factoryMethod.getModifiers())) {
- throw new ConfigException(factoryMethod.toGenericString() +
- " is not a static method. Only static " +
- "methods can be used as factory methods.");
- }
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- @Override
- public Object run() {
- factoryMethod.setAccessible(true);
- return null;
- }
- });
- Object invoke = factoryMethod.invoke(null, value);
- return targetType.getRawType().cast(invoke);
- } catch (Exception e) {
- throw new ConfigException("Failed to decode '" + value + "'", e);
- }
- }
- };
- }
- if (converter == null) {
- try {
- final Constructor<T> constr = targetType.getRawType().getDeclaredConstructor(String.class);
- converter = new PropertyConverter<T>() {
- @Override
- public T convert(String value, ConversionContext context) {
- context.addSupportedFormats(PropertyConverter.class, "new T(String)");
- try {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- @Override
- public Object run() {
- constr.setAccessible(true);
- return null;
- }
- });
- return constr.newInstance(value);
- } catch (Exception e) {
- throw new ConfigException("Failed to decode '" + value + "'", e);
- }
- }
- };
- } catch (Exception e) {
- LOG.finest("Failed to construct instance of type: " + targetType.getRawType().getName() + ": " + e);
- }
- }
- return converter;
- }
-
- /**
- * Tries to evaluate a factory method that can be used to create an instance based on a String.
- *
- * @param type the target type
- * @param methodNames the possible static method names
- * @return the first method found, or null.
- */
- private Method getFactoryMethod(Class<?> type, String... methodNames) {
- Method m;
- for (String name : methodNames) {
- try {
- m = type.getDeclaredMethod(name, String.class);
- return m;
- } catch (NoSuchMethodException | RuntimeException e) {
- LOG.finest("No such factory method found on type: " + type.getName() + ", methodName: " + name);
- }
- }
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/SEInjectorCDIExtension.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/SEInjectorCDIExtension.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/SEInjectorCDIExtension.java
deleted file mode 100644
index 86e95b0..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/SEInjectorCDIExtension.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.integration.cdi;
-
-
-import org.apache.tamaya.inject.ConfigurationInjection;
-import org.apache.tamaya.inject.api.Config;
-import org.apache.tamaya.inject.api.ConfigDefaultSections;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Vetoed;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.InjectionTarget;
-import javax.enterprise.inject.spi.ProcessInjectionTarget;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Set;
-
-/**
- * CDI portable extension that integrates {@link org.apache.tamaya.inject.ConfigurationInjector}
- * with CDI by adding configuration features to CDI (config enable CDI beans).
- */
-@Vetoed
-public final class SEInjectorCDIExtension implements Extension {
-
- /**
- * Method that injects the values into any configured fields, by wrapping the given
- * InjectionTarget.
- * @param pit the injection target
- * @param <T> the target type
- */
- public <T> void initializeConfiguredFields(final @Observes ProcessInjectionTarget<T> pit) {
- final AnnotatedType<T> at = pit.getAnnotatedType();
- if (!isConfigured(at.getJavaClass())) {
- return;
- }
- final InjectionTarget<T> it = pit.getInjectionTarget();
- InjectionTarget<T> wrapped = new InjectionTarget<T>() {
- @Override
- public void inject(T instance, CreationalContext<T> ctx) {
- it.inject(instance, ctx);
- ConfigurationInjection.getConfigurationInjector().configure(instance);
- }
-
- @Override
- public void postConstruct(T instance) {
- it.postConstruct(instance);
- }
-
- @Override
- public void preDestroy(T instance) {
- it.dispose(instance);
- }
-
- @Override
- public void dispose(T instance) {
- it.dispose(instance);
- }
-
- @Override
- public Set<InjectionPoint> getInjectionPoints() {
- return it.getInjectionPoints();
- }
-
- @Override
- public T produce(CreationalContext<T> ctx) {
- return it.produce(ctx);
- }
- };
- pit.setInjectionTarget(wrapped);
- }
-
- private boolean isConfigured(Class type) {
- if (type.getAnnotation(ConfigDefaultSections.class) != null) {
- return true;
- }
- // if no class level annotation is there we might have field level annotations only
- for (Field field : type.getDeclaredFields()) {
- if (field.isAnnotationPresent(Config.class)) {
- return true;
- }
- }
- // if no class level annotation is there we might have method level annotations only
- for (Method method : type.getDeclaredMethods()) {
- if(method.isAnnotationPresent(Config.class)) {
- return true;
- }
- }
- return false;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/ServiceLoaderServiceContext.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/ServiceLoaderServiceContext.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/ServiceLoaderServiceContext.java
deleted file mode 100644
index 5171d91..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/ServiceLoaderServiceContext.java
+++ /dev/null
@@ -1,151 +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.integration.cdi;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.ServiceContext;
-
-import javax.annotation.Priority;
-import java.text.MessageFormat;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * This class implements the (default) {@link ServiceContext} interface and hereby uses the JDK
- * {@link ServiceLoader} to load the services required.
- */
-final class ServiceLoaderServiceContext 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) {
- Object cached = singletons.get(serviceType);
- if (cached == null) {
- Collection<T> services = getServices(serviceType);
- if (services.isEmpty()) {
- cached = null;
- } else {
- cached = getServiceWithHighestPriority(services, serviceType);
- }
- if(cached!=null) {
- singletons.put(serviceType, cached);
- }
- }
- return serviceType.cast(cached);
- }
-
- /**
- * Loads and registers services.
- *
- * @param <T> the concrete type.
- * @param serviceType The service type.
- * @return the items found, never {@code null}.
- */
- @Override
- public <T> List<T> getServices(final Class<T> serviceType) {
- List<T> found = (List<T>) servicesLoaded.get(serviceType);
- if (found != null) {
- return found;
- }
- List<T> services = new ArrayList<>();
- try {
- for (T t : ServiceLoader.load(serviceType)) {
- services.add(t);
- }
- services = Collections.unmodifiableList(services);
- } catch (Exception e) {
- Logger.getLogger(ServiceLoaderServiceContext.class.getName()).log(Level.WARNING,
- "Error loading services current type " + serviceType, e);
- }
- final List<T> previousServices = List.class.cast(servicesLoaded.putIfAbsent(serviceType, (List<Object>) services));
- return previousServices != null ? previousServices : services;
- }
-
- /**
- * Checks the given instance for a @Priority annotation. If present the annotation's value s evaluated. If no such
- * annotation is present, a default priority is returned (1);
- * @param o the instance, not null.
- * @return a priority, by default 1.
- */
- public static int getPriority(Object o){
- int prio = 1; //X TODO discuss default priority
- Priority priority = o.getClass().getAnnotation(Priority.class);
- if (priority != null) {
- prio = priority.value();
- }
- return prio;
- }
-
- /**
- * @param services to scan
- * @param <T> type of the service
- *
- * @return the service with the highest {@link Priority#value()}
- *
- * @throws ConfigException if there are multiple service implementations with the maximum priority
- */
- private <T> T getServiceWithHighestPriority(Collection<T> services, Class<T> serviceType) {
-
- // we do not need the priority stuff if the list contains only one element
- if (services.size() == 1) {
- return services.iterator().next();
- }
-
- Integer highestPriority = null;
- int highestPriorityServiceCount = 0;
- T highestService = null;
-
- for (T service : services) {
- int prio = getPriority(service);
- if (highestPriority == null || highestPriority < prio) {
- highestService = service;
- highestPriorityServiceCount = 1;
- highestPriority = prio;
- } else if (highestPriority == prio) {
- highestPriorityServiceCount++;
- }
- }
-
- if (highestPriorityServiceCount > 1) {
- throw new ConfigException(MessageFormat.format("Found {0} implementations for Service {1} with Priority {2}: {3}",
- highestPriorityServiceCount,
- serviceType.getName(),
- highestPriority,
- services));
- }
-
- return highestService;
- }
-
- @Override
- public int ordinal() {
- return 1;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaCDIIntegration.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaCDIIntegration.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaCDIIntegration.java
deleted file mode 100644
index 3f62039..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaCDIIntegration.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.integration.cdi;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterDeploymentValidation;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Extension;
-
-/**
- * Tamaya main integration with CDI, storing the BeanManager reference for implementation, where no
- * JNDI is available or {@code java:comp/env/BeanManager} is not set correctly.
- */
-public class TamayaCDIIntegration implements Extension {
- /** The BeanManager references stored. */
- private static BeanManager beanManager;
-
- /**
- * Initializes the current BeanManager with the instance passed.
- * @param validation the event
- * @param beanManager the BeanManager instance
- */
- @SuppressWarnings("all")
- public void initBeanManager(@Observes AfterDeploymentValidation validation, BeanManager beanManager){
- TamayaCDIIntegration.beanManager = beanManager;
- }
-
- /**
- * Get the current {@link BeanManager} instance.
- * @return the currently used bean manager.
- */
- public static BeanManager getBeanManager(){
- return beanManager;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaConfigProvider.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaConfigProvider.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaConfigProvider.java
deleted file mode 100644
index f2763e5..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/TamayaConfigProvider.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tamaya.integration.cdi;
-
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spisupport.DefaultConfiguration;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.Produces;
-import javax.inject.Singleton;
-
-/**
- * Tamaya main integreation with CDI (singleton) serving producers for Configuration, ConfigurationContext and
- * ConfigurationContextBuilder.
- */
-@Singleton
-public class TamayaConfigProvider{
-
- @Produces
- @ApplicationScoped
- public Configuration getConfiguration(ConfigurationContext context){
- return new DefaultConfiguration(context);
- }
-
- @Produces @ApplicationScoped
- public ConfigurationContext getConfigurationContext(){
- return new DefaultConfigurationContext();
- }
-
- @Produces
- public ConfigurationContextBuilder getConfigurationContextBuilder(){
- return new DefaultConfigurationContextBuilder();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/config/ConfiguredVetoExtension.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/config/ConfiguredVetoExtension.java b/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/config/ConfiguredVetoExtension.java
deleted file mode 100644
index f90998d..0000000
--- a/modules/integration/cdi-se/src/main/java/org/apache/tamaya/integration/cdi/config/ConfiguredVetoExtension.java
+++ /dev/null
@@ -1,42 +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.integration.cdi.config;
-
-import org.apache.tamaya.ConfigurationProvider;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-
-/**
- * CDI Extension that can be used to veto on beans by configuring the fully qualified class names (as regex expression)
- * under {@code javax.enterprise.inject.vetoed}. Multiple expression can be added as comma separated values.
- */
-public class ConfiguredVetoExtension {
-
- public void observesBean(@Observes ProcessAnnotatedType<?> type){
- String vetoedTypesVal = ConfigurationProvider.getConfiguration().get("javax.enterprise.inject.vetoed");
- String[] vetoedTypes = vetoedTypesVal.split(",");
- for(String typeExpr:vetoedTypes){
- if(type.getAnnotatedType().getJavaClass().getName().matches(typeExpr)){
- type.veto();
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/resources/META-INF/beans.xml b/modules/integration/cdi-se/src/main/resources/META-INF/beans.xml
deleted file mode 100644
index adee378..0000000
--- a/modules/integration/cdi-se/src/main/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy 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.
--->
-<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
-
-</beans>
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension b/modules/integration/cdi-se/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
deleted file mode 100644
index 8580a42..0000000
--- a/modules/integration/cdi-se/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
+++ /dev/null
@@ -1,20 +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.integration.cdi.TamayaCDIIntegration
-org.apache.tamaya.integration.cdi.SEInjectorCDIExtension
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext b/modules/integration/cdi-se/src/main/resources/META-INF/services/org.apache.tamaya.spi.ServiceContext
deleted file mode 100644
index 4fe7e01..0000000
--- a/modules/integration/cdi-se/src/main/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.integration.cdi.CDIAwareServiceContext
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java
deleted file mode 100644
index 9d920bc..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredClass.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy 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.
- *
- */
-package org.apache.tamaya.integration.cdi;
-
-import org.apache.tamaya.inject.api.Config;
-
-import java.math.BigDecimal;
-
-import javax.inject.Singleton;
-
-/**
- * Class to be loaded from CDI to ensure fields are correctly configured using CDI injection mechanisms.
- */
-@Singleton
-public class ConfiguredClass{
-
- @Config
- private String testProperty;
-
- @Config(value = {"a.b.c.key1","a.b.c.key2","a.b.c.key3"}, defaultValue = "The current \\${JAVA_HOME} env property is ${env:JAVA_HOME}.")
- String value1;
-
- @Config({"foo","a.b.c.key2"})
- private String value2;
-
- @Config(defaultValue = "N/A")
- private String runtimeVersion;
-
- @Config(defaultValue = "${sys:java.version}")
- private String javaVersion2;
-
- @Config(defaultValue = "5")
- private Integer int1;
-
- @Config
- private int int2;
-
- @Config
- private boolean booleanT;
-
- @Config("BD")
- private BigDecimal bigNumber;
-
- @Config("double1")
- private double doubleValue;
-
- public String getTestProperty() {
- return testProperty;
- }
-
- public String getValue1() {
- return value1;
- }
-
- public String getValue2() {
- return value2;
- }
-
- public String getRuntimeVersion() {
- return runtimeVersion;
- }
-
- public String getJavaVersion2() {
- return javaVersion2;
- }
-
- public Integer getInt1() {
- return int1;
- }
-
- public int getInt2() {
- return int2;
- }
-
- public boolean isBooleanT() {
- return booleanT;
- }
-
- public BigDecimal getBigNumber() {
- return bigNumber;
- }
-
- public double getDoubleValue() {
- return doubleValue;
- }
-
- @Override
- public String toString(){
- return super.toString() + ": testProperty="+testProperty+", value1="+value1+", value2="+value2
- +", int1="+int1+", int2="+int2+", booleanT="+booleanT+", bigNumber="+bigNumber
- +", runtimeVersion="+runtimeVersion+", javaVersion2="+javaVersion2;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.java
deleted file mode 100644
index 69e8ef9..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/ConfiguredTest.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 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.
- *
- */
-package org.apache.tamaya.integration.cdi;
-
-import org.apache.deltaspike.testcontrol.api.TestControl;
-import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
-import org.hamcrest.MatcherAssert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.inject.spi.CDI;
-import javax.inject.Singleton;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests for CDI integration.
- */
-@RunWith(CdiTestRunner.class)
-@TestControl(startScopes = {ApplicationScoped.class, Singleton.class})
-public class ConfiguredTest{
-
- @Test
- public void test_Configuration_is_injected_correctly(){
- ConfiguredClass item = CDI.current().select(ConfiguredClass.class).get();
- System.out.println("********************************************");
- System.out.println(item);
- System.out.println("********************************************");
- double actual = 1234.5678;
- MatcherAssert.assertThat(item.getDoubleValue(), is(actual));
- }
-
- @Test
- public void test_Default_injections_are_accessible(){
- InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get();
- System.out.println("********************************************");
- System.out.println(injectedClass);
- System.out.println("********************************************");
- assertNotNull(injectedClass.builder1);
- assertNotNull(injectedClass.builder2);
- assertNotNull(injectedClass.config);
- assertNotNull(injectedClass.configContext);
- }
-
- @Test
- public void test_Injected_builders_are_notSame(){
- InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get();
- assertTrue(injectedClass.builder1 != injectedClass.builder2);
- }
-
- @Test
- public void test_Injected_configs_are_same(){
- InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get();
- assertTrue(injectedClass.config == injectedClass.config2);
- }
-
- @Test
- public void test_Injected_configContexts_are_same(){
- InjectedClass injectedClass = CDI.current().select(InjectedClass.class).get();
- assertTrue(injectedClass.configContext == injectedClass.configContext2);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java
deleted file mode 100644
index 9b7bd23..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/InjectedClass.java
+++ /dev/null
@@ -1,62 +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.
- *
- */
-package org.apache.tamaya.integration.cdi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-/**
- * Class loaded by CDI to test correct injection of Configuration API artifacts.
- */
-@Singleton
-public class InjectedClass {
-
- @Inject
- Configuration config;
-
- @Inject
- Configuration config2;
-
- @Inject
- ConfigurationContext configContext;
-
- @Inject
- ConfigurationContext configContext2;
-
- @Inject
- ConfigurationContextBuilder builder1;
-
- @Inject
- ConfigurationContextBuilder builder2;
-
- @Override
- public String toString() {
- return "InjectedClass{" +
- "config=" + config +
- ", configContext=" + configContext +
- ", builder1=" + builder1 +
- ", builder2=" + builder2 +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java
deleted file mode 100644
index f7e3c6d..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/ProvidedPropertySource.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy 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.
- *
- */
-package org.apache.tamaya.integration.cdi.cfg;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import javax.enterprise.inject.Vetoed;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by Anatole on 17.09.2015.
- */
-@Vetoed
-class ProvidedPropertySource implements PropertySource{
-
- final Map<String,String> config = new HashMap<>();
-
- public ProvidedPropertySource(){
- config.put("a.b.c.key3", "keys current a.b.c.key3");
- config.put("a.b.c.key4", "keys current a.b.c.key4");
- config.put("{meta}source.type:"+getClass().getName(), "PropertySourceProvider");
- }
-
- @Override
- public int getOrdinal() {
- return 10;
- }
-
- @Override
- public String getName() {
- return getClass().getName();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, config.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return config;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java
deleted file mode 100644
index 7b89fba..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestConfigProvider.java
+++ /dev/null
@@ -1,45 +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.
- */
-package org.apache.tamaya.integration.cdi.cfg;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertySourceProvider;
-
-import javax.enterprise.context.ApplicationScoped;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * Created by Anatole on 29.09.2014.
- */
-@ApplicationScoped
-public class TestConfigProvider implements PropertySourceProvider {
-
- private List<PropertySource> configs = new ArrayList<>();
-
- public TestConfigProvider(){
- configs.add(new ProvidedPropertySource());
- }
-
- @Override
- public Collection<PropertySource> getPropertySources() {
- return configs;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java b/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java
deleted file mode 100644
index 75c55ca..0000000
--- a/modules/integration/cdi-se/src/test/java/org/apache/tamaya/integration/cdi/cfg/TestPropertySource.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy 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.
- *
- */
-package org.apache.tamaya.integration.cdi.cfg;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import javax.inject.Singleton;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by Anatole on 17.09.2015.
- */
-@Singleton
-public class TestPropertySource implements PropertySource{
-
- final Map<String,String> config = new HashMap<>();
-
- public TestPropertySource(){
- config.put("a.b.c.key1", "keys current a.b.c.key1");
- config.put("a.b.c.key2", "keys current a.b.c.key2");
- config.put("a.b.key3", "keys current a.b.key3");
- config.put("a.b.key4", "keys current a.b.key4");
- config.put("a.key5", "keys current a.key5");
- config.put("a.key6", "keys current a.key6");
- config.put("int1", "123456");
- config.put("int2", "111222");
- config.put("testProperty", "testPropertyValue!");
- config.put("booleanT", "true");
- config.put("double1", "1234.5678");
- config.put("BD", "123456789123456789123456789123456789.123456789123456789123456789123456789");
- config.put("testProperty", "keys current testProperty");
- config.put("runtimeVersion", "${java.version}");
- config.put("{meta}source.type:"+getClass().getName(), "PropertySource");
- }
-
- @Override
- public int getOrdinal() {
- return 10;
- }
-
- @Override
- public String getName() {
- return getClass().getName();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, config.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return config;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/resources/META-INF/beans.xml b/modules/integration/cdi-se/src/test/resources/META-INF/beans.xml
deleted file mode 100644
index adee378..0000000
--- a/modules/integration/cdi-se/src/test/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy 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.
--->
-<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
-
-</beans>
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi-se/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/integration/cdi-se/src/test/resources/META-INF/javaconfiguration.properties b/modules/integration/cdi-se/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index 362ce0b..0000000
--- a/modules/integration/cdi-se/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,20 +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.
-#
-double1=1234.5678
-int2=13
-booleanT=y
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/pom.xml
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/pom.xml b/modules/integration/cdi/pom.xml
deleted file mode 100644
index 34481f6..0000000
--- a/modules/integration/cdi/pom.xml
+++ /dev/null
@@ -1,224 +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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-integration</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- </parent>
-
- <artifactId>tamaya-cdi</artifactId>
- <name>Apache Tamaya Integration - CDI (Java EE)</name>
- <packaging>bundle</packaging>
-
- <properties>
- <owb.version>1.6.2</owb.version>
- <weld.version>2.2.7.Final</weld.version>
- <geronimo-jcdi-1.1-spec.version>1.0</geronimo-jcdi-1.1-spec.version>
- <geronimo-interceptor-1.2-spec.version>1.0</geronimo-interceptor-1.2-spec.version>
- <geronimo-atinject-1.0-spec.version>1.0</geronimo-atinject-1.0-spec.version>
- <bval.version>0.5</bval.version>
- <ds.version>1.1.0</ds.version>
- <javaee-api.version>6.0-6</javaee-api.version>
- <openejb.version>4.7.1</openejb.version>
- <tomee.version>1.7.1</tomee.version>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.jacoco</groupId>
- <artifactId>jacoco-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>prepare-agent</id>
- <goals>
- <goal>prepare-agent</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.integration.cdi
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-injection-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.openejb</groupId>
- <artifactId>javaee-api</artifactId>
- <version>${javaee-api.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.tomitribe</groupId>
- <artifactId>tomitribe-util</artifactId>
- <version>1.1.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.openejb</groupId>
- <artifactId>openejb-core</artifactId>
- <version>${openejb.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jcdi_1.1_spec</artifactId>
- <version>${geronimo-jcdi-1.1-spec.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.deltaspike.modules</groupId>
- <artifactId>deltaspike-test-control-module-api</artifactId>
- <version>${ds.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.deltaspike.modules</groupId>
- <artifactId>deltaspike-test-control-module-impl</artifactId>
- <version>${ds.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <profiles>
- <!--<profile>-->
- <!--<id>OWB</id>-->
- <!--<!– there is an issue with this profile:-->
- <!--java.lang.NoClassDefFoundError: org/apache/webbeans/event/EventMetadata-->
- <!--–>-->
- <!--<activation>-->
- <!--<activeByDefault>false</activeByDefault>-->
- <!--</activation>-->
- <!--<dependencies>-->
- <!--<!– OWB specific dependencies–>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.geronimo.specs</groupId>-->
- <!--<artifactId>geronimo-atinject_1.0_spec</artifactId>-->
- <!--<version>${geronimo-atinject-1.0-spec.version}</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.geronimo.specs</groupId>-->
- <!--<artifactId>geronimo-interceptor_1.2_spec</artifactId>-->
- <!--<version>${geronimo-interceptor-1.2-spec.version}</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.geronimo.specs</groupId>-->
- <!--<artifactId>geronimo-annotation_1.2_spec</artifactId>-->
- <!--<version>1.0</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.geronimo.specs</groupId>-->
- <!--<artifactId>geronimo-el_2.2_spec</artifactId>-->
- <!--<version>1.0.2</version>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>org.apache.openwebbeans</groupId>-->
- <!--<artifactId>openwebbeans-impl</artifactId>-->
- <!--<version>${owb.version}</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.openwebbeans</groupId>-->
- <!--<artifactId>openwebbeans-spi</artifactId>-->
- <!--<version>${owb.version}</version>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.openwebbeans</groupId>-->
- <!--<artifactId>openwebbeans-resource</artifactId>-->
- <!--<version>${owb.version}</version>-->
- <!--</dependency>-->
-
- <!--<dependency>-->
- <!--<groupId>org.apache.bval</groupId>-->
- <!--<artifactId>bval-jsr303</artifactId>-->
- <!--<version>${bval.version}</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
- <!--<dependency>-->
- <!--<groupId>org.apache.deltaspike.cdictrl</groupId>-->
- <!--<artifactId>deltaspike-cdictrl-owb</artifactId>-->
- <!--<version>${ds.version}</version>-->
- <!--<scope>test</scope>-->
- <!--</dependency>-->
- <!--</dependencies>-->
- <!--</profile>-->
- <profile>
- <id>Weld</id>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- <dependencies>
- <dependency>
- <groupId>org.jboss.weld.se</groupId>
- <artifactId>weld-se</artifactId>
- <version>${weld.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.deltaspike.cdictrl</groupId>
- <artifactId>deltaspike-cdictrl-weld</artifactId>
- <version>${ds.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredField.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredField.java b/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredField.java
deleted file mode 100644
index fa826f5..0000000
--- a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredField.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.integration.cdi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.inject.spi.ConfiguredField;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * CDI implementation for event publishing of configured instances.
- */
-class CDIConfiguredField implements ConfiguredField{
-
- private final Field field;
- private List<String> keys = new ArrayList<>();
-
- CDIConfiguredField(InjectionPoint injectionPoint, List<String> keys){
- this.field = (Field)injectionPoint.getMember();
- this.keys.addAll(keys);
- this.keys = Collections.unmodifiableList(this.keys);
- }
-
- @Override
- public Class<?> getType() {
- return field.getType();
- }
-
- @Override
- public Collection<String> getConfiguredKeys() {
- return keys;
- }
-
- @Override
- public Field getAnnotatedField() {
- return field;
- }
-
- @Override
- public String getName() {
- return field.getName();
- }
-
- @Override
- public String getSignature() {
- return getName()+':'+field.getType().getName();
- }
-
- @Override
- public void configure(Object instance, Configuration config) {
- throw new UnsupportedOperationException("Use CDI annotations for configuration injection.");
- }
-
- @Override
- public String toString() {
- return "CDIConfiguredField["+getSignature()+']';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredMethod.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredMethod.java b/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredMethod.java
deleted file mode 100644
index ed8019a..0000000
--- a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredMethod.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.integration.cdi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.inject.spi.ConfiguredMethod;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Implementation of a configured methods for CDI module.
- */
-public class CDIConfiguredMethod implements ConfiguredMethod{
-
- private final Method method;
- private List<String> keys = new ArrayList<>();
-
- CDIConfiguredMethod(InjectionPoint injectionPoint, List<String> keys){
- this.method = (Method)injectionPoint.getMember();
- this.keys.addAll(keys);
- this.keys = Collections.unmodifiableList(this.keys);
- }
-
- @Override
- public Collection<String> getConfiguredKeys() {
- return keys;
- }
-
- @Override
- public Class<?>[] getParameterTypes() {
- return method.getParameterTypes();
- }
-
- @Override
- public Method getAnnotatedMethod() {
- return method;
- }
-
- @Override
- public String getName() {
- return method.getName();
- }
-
- @Override
- public String getSignature() {
- return null;
- }
-
- @Override
- public void configure(Object instance, Configuration config) {
- throw new UnsupportedOperationException("Use CDI annotations for configuration injection.");
- }
-
- @Override
- public String toString() {
- return "CDIConfiguredMethod["+getSignature()+']';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredType.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredType.java b/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredType.java
deleted file mode 100644
index c677065..0000000
--- a/modules/integration/cdi/src/main/java/org/apache/tamaya/integration/cdi/CDIConfiguredType.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tamaya.integration.cdi;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.inject.spi.ConfiguredField;
-import org.apache.tamaya.inject.spi.ConfiguredMethod;
-import org.apache.tamaya.inject.spi.ConfiguredType;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * Event published for items configured by CDI extensions. This is for example used by the documentation module
- * to automatically track the configuration endpoints for documentation.
- */
-class CDIConfiguredType implements ConfiguredType{
-
- private final Class<?> type;
- private final List<CDIConfiguredMethod> methods = new ArrayList<>();
- private final List<CDIConfiguredField> fields = new ArrayList<>();
-
- public CDIConfiguredType(Class<?> type){
- this.type = Objects.requireNonNull(type);
- }
-
- @Override
- public Class getType() {
- return type;
- }
-
- @Override
- public String getName() {
- return type.getName();
- }
-
- @Override
- public Collection<ConfiguredField> getConfiguredFields() {
- return null;
- }
-
- @Override
- public Collection<ConfiguredMethod> getConfiguredMethods() {
- return null;
- }
-
- @Override
- public void configure(Object instance, Configuration config) {
- throw new UnsupportedOperationException("Use CDI annotations for configuration injection.");
- }
-
- /**
- * Used to build up during injection point processing.
- * @param injectionPoint the CDI injection ppint, not null.
- * @param keys the possible config keys, in order of precedence, not null.
- */
- void addConfiguredMember(InjectionPoint injectionPoint, List<String> keys) {
- Member member = injectionPoint.getMember();
- if(member instanceof Field){
- this.fields.add(new CDIConfiguredField(injectionPoint, keys));
- } else if(member instanceof Method){
- this.methods.add(new CDIConfiguredMethod(injectionPoint, keys));
- }
- }
-
- @Override
- public String toString() {
- return "CDIConfiguredType{" +
- "type=" + type +
- ", methods=" + methods +
- ", fields=" + fields +
- '}';
- }
-}