Readding Weld3 profile.
git-svn-id: https://svn.apache.org/repos/asf/geronimo/components/config/trunk@1804481 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/impl/pom.xml b/impl/pom.xml
index 5cc4ca7..6133927 100644
--- a/impl/pom.xml
+++ b/impl/pom.xml
@@ -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>
diff --git a/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java
index 4c2c540..04604ef 100644
--- a/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java
+++ b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigExtension.java
@@ -69,16 +69,18 @@
}
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) {
diff --git a/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java
index f3e2057..ec8fda8 100644
--- a/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java
+++ b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionBean.java
@@ -86,7 +86,7 @@
@Override
public Set<InjectionPoint> getInjectionPoints() {
- return Collections.EMPTY_SET;
+ return Collections.emptySet();
}
@Override
@@ -101,9 +101,7 @@
@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 @@
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 @@
@Override
public Set<Class<? extends Annotation>> getStereotypes() {
- return Collections.EMPTY_SET;
+ return Collections.emptySet();
}
@Override
diff --git a/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionPoint.java b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionPoint.java
new file mode 100644
index 0000000..6ba7415
--- /dev/null
+++ b/impl/src/main/java/org/apache/geronimo/config/cdi/ConfigInjectionPoint.java
@@ -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;
+ }
+}
diff --git a/impl/src/main/java/org/apache/geronimo/config/cdi/DefaultLiteral.java b/impl/src/main/java/org/apache/geronimo/config/cdi/DefaultLiteral.java
new file mode 100644
index 0000000..e16727e
--- /dev/null
+++ b/impl/src/main/java/org/apache/geronimo/config/cdi/DefaultLiteral.java
@@ -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();
+}
diff --git a/pom.xml b/pom.xml
index 154844d..1332903 100644
--- a/pom.xml
+++ b/pom.xml
@@ -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>