TAMAYA-260: Fixed CDI integration for almost any aspects of MP, removed mp from build.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/commit/029a43ca Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/tree/029a43ca Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/diff/029a43ca Branch: refs/heads/java8 Commit: 029a43ca63eb1fc0a809ac337a63c351ae142d28 Parents: 88b39ef Author: anatole <anat...@apache.org> Authored: Sun Aug 13 23:51:10 2017 +0200 Committer: anatole <anat...@apache.org> Committed: Sun Aug 13 23:51:10 2017 +0200 ---------------------------------------------------------------------- .../microprofile/cdi/BridgingConfigBean.java | 2 +- .../microprofile/cdi/ConfiguredField.java | 2 +- .../microprofile/cdi/ConfiguredMethod.java | 2 +- .../tamaya/microprofile/cdi/ConfiguredType.java | 2 +- .../cdi/MicroprofileCDIExtension.java | 2 +- .../cdi/MicroprofileConfigurationProducer.java | 1 + .../converter/ProviderConverter.java | 138 +++++++++---------- .../org.apache.tamaya.spi.PropertyConverter | 2 +- .../imported/CDIPlainInjectionTest.java | 7 +- .../tck/TamayaConfigArchiveProcessor.java | 5 +- pom.xml | 2 +- 11 files changed, 83 insertions(+), 82 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java ---------------------------------------------------------------------- diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java index 0b22c6a..763f6ed 100644 --- a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java +++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/BridgingConfigBean.java @@ -27,7 +27,7 @@ import java.util.Set; /** * Internally used conversion bean. */ -class BridgingConfigBean implements Bean<Object> { +final class BridgingConfigBean implements Bean<Object> { private final Bean<Object> delegate; private final Set<Type> types; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredField.java ---------------------------------------------------------------------- diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredField.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredField.java index 1c9607c..29d7122 100644 --- a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredField.java +++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredField.java @@ -24,7 +24,7 @@ import java.lang.reflect.Field; /** * CDI implementation for event publishing of configured instances. */ -class ConfiguredField { +public final class ConfiguredField { private final Field field; private String key; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredMethod.java ---------------------------------------------------------------------- diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredMethod.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredMethod.java index 74e158a..90204fe 100644 --- a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredMethod.java +++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredMethod.java @@ -24,7 +24,7 @@ import java.lang.reflect.Method; /** * Implementation of a configured methods for CDI module. */ -public class ConfiguredMethod { +public final class ConfiguredMethod { private final Method method; private String key; http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredType.java ---------------------------------------------------------------------- diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredType.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredType.java index e94c075..535a556 100644 --- a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredType.java +++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/ConfiguredType.java @@ -31,7 +31,7 @@ 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. */ -public class ConfiguredType { +public final class ConfiguredType { private final Class<?> type; private final List<ConfiguredMethod> methods = new ArrayList<>(); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileCDIExtension.java ---------------------------------------------------------------------- diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileCDIExtension.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileCDIExtension.java index 1993e7b..9260d3d 100644 --- a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileCDIExtension.java +++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileCDIExtension.java @@ -61,6 +61,7 @@ public class MicroprofileCDIExtension implements Extension { boolean configured = false; for (InjectionPoint injectionPoint : ips) { if (injectionPoint.getAnnotated().isAnnotationPresent(ConfigProperty.class)) { + System.err.println("Configured: " + injectionPoint); final ConfigProperty annotation = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class); String key = !annotation.name().isEmpty()?annotation.name():injectionPoint.getMember().getName(); Member member = injectionPoint.getMember(); @@ -86,7 +87,6 @@ public class MicroprofileCDIExtension implements Extension { if (ppm.getAnnotated().isAnnotationPresent(ConfigProperty.class)) { convBean = ppm.getBean(); } - } public void addConverter(@Observes final AfterBeanDiscovery abd, final BeanManager bm) { http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java ---------------------------------------------------------------------- diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java index e4bbf6b..7a7799f 100644 --- a/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java +++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/cdi/MicroprofileConfigurationProducer.java @@ -45,6 +45,7 @@ public class MicroprofileConfigurationProducer { @Produces @ConfigProperty public Object resolveAndConvert(final InjectionPoint injectionPoint) { + System.err.println("Inject: " + injectionPoint); final ConfigProperty annotation = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class); String key = annotation.name(); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java ---------------------------------------------------------------------- diff --git a/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java b/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java index d50cba9..de57465 100644 --- a/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java +++ b/microprofile/src/main/java/org/apache/tamaya/microprofile/converter/ProviderConverter.java @@ -1,69 +1,69 @@ -/* - * 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.microprofile.converter; - -import org.apache.tamaya.TypeLiteral; -import org.apache.tamaya.spi.ConversionContext; -import org.apache.tamaya.spi.PropertyConverter; - -import javax.inject.Provider; -import java.lang.reflect.Type; -import java.util.Optional; -import java.util.logging.Logger; - -/** - * Converter, converting from String to Boolean. - */ -public class ProviderConverter implements PropertyConverter<Provider> { - - private final Logger LOG = Logger.getLogger(getClass().getName()); - - @Override - public Provider<?> convert(String value, ConversionContext context) { - TypeLiteral<Optional> target = (TypeLiteral<Optional>)context.getTargetType(); - Type targetType = TypeLiteral.getTypeParameters(target.getType())[0]; - return () -> { - Object result = null; - if(String.class.equals(targetType)){ - result = value; - } - for(PropertyConverter pv:context.getConfigurationContext().getPropertyConverters( - TypeLiteral.of(targetType))){ - result = pv.convert(value, context); - if(result!=null){ - break; - } - } - if(result==null){ - throw new IllegalArgumentException("Unconvertable value: " + value); - } - return result; - }; - } - - @Override - public boolean equals(Object o){ - return getClass().equals(o.getClass()); - } - - @Override - public int hashCode(){ - return getClass().hashCode(); - } -} +///* +// * 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.microprofile.converter; +// +//import org.apache.tamaya.TypeLiteral; +//import org.apache.tamaya.spi.ConversionContext; +//import org.apache.tamaya.spi.PropertyConverter; +// +//import javax.inject.Provider; +//import java.lang.reflect.Type; +//import java.util.Optional; +//import java.util.logging.Logger; +// +///** +// * Converter, converting from String to Boolean. +// */ +//public class ProviderConverter implements PropertyConverter<Provider> { +// +// private final Logger LOG = Logger.getLogger(getClass().getName()); +// +// @Override +// public Provider<?> convert(String value, ConversionContext context) { +// TypeLiteral<Optional> target = (TypeLiteral<Optional>)context.getTargetType(); +// Type targetType = TypeLiteral.getTypeParameters(target.getType())[0]; +// return () -> { +// Object result = null; +// if(String.class.equals(targetType)){ +// result = value; +// } +// for(PropertyConverter pv:context.getConfigurationContext().getPropertyConverters( +// TypeLiteral.of(targetType))){ +// result = pv.convert(value, context); +// if(result!=null){ +// break; +// } +// } +// if(result==null){ +// throw new IllegalArgumentException("Unconvertable value: " + value); +// } +// return result; +// }; +// } +// +// @Override +// public boolean equals(Object o){ +// return getClass().equals(o.getClass()); +// } +// +// @Override +// public int hashCode(){ +// return getClass().hashCode(); +// } +//} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/microprofile/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter ---------------------------------------------------------------------- diff --git a/microprofile/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter b/microprofile/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter index 5f5bb0e..c8d5bea 100644 --- a/microprofile/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter +++ b/microprofile/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter @@ -17,4 +17,4 @@ # under the License. # -org.apache.tamaya.microprofile.converter.ProviderConverter \ No newline at end of file +#org.apache.tamaya.microprofile.converter.ProviderConverter \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/CDIPlainInjectionTest.java ---------------------------------------------------------------------- diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/CDIPlainInjectionTest.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/CDIPlainInjectionTest.java index 61c67fb..137ada2 100644 --- a/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/CDIPlainInjectionTest.java +++ b/microprofile/src/test/java/org/apache/tamaya/microprofile/imported/CDIPlainInjectionTest.java @@ -23,8 +23,7 @@ import org.apache.openejb.jee.EjbJar; import org.apache.openejb.junit.ApplicationComposer; import org.apache.openejb.testing.Classes; import org.apache.openejb.testing.Module; -import org.apache.tamaya.microprofile.cdi.MicroprofileCDIExtension; -import org.apache.tamaya.microprofile.cdi.MicroprofileConfigurationProducer; +import org.apache.tamaya.microprofile.cdi.*; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.config.spi.ConfigSource; import org.junit.After; @@ -68,7 +67,9 @@ public class CDIPlainInjectionTest{ @Classes(cdi = true, value = { SimpleValuesBean.class, DynamicValuesBean.class, DefaultPropertyBean.class, MicroprofileCDIExtension.class, - MicroprofileConfigurationProducer.class + MicroprofileConfigurationProducer.class, + ConfiguredType.class, ConfiguredMethod.class, ConfiguredField.class, + BridgingConfigBean.class }) public EjbJar jar() { ensure_all_property_values_are_defined(); http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java ---------------------------------------------------------------------- diff --git a/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java index 1620535..059f715 100644 --- a/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java +++ b/microprofile/src/test/java/org/apache/tamaya/microprofile/tck/TamayaConfigArchiveProcessor.java @@ -21,7 +21,6 @@ package org.apache.tamaya.microprofile.tck; import org.apache.tamaya.microprofile.MicroprofileAdapter; import org.apache.tamaya.microprofile.MicroprofileConfigProviderResolver; import org.apache.tamaya.microprofile.cdi.MicroprofileCDIExtension; -import org.apache.tamaya.microprofile.converter.ProviderConverter; import org.apache.tamaya.spi.PropertyConverter; import org.eclipse.microprofile.config.spi.ConfigProviderResolver; import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; @@ -62,10 +61,10 @@ public class TamayaConfigArchiveProcessor implements ApplicationArchiveProcessor .create(JavaArchive.class, "tamaya-config-impl.jar") .addPackage(MicroprofileAdapter.class.getPackage()) .addPackage(MicroprofileCDIExtension.class.getPackage()) - .addPackage(ProviderConverter.class.getPackage()) +// .addPackage(ProviderConverter.class.getPackage()) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml") .addAsServiceProvider(ConfigProviderResolver.class, MicroprofileConfigProviderResolver.class) - .addAsServiceProvider(PropertyConverter.class, ProviderConverter.class) +// .addAsServiceProvider(PropertyConverter.class, ProviderConverter.class) .addAsServiceProvider(Extension.class, MicroprofileCDIExtension.class); ((WebArchive) applicationArchive).addAsLibraries( configJar) http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/029a43ca/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 0078166..f58043c 100644 --- a/pom.xml +++ b/pom.xml @@ -753,7 +753,7 @@ under the License. <!--<module>osgi</module>--> <module>management</module> <module>metamodel</module> - <module>microprofile</module> + <!--<module>microprofile</module>--> <module>uom</module> <module>vertx</module> </modules>