You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2014/09/06 21:13:51 UTC
svn commit: r1622912 - in /openwebbeans/trunk:
webbeans-impl/src/main/java/org/apache/webbeans/container/
webbeans-impl/src/main/java/org/apache/webbeans/event/
webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/
webbeans-impl/src/main/java/or...
Author: struberg
Date: Sat Sep 6 19:13:51 2014
New Revision: 1622912
URL: http://svn.apache.org/r1622912
Log:
OWB-1001 implement ProcessInjectionPoint
applied patch from Reinhard Sandtner
plus fixed a few minor things with him together in a hangout session.
Added:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java (with props)
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessInjectionPoint.java (with props)
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
openwebbeans/trunk/webbeans-tck/testng-dev.xml
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java?rev=1622912&r1=1622911&r2=1622912&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java Sat Sep 6 19:13:51 2014
@@ -768,7 +768,7 @@ public class BeanManagerImpl implements
public InjectionPoint createInjectionPoint(AnnotatedField<?> field)
{
- return webBeansContext.getInjectionPointFactory().buildInjectionPoint(null, field);
+ return webBeansContext.getInjectionPointFactory().buildInjectionPoint(null, field, false);
}
public InjectionPoint createInjectionPoint(AnnotatedParameter<?> parameter)
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1622912&r1=1622911&r2=1622912&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java Sat Sep 6 19:13:51 2014
@@ -318,7 +318,7 @@ public final class NotificationManager
if(ClassUtil.isParametrizedType(type))
{
- addToMathingWithParametrizedForBeans(type,beanClass,matching);
+ addToMatchingWithParametrizedForBeans(type, beanClass, matching);
}
else
{
@@ -354,7 +354,7 @@ public final class NotificationManager
{
if(ClassUtil.isParametrizedType(type))
{
- addToMathingWithParametrizedForBeans(type,beanClass,matching);
+ addToMatchingWithParametrizedForBeans(type, beanClass, matching);
}
else
{
@@ -431,7 +431,7 @@ public final class NotificationManager
}
}
- private <T> void addToMathingWithParametrizedForBeans(Type type, Class<?> beanClass, Set<ObserverMethod<? super T>> matching )
+ private <T> void addToMatchingWithParametrizedForBeans(Type type, Class<?> beanClass, Set<ObserverMethod<? super T>> matching)
{
ParameterizedType pt = (ParameterizedType)type;
Type[] actualArgs = pt.getActualTypeArguments();
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java?rev=1622912&r1=1622911&r2=1622912&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/inject/impl/InjectionPointFactory.java Sat Sep 6 19:13:51 2014
@@ -18,16 +18,12 @@
*/
package org.apache.webbeans.inject.impl;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.TypeVariable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import org.apache.webbeans.annotation.AnnotationManager;
+import org.apache.webbeans.annotation.NamedLiteral;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.util.AnnotationUtil;
+import org.apache.webbeans.util.Asserts;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Disposes;
@@ -42,13 +38,16 @@ import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.InjectionPoint;
import javax.inject.Inject;
import javax.inject.Named;
-
-import org.apache.webbeans.annotation.AnnotationManager;
-import org.apache.webbeans.annotation.NamedLiteral;
-import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.exception.WebBeansConfigurationException;
-import org.apache.webbeans.util.AnnotationUtil;
-import org.apache.webbeans.util.Asserts;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.TypeVariable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
public class InjectionPointFactory
{
@@ -103,7 +102,7 @@ public class InjectionPointFactory
return injectionPoints;
}
- public <X> InjectionPoint buildInjectionPoint(Bean<?> owner, AnnotatedField<X> annotField)
+ public <X> InjectionPoint buildInjectionPoint(Bean<?> owner, AnnotatedField<X> annotField, boolean fireEvent)
{
Asserts.assertNotNull(annotField, "annotField parameter can not be null");
@@ -111,12 +110,12 @@ public class InjectionPointFactory
Annotation[] qualifierAnnots = webBeansContext.getAnnotationManager().getQualifierAnnotations(annots);
//@Named update for injection fields!
- for (int i=0; i < qualifierAnnots.length; i++)
+ for (int i = 0; i < qualifierAnnots.length; i++)
{
Annotation qualifier = qualifierAnnots[i];
if (qualifier.annotationType().equals(Named.class))
{
- Named named = (Named)qualifier;
+ Named named = (Named) qualifier;
String value = named.value();
if (value == null || value.equals(""))
@@ -130,7 +129,20 @@ public class InjectionPointFactory
}
}
- return new InjectionPointImpl(owner, Arrays.asList(qualifierAnnots), annotField);
+ InjectionPoint injectionPoint = new InjectionPointImpl(owner, Arrays.asList(qualifierAnnots), annotField);
+
+ if (fireEvent)
+ {
+ injectionPoint = webBeansContext.getWebBeansUtil().fireProcessInjectionPointEvent(injectionPoint).getInjectionPoint();
+ }
+
+ return injectionPoint;
+
+ }
+
+ public <X> InjectionPoint buildInjectionPoint(Bean<?> owner, AnnotatedField<X> annotField)
+ {
+ return buildInjectionPoint(owner, annotField, true);
}
public <X> InjectionPoint buildInjectionPoint(Bean<?> owner, AnnotatedParameter<X> parameter)
Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java?rev=1622912&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java Sat Sep 6 19:13:51 2014
@@ -0,0 +1,71 @@
+/*
+ * 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.webbeans.portable.events;
+
+import org.apache.webbeans.config.WebBeansContext;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.ProcessInjectionPoint;
+
+/**
+ * Fired for every {@link InjectionPoint} of every Java EE component class supporting injection,
+ * including every {@link javax.annotation.ManagedBean}, EJB session or message-driven bean, bean, interceptor or decorator.
+ *
+ * @param <T> bean class
+ * @param <X> declared type
+ */
+public class ProcessInjectionPointImpl<T, X> implements ProcessInjectionPoint<T, X>
+{
+
+ private InjectionPoint injectionPoint;
+
+
+ public ProcessInjectionPointImpl(InjectionPoint injectionPoint)
+ {
+ this.injectionPoint = injectionPoint;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public InjectionPoint getInjectionPoint()
+ {
+ return injectionPoint;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setInjectionPoint(InjectionPoint injectionPoint)
+ {
+ this.injectionPoint = injectionPoint;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void addDefinitionError(Throwable t)
+ {
+ WebBeansContext.getInstance().getBeanManagerImpl().getErrorStack().pushError(t);
+ }
+}
Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ProcessInjectionPointImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessInjectionPoint.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessInjectionPoint.java?rev=1622912&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessInjectionPoint.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessInjectionPoint.java Sat Sep 6 19:13:51 2014
@@ -0,0 +1,52 @@
+/*
+ * 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.webbeans.portable.events.generics;
+
+import org.apache.webbeans.portable.events.ProcessInjectionPointImpl;
+
+import javax.enterprise.inject.spi.AnnotatedMember;
+import javax.enterprise.inject.spi.InjectionPoint;
+
+
+public class GProcessInjectionPoint extends ProcessInjectionPointImpl implements GenericBeanEvent
+{
+
+ public GProcessInjectionPoint(InjectionPoint injectionPoint)
+ {
+ super(injectionPoint);
+ }
+
+ @Override
+ public Class<?> getBeanClassFor(Class<?> eventClass)
+ {
+ if (getInjectionPoint() != null)
+ {
+ if (getInjectionPoint().getBean() != null)
+ {
+ return getInjectionPoint().getBean().getBeanClass();
+ }
+ else if (getInjectionPoint().getAnnotated() != null && getInjectionPoint().getAnnotated() instanceof AnnotatedMember)
+ {
+ return ((AnnotatedMember) getInjectionPoint().getAnnotated()).getDeclaringType().getJavaClass();
+ }
+ }
+
+ return null;
+ }
+}
Propchange: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessInjectionPoint.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java?rev=1622912&r1=1622911&r2=1622912&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java Sat Sep 6 19:13:51 2014
@@ -69,6 +69,7 @@ import org.apache.webbeans.portable.even
import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
import org.apache.webbeans.portable.events.generics.GProcessBean;
import org.apache.webbeans.portable.events.generics.GProcessBeanAttributes;
+import org.apache.webbeans.portable.events.generics.GProcessInjectionPoint;
import org.apache.webbeans.portable.events.generics.GProcessInjectionTarget;
import org.apache.webbeans.portable.events.generics.GProcessManagedBean;
import org.apache.webbeans.portable.events.generics.GProcessObservableMethod;
@@ -1031,6 +1032,17 @@ public final class WebBeansUtil
}
/**
+ * @param injectionPoint the original {@link InjectionPoint}
+ * @return fired {@link ProcessInjectionPoint} event
+ */
+ public GProcessInjectionPoint fireProcessInjectionPointEvent(InjectionPoint injectionPoint)
+ {
+ GProcessInjectionPoint event = new GProcessInjectionPoint(injectionPoint);
+ webBeansContext.getBeanManagerImpl().fireEvent(event, true, AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
+ return event;
+ }
+
+ /**
* Returns <code>ProcessInjectionTarget</code> event.
* @param <T> bean type
* @return event
@@ -1246,29 +1258,11 @@ public final class WebBeansUtil
}
}
- public static boolean isExtensionEventType(Type type)
- {
- return type.equals(BeforeBeanDiscovery.class) ||
- type.equals(AfterBeanDiscovery.class) ||
- type.equals(AfterDeploymentValidation.class) ||
- type.equals(BeforeShutdown.class) ||
- type.equals(GProcessAnnotatedType.class) ||
- type.equals(GProcessSyntheticAnnotatedType.class) ||
- type.equals(GProcessInjectionTarget.class) ||
- type.equals(GProcessBeanAttributes.class) ||
- type.equals(GProcessProducer.class) ||
- type.equals(GProcessProducerField.class) ||
- type.equals(GProcessProducerMethod.class) ||
- type.equals(GProcessManagedBean.class) ||
- type.equals(GProcessBean.class) ||
- type.equals(GProcessSessionBean.class) ||
- type.equals(GProcessObservableMethod.class);
- }
-
public static boolean isExtensionBeanEventType(Type type)
{
return type.equals(GProcessAnnotatedType.class) ||
type.equals(GProcessSyntheticAnnotatedType.class) ||
+ type.equals(GProcessInjectionPoint.class) ||
type.equals(GProcessInjectionTarget.class) ||
type.equals(GProcessBeanAttributes.class) ||
type.equals(GProcessManagedBean.class) ||
@@ -1280,6 +1274,7 @@ public final class WebBeansUtil
{
return clazz.equals(ProcessAnnotatedType.class) ||
clazz.equals(ProcessSyntheticAnnotatedType.class) ||
+ clazz.equals(ProcessInjectionPoint.class) ||
clazz.equals(ProcessInjectionTarget.class) ||
clazz.equals(ProcessBeanAttributes.class) ||
clazz.equals(ProcessManagedBean.class) ||
Modified: openwebbeans/trunk/webbeans-tck/testng-dev.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-tck/testng-dev.xml?rev=1622912&r1=1622911&r2=1622912&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-tck/testng-dev.xml (original)
+++ openwebbeans/trunk/webbeans-tck/testng-dev.xml Sat Sep 6 19:13:51 2014
@@ -18,7 +18,7 @@
<suite name="JSR-346-TCK" verbose="2" configfailurepolicy="continue">
<test name="JSR-346 TCK">
<classes>
- <class name="org.jboss.cdi.tck.tests.decorators.interceptor.DecoratorAndInterceptorTest" />
+ <class name="org.jboss.cdi.tck.tests.extensions.beanManager.bootstrap.unavailable.methods.UnavailableMethodsDuringApplicationInitializationTest" />
<!--
<class name="org.jboss.cdi.tck.tests.event.parameterized.ParameterizedEventTest" />
<class name="org.jboss.cdi.tck.tests.event.fires.FireEventTest" />