You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jo...@apache.org on 2017/08/09 01:58:41 UTC

svn commit: r1804481 - in /geronimo/components/config/trunk: ./ impl/ impl/src/main/java/org/apache/geronimo/config/cdi/

Author: johndament
Date: Wed Aug  9 01:58:41 2017
New Revision: 1804481

URL: http://svn.apache.org/viewvc?rev=1804481&view=rev
Log:
Readding Weld3 profile.

Added:
    geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionPoint.java
    geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/DefaultLiteral.java
Modified:
    geronimo/components/config/trunk/impl/pom.xml
    geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java
    geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java
    geronimo/components/config/trunk/pom.xml

Modified: geronimo/components/config/trunk/impl/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/components/config/trunk/impl/pom.xml?rev=1804481&r1=1804480&r2=1804481&view=diff
==============================================================================
--- geronimo/components/config/trunk/impl/pom.xml (original)
+++ geronimo/components/config/trunk/impl/pom.xml Wed Aug  9 01:58:41 2017
@@ -222,19 +222,19 @@
                 <dependency>
                     <groupId>org.jboss.weld.se</groupId>
                     <artifactId>weld-se-shaded</artifactId>
-                    <version>3.0.0.Final</version>
+                    <version>${weld.version}</version>
                     <scope>test</scope>
                 </dependency>
                 <dependency>
                     <groupId>org.jboss.arquillian.container</groupId>
                     <artifactId>arquillian-weld-embedded</artifactId>
-                    <version>2.0.0-SNAPSHOT</version>
+                    <version>${arquillian-weld-embedded.version}</version>
                     <scope>test</scope>
                 </dependency>
                 <dependency>
                     <groupId>javax.enterprise</groupId>
                     <artifactId>cdi-api</artifactId>
-                    <version>2.0</version>
+                    <version>${cdi2-api.version}</version>
                 </dependency>
             </dependencies>
         </profile>

Modified: geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java
URL: http://svn.apache.org/viewvc/geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java?rev=1804481&r1=1804480&r2=1804481&view=diff
==============================================================================
--- geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java (original)
+++ geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java Wed Aug  9 01:58:41 2017
@@ -69,16 +69,18 @@ public class ConfigExtension implements
     }
 
     public void registerConfigProducer(@Observes AfterBeanDiscovery abd, BeanManager bm) {
-        Set<Class> types = injectionPoints.stream()
+        Set<Type> types = injectionPoints.stream()
                 .filter(ip -> ip.getType() instanceof Class)
-                .map(ip -> (Class) REPLACED_TYPES.getOrDefault(ip.getType(), ip.getType()))
+                .map(ip -> REPLACED_TYPES.getOrDefault(ip.getType(), ip.getType()))
                 .collect(Collectors.toSet());
 
         // Provider and Optional are ParameterizedTypes and not a Class, so we need to add them manually
         types.add(Provider.class);
         types.add(Optional.class);
 
-        types.forEach(type -> abd.addBean(new ConfigInjectionBean(bm, type)));
+        types.stream()
+                .map(type -> new ConfigInjectionBean(bm, type))
+                .forEach(abd::addBean);
     }
 
     public void validate(@Observes AfterDeploymentValidation add) {

Modified: geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java
URL: http://svn.apache.org/viewvc/geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java?rev=1804481&r1=1804480&r2=1804481&view=diff
==============================================================================
--- geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java (original)
+++ geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java Wed Aug  9 01:58:41 2017
@@ -86,7 +86,7 @@ public class ConfigInjectionBean<T> impl
 
     @Override
     public Set<InjectionPoint> getInjectionPoints() {
-        return Collections.EMPTY_SET;
+        return Collections.emptySet();
     }
 
     @Override
@@ -101,9 +101,7 @@ public class ConfigInjectionBean<T> impl
 
     @Override
     public T create(CreationalContext<T> context) {
-        Set<Bean<?>> beans = bm.getBeans(InjectionPoint.class);
-        Bean<?> bean = bm.resolve(beans);
-        InjectionPoint ip = (InjectionPoint) bm.getReference(bean, InjectionPoint.class,  context);
+        InjectionPoint ip = (InjectionPoint)bm.getInjectableReference(new ConfigInjectionPoint(this),context);
         if (ip == null) {
             throw new IllegalStateException("Could not retrieve InjectionPoint");
         }
@@ -143,12 +141,11 @@ public class ConfigInjectionBean<T> impl
         throw new IllegalStateException("unhandled ConfigProperty");
     }
 
-
     /**
      * Get the property key to use.
      * In case the {@link ConfigProperty#name()} is empty we will try to determine the key name from the InjectionPoint.
      */
-    public static String getConfigKey(InjectionPoint ip, ConfigProperty configProperty) {
+    static String getConfigKey(InjectionPoint ip, ConfigProperty configProperty) {
         String key = configProperty.name();
         if (key.length() > 0) {
             return key;
@@ -208,7 +205,7 @@ public class ConfigInjectionBean<T> impl
 
     @Override
     public Set<Class<? extends Annotation>> getStereotypes() {
-        return Collections.EMPTY_SET;
+        return Collections.emptySet();
     }
 
     @Override

Added: geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionPoint.java
URL: http://svn.apache.org/viewvc/geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionPoint.java?rev=1804481&view=auto
==============================================================================
--- geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionPoint.java (added)
+++ geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionPoint.java Wed Aug  9 01:58:41 2017
@@ -0,0 +1,72 @@
+/*
+ *  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.geronimo.config.cdi;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.Set;
+
+class ConfigInjectionPoint implements InjectionPoint{
+    private final Bean bean;
+
+    ConfigInjectionPoint(Bean bean) {
+        this.bean = bean;
+    }
+
+    @Override
+    public boolean isTransient() {
+        return false;
+    }
+
+    @Override
+    public boolean isDelegate() {
+        return false;
+    }
+
+    @Override
+    public Type getType() {
+        return InjectionPoint.class;
+    }
+
+    @Override
+    public Set<Annotation> getQualifiers() {
+        return Collections.singleton(DefaultLiteral.INSTANCE);
+    }
+
+    @Override
+    public Member getMember() {
+        return null;
+    }
+
+    @Override
+    public Bean<?> getBean() {
+        return bean;
+    }
+
+    @Override
+    public Annotated getAnnotated() {
+        return null;
+    }
+}

Added: geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/DefaultLiteral.java
URL: http://svn.apache.org/viewvc/geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/DefaultLiteral.java?rev=1804481&view=auto
==============================================================================
--- geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/DefaultLiteral.java (added)
+++ geronimo/components/config/trunk/impl/src/main/java/org/apache/geronimo/config/cdi/DefaultLiteral.java Wed Aug  9 01:58:41 2017
@@ -0,0 +1,27 @@
+/*
+ *  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.geronimo.config.cdi;
+
+import javax.enterprise.inject.Default;
+import javax.enterprise.util.AnnotationLiteral;
+
+class DefaultLiteral extends AnnotationLiteral<Default> implements Default {
+    public static Default INSTANCE = new DefaultLiteral();
+}

Modified: geronimo/components/config/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/components/config/trunk/pom.xml?rev=1804481&r1=1804480&r2=1804481&view=diff
==============================================================================
--- geronimo/components/config/trunk/pom.xml (original)
+++ geronimo/components/config/trunk/pom.xml Wed Aug  9 01:58:41 2017
@@ -54,6 +54,9 @@
         <owb.version>1.7.3</owb.version>
         <owb2.version>2.0.1-SNAPSHOT</owb2.version>
         <arquillian.version>1.1.13.Final</arquillian.version>
+        <arquillian-weld-embedded.version>2.0.0.Beta5</arquillian-weld-embedded.version>
+        <cdi2-api.version>2.0</cdi2-api.version>
+        <weld.version>3.0.0.Final</weld.version>
     </properties>