Author: struberg
Date: Tue Jul 19 15:10:35 2011
New Revision: 1148387
URL: http://svn.apache.org/viewvc?rev=1148387&view=rev
Log:
OWB-593 also use InterceptorBindings which got added in BeforeBeanDiscovery
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/InterceptorExtension.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleBinding.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTest.java
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java?rev=1148387&r1=1148386&r2=1148387&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java
Tue Jul 19 15:10:35 2011
@@ -74,22 +74,26 @@ public final class AnnotationManager
beanManagerImpl = context.getBeanManagerImpl();
}
-
/**
* Returns true if the annotation is defined in xml or annotated with
- * {@link javax.interceptor.InterceptorBinding} false otherwise.
+ * {@link javax.interceptor.InterceptorBinding} or an InterceptorBinding
+ * registered via {@link javax.enterprise.inject.spi.BeforeBeanDiscovery}.
+ * False otherwise.
*
* @param clazz type of the annotation
* @return true if the annotation is defined in xml or annotated with
- * {@link javax.interceptor.InterceptorBinding} false otherwise
+ * {@link javax.interceptor.InterceptorBinding}, false otherwise
*/
public boolean isInterceptorBindingAnnotation(Class<? extends Annotation>
clazz)
{
Asserts.nullCheckForClass(clazz);
- return clazz.isAnnotationPresent(InterceptorBinding.class);
+ return clazz.isAnnotationPresent(InterceptorBinding.class)
+ || beanManagerImpl.hasInterceptorBindingType(clazz);
}
+
+
/**
* If any Annotations in the input is an interceptor binding annotation
type then return
* true, false otherwise.
@@ -573,8 +577,7 @@ public final class AnnotationManager
Annotation old = null;
for (Annotation interceptorBinding : interceptorBindings)
{
- if (!this.isInterceptorBindingAnnotation(
- interceptorBinding.annotationType()))
+ if
(!this.isInterceptorBindingAnnotation(interceptorBinding.annotationType()))
{
throw new
IllegalArgumentException("Manager.resolveInterceptors() method parameter
interceptor" +
" bindings array can not contain other annotation that
is not @InterceptorBinding");
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=1148387&r1=1148386&r2=1148387&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
Tue Jul 19 15:10:35 2011
@@ -943,20 +943,6 @@ public final class AnnotationUtil
}
/**
- * If any Annotations in the input is an interceptor binding annotation
type then return
- * true, false otherwise.
- *
- * @param anns array of Annotations to check
- * @return true if one or moe of the input annotations are an interceptor
binding annotation
- * type false otherwise
- */
- @Deprecated
- public static boolean hasInterceptorBindingMetaAnnotation(Annotation[]
anns)
- {
- return
WebBeansContext.getInstance().getAnnotationManager().hasInterceptorBindingMetaAnnotation(anns);
- }
-
- /**
* Collect the interceptor bindings from an array of annotations, including
* transitively defined interceptor bindings.
* @param anns An array of annotations
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java?rev=1148387&r1=1148386&r2=1148387&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/xml/WebBeansXMLConfigurator.java
Tue Jul 19 15:10:35 2011
@@ -243,7 +243,8 @@ public final class WebBeansXMLConfigurat
*/
private void configureInterceptorsElement(Element interceptorsElement,
String fileName,ScannerService scanner)
{
- InterceptorsManager manager =
WebBeansContext.getInstance().getInterceptorsManager();
+ WebBeansContext webBeansContext = WebBeansContext.getInstance();
+ InterceptorsManager manager = webBeansContext.getInterceptorsManager();
Node node;
Element child;
NodeList ns = interceptorsElement.getChildNodes();
@@ -267,12 +268,14 @@ public final class WebBeansXMLConfigurat
else
{
if
(AnnotationUtil.hasAnnotation(clazz.getDeclaredAnnotations(),
Interceptor.class) &&
-
!AnnotationUtil.hasInterceptorBindingMetaAnnotation(clazz.getDeclaredAnnotations()))
+ !webBeansContext.getAnnotationManager().
+
hasInterceptorBindingMetaAnnotation(clazz.getDeclaredAnnotations()))
{
throw new
WebBeansConfigurationException(createConfigurationFailedMessage() +
"Interceptor class : " +
child.getTextContent().trim() +
- " must have at
least one @InterceptorBindingType");
+ " must have at
least one @InterceptorBinding");
}
+
boolean isBDAScanningEnabled=(scanner!=null &&
scanner.isBDABeansXmlScanningEnabled());
if ((!isBDAScanningEnabled &&
manager.isInterceptorEnabled(clazz)) ||
(isBDAScanningEnabled &&
!scanner.getBDABeansXmlScanner().addInterceptor(clazz, fileName)))
Modified:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/InterceptorExtension.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/InterceptorExtension.java?rev=1148387&r1=1148386&r2=1148387&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/InterceptorExtension.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/InterceptorExtension.java
Tue Jul 19 15:10:35 2011
@@ -19,12 +19,22 @@
package org.apache.webbeans.newtests.interceptors.lifecycle;
import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import javax.enterprise.util.AnnotationLiteral;
public class InterceptorExtension implements Extension
{
+ /**
+ * we add the InterceptorBinding via Extension to test OWB-593
+ * @param event
+ */
+ public void registerInterceptorBinding(@Observes BeforeBeanDiscovery event)
+ {
+ event.addInterceptorBinding(LifecycleBinding.class);
+ }
+
@SuppressWarnings("serial")
public void observe(@Observes ProcessAnnotatedType<NotAnnotatedBean>
process)
{
Modified:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleBinding.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleBinding.java?rev=1148387&r1=1148386&r2=1148387&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleBinding.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleBinding.java
Tue Jul 19 15:10:35 2011
@@ -23,9 +23,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import javax.interceptor.InterceptorBinding;
-@InterceptorBinding
+// we add the @InterceptorBinding via Extension to test for OWB-593
@Retention(RetentionPolicy.RUNTIME)
@Target( { ElementType.TYPE})
public @interface LifecycleBinding
Modified:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTest.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTest.java?rev=1148387&r1=1148386&r2=1148387&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTest.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTest.java
Tue Jul 19 15:10:35 2011
@@ -49,7 +49,9 @@ public class LifecycleTest extends Abstr
Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
beanClasses.add(LifecycleInterceptor.class);
beanClasses.add(LifecycleBean.class);
-
+
+ addExtension(new InterceptorExtension());
+
startContainer(beanClasses, beanXmls);
Set<Bean<?>> beans =
getBeanManager().getBeans("org.apache.webbeans.newtests.interceptors.lifecycle.LifecycleBean");