Repository: incubator-tamaya-extensions Updated Branches: refs/heads/master 3e1a12102 -> 5d8be5ffa
TAMAYA-323: Refactorings * Fix typos, remove unused imports, add suppress warnings Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/5d8be5ff Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/5d8be5ff Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/5d8be5ff Branch: refs/heads/master Commit: 5d8be5ffa8ee7a13daf0068917ead5ee38ab25bc Parents: 3e1a121 Author: Phil Ottlinger <[email protected]> Authored: Wed Feb 21 20:34:59 2018 +0100 Committer: Phil Ottlinger <[email protected]> Committed: Wed Feb 21 20:34:59 2018 +0100 ---------------------------------------------------------------------- .../microprofile/cdi/BridgingConfigBean.java | 3 +- .../tamaya/microprofile/cdi/ConfiguredType.java | 5 ++- .../cdi/MicroprofileConfigurationProducer.java | 39 ++++++++++---------- .../converter/ProviderConverter.java | 4 +- 4 files changed, 26 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d8be5ff/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java index a08f76f..e6f90c8 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java @@ -32,7 +32,8 @@ final class BridgingConfigBean implements Bean<Object> { private final Bean<Object> delegate; private final Set<Type> types; - public BridgingConfigBean(final Bean delegate, final Set<Type> types) { + @SuppressWarnings({ "unchecked", "rawtypes" }) + public BridgingConfigBean(final Bean delegate, final Set<Type> types) { this.types = types; this.delegate = Objects.requireNonNull(delegate); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d8be5ff/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredType.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredType.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredType.java index 535a556..92b535e 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredType.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredType.java @@ -41,7 +41,8 @@ public final class ConfiguredType { this.type = Objects.requireNonNull(type); } - public Class getType() { + @SuppressWarnings("rawtypes") + public Class getType() { return type; } @@ -64,7 +65,7 @@ public final class ConfiguredType { /** * Used to build up during injection point processing. * @param injectionPoint the CDI injection point, not null. - * @param key the possible config key, not null. + * @param key the possible configuration key, not null. */ void addConfiguredMember(InjectionPoint injectionPoint, String key) { Member member = injectionPoint.getMember(); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d8be5ff/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java index bae7287..2f81305 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java @@ -16,6 +16,20 @@ */ package org.apache.tamaya.microprofile.cdi; +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.List; +import java.util.Optional; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.inject.Produces; +import javax.enterprise.inject.spi.InjectionPoint; +import javax.inject.Provider; + import org.apache.tamaya.ConfigException; import org.apache.tamaya.Configuration; import org.apache.tamaya.ConfigurationProvider; @@ -28,22 +42,6 @@ import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.config.spi.ConfigBuilder; import org.eclipse.microprofile.config.spi.ConfigProviderResolver; -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.inject.Produces; -import javax.enterprise.inject.spi.Annotated; -import javax.enterprise.inject.spi.AnnotatedField; -import javax.enterprise.inject.spi.AnnotatedType; -import javax.enterprise.inject.spi.InjectionPoint; -import javax.inject.Provider; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Method; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.List; -import java.util.Optional; -import java.util.logging.Level; -import java.util.logging.Logger; - /** * Producer bean for configuration properties. */ @@ -63,7 +61,7 @@ public class MicroprofileConfigurationProducer { } // unless the extension is not installed, this should never happen because the extension - // enforces the resolvability of the config + // enforces the resolvability of the configuration String defaultTextValue = annotation.defaultValue().equals(ConfigProperty.UNCONFIGURED_VALUE) ? null : annotation.defaultValue(); ConversionContext conversionContext = createConversionContext(key, injectionPoint); @@ -77,7 +75,8 @@ public class MicroprofileConfigurationProducer { return value; } - static String getDefaultKey(InjectionPoint injectionPoint) { + @SuppressWarnings("rawtypes") + static String getDefaultKey(InjectionPoint injectionPoint) { Class declaringType = injectionPoint.getMember().getDeclaringClass(); return declaringType.getCanonicalName() + "." + injectionPoint.getMember().getName(); } @@ -114,6 +113,7 @@ public class MicroprofileConfigurationProducer { return builder.build(); } + @SuppressWarnings({ "rawtypes", "unchecked" }) static Object resolveValue(String defaultTextValue, ConversionContext context, InjectionPoint injectionPoint) { Config config = ConfigProviderResolver.instance().getConfig(); String textValue = config.getOptionalValue(context.getKey(), String.class).orElse(defaultTextValue); @@ -123,7 +123,7 @@ public class MicroprofileConfigurationProducer { Object value = null; if (textValue != null || Optional.class.equals(context.getTargetType().getRawType())) { LOGGER.log(Level.FINEST, () -> "Converting KEY: " + context.getKey() + "("+context.getTargetType()+"), textValue: " + textValue); - List<PropertyConverter> converters = ConfigurationProvider.getConfiguration().getContext() + List<PropertyConverter> converters = ConfigurationProvider.getConfiguration().getContext() .getPropertyConverters((TypeLiteral)context.getTargetType()); for (PropertyConverter<Object> converter : converters) { try { @@ -152,5 +152,4 @@ public class MicroprofileConfigurationProducer { return ConfigProviderResolver.instance().getBuilder(); } - } http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/5d8be5ff/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java ---------------------------------------------------------------------- diff --git a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java index 0bd13ba..a9fcf95 100644 --- a/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java +++ b/modules/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java @@ -40,7 +40,7 @@ public class ProviderConverter implements PropertyConverter<Provider> { private static final Logger LOG = Logger.getLogger(ProviderConverter.class.getName()); - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"unchecked"}) @Override public Provider convert(String value, ConversionContext context) { return () -> { @@ -49,7 +49,7 @@ public class ProviderConverter implements PropertyConverter<Provider> { ConvertQuery converter = new ConvertQuery(value, TypeLiteral.of(targetType)); return context.getConfiguration().query(converter); }catch(Exception e){ - throw new ConfigException("Error evaluating config value.", e); + throw new ConfigException("Error evaluating configuration value.", e); } }; }
