Author: struberg
Date: Thu Jul 21 18:07:24 2011
New Revision: 1149288

URL: http://svn.apache.org/viewvc?rev=1149288&view=rev
Log:
OWB-593 fix lots of AnnotatedType issues with Interceptors 

Added:
    
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorBbd.java
   (contents, props changed)
      - copied, changed from r1148655, 
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptor.java
    
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorPat.java
    
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestBbd.xml
   (contents, props changed)
      - copied, changed from r1148655, 
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTest.xml
    
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestPat.xml
Modified:
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/container/BeanManagerImpl.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
    
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.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/LifecycleTest.java

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=1149288&r1=1149287&r2=1149288&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
 Thu Jul 21 18:07:24 2011
@@ -1190,9 +1190,10 @@ public class BeanManagerImpl implements 
             additionalQualifiers.add(qualifier);
         }
     }
-    
+
     public void addAdditionalAnnotatedType(AnnotatedType<?> annotatedType)
     {
+        
webBeansContext.getAnnotatedElementFactory().setAnnotatedType(annotatedType);
         this.additionalAnnotatedTypes.add(annotatedType);
     }
 
@@ -1214,7 +1215,7 @@ public class BeanManagerImpl implements 
     {
         return additionalScopes;
     }
-    
+
     public List<AnnotatedType<?>> getAdditionalAnnotatedTypes()
     {
         return additionalAnnotatedTypes;

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java?rev=1149288&r1=1149287&r2=1149288&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorUtil.java
 Thu Jul 21 18:07:24 2011
@@ -333,31 +333,40 @@ public final class InterceptorUtil
     }
 
 
-    public void checkInterceptorConditions(Class<?> clazz)
+    public void checkInterceptorConditions(AnnotatedType annotatedType)
     {
-        Asserts.nullCheckForClass(clazz);
+        Asserts.assertNotNull(annotatedType);
 
-        Method[] methods = 
webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(clazz);
-        for(Method method : methods)
+        Set<AnnotatedMethod> methods = annotatedType.getMethods();
+        for(AnnotatedMethod method : methods)
         {
-            if(AnnotationUtil.hasMethodAnnotation(method, Produces.class))
+            List<AnnotatedParameter> parms = method.getParameters();
+            for (AnnotatedParameter parameter : parms)
             {
-                throw new WebBeansConfigurationException("Interceptor class : 
" + clazz + " can not have producer methods but it has one with name : "
-                                                         + method.getName());
+                if (parameter.isAnnotationPresent(Produces.class))
+                {
+                    throw new WebBeansConfigurationException("Interceptor 
class : " + annotatedType.getJavaClass()
+                            + " can not have producer methods but it has one 
with name : "
+                            + method.getJavaMember().getName());
+                }
             }
         }
 
-        if 
(!webBeansContext.getAnnotationManager().hasInterceptorBindingMetaAnnotation(
-            clazz.getDeclaredAnnotations()))
+
+        Annotation[] anns = annotatedType.getAnnotations().toArray(new 
Annotation[annotatedType.getAnnotations().size()]);
+        if 
(!webBeansContext.getAnnotationManager().hasInterceptorBindingMetaAnnotation(anns))
         {
-            throw new WebBeansConfigurationException("WebBeans Interceptor 
class : " + clazz.getName()
+            throw new WebBeansConfigurationException("WebBeans Interceptor 
class : " + annotatedType.getJavaClass()
                                                      + " must have at least 
one @InterceptorBinding annotation");
         }
 
-        checkLifecycleConditions(clazz, clazz.getDeclaredAnnotations(), 
"Lifecycle interceptor : " + clazz.getName()
-                                                                        + " 
interceptor binding type must be defined as @Target{TYPE}");
+        checkLifecycleConditions(annotatedType.getJavaClass(), anns, 
"Lifecycle interceptor : " + annotatedType.getJavaClass()
+                                              + " interceptor binding type 
must be defined as @Target{TYPE}");
     }
 
+    /**
+     * @param clazz AUTSCH! we should use the AnnotatedType for all that stuff!
+     */
     public <T> void checkLifecycleConditions(Class<T> clazz, Annotation[] 
annots, String errorMessage)
     {
         Asserts.nullCheckForClass(clazz);

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java?rev=1149288&r1=1149287&r2=1149288&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/intercept/InterceptorsManager.java
 Thu Jul 21 18:07:24 2011
@@ -21,6 +21,7 @@ package org.apache.webbeans.intercept;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.interceptor.Interceptor;
 
 import org.apache.webbeans.config.WebBeansContext;
@@ -31,12 +32,14 @@ import org.apache.webbeans.util.Asserts;
 public class InterceptorsManager
 {
     private List<Class<?>> enabledInterceptors = new 
CopyOnWriteArrayList<Class<?>>();
+    private final WebBeansContext webBeansContext;
+
     private final BeanManagerImpl manager;
 
     public InterceptorsManager(WebBeansContext webBeansContext)
     {
-
-        manager = webBeansContext.getBeanManagerImpl();
+        this.webBeansContext = webBeansContext;
+        this.manager = webBeansContext.getBeanManagerImpl();
     }
 
     @Deprecated
@@ -92,12 +95,14 @@ public class InterceptorsManager
     
     public void validateInterceptorClasses()
     {
-        for(Class<?> decoratorClazz : enabledInterceptors)
+        for(Class<?> interceptorClass : enabledInterceptors)
         {
+            AnnotatedType<?> annotatedType = 
webBeansContext.getAnnotatedElementFactory().getAnnotatedType(interceptorClass);
+
             //Validate decorator classes
-            if(!decoratorClazz.isAnnotationPresent(Interceptor.class) && 
!manager.containsCustomInterceptorClass(decoratorClazz))
+            if(!annotatedType.isAnnotationPresent(Interceptor.class) && 
!manager.containsCustomInterceptorClass(interceptorClass))
             {
-                throw new WebBeansConfigurationException("Given class : " + 
decoratorClazz + " is not a interceptor class");
+                throw new WebBeansConfigurationException("Given class : " + 
interceptorClass + " is not a interceptor class");
             }   
         }                
     }    

Modified: 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java?rev=1149288&r1=1149287&r2=1149288&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedElementFactory.java
 Thu Jul 21 18:07:24 2011
@@ -78,6 +78,33 @@ public final class AnnotatedElementFacto
     }
 
     /**
+     * Get an already registered AnnotatedType. This will NOT create a new one!
+     * @param annotatedClass
+     * @param <X>
+     * @return AnnotatedType
+     */
+    public <X> AnnotatedType<X> getAnnotatedType(Class<X> annotatedClass)
+    {
+        return (AnnotatedType<X>) annotatedTypeCache.get(annotatedClass);
+    }
+
+    /**
+     * This method will get used to manually add AnnoatedTypes to our storage.
+     * Those AnnotatedTypes are coming from Extensions and get registered e.g. 
via
+     * {@link 
javax.enterprise.inject.spi.BeforeBeanDiscovery#addAnnotatedType(AnnotatedType)}
+     *
+     * Sets the annotatedType and replace the given one.
+     * @param annotatedType
+     * @param <X>
+     * @return the previously registered AnnotatedType or null if not 
previously defined.
+     */
+    public <X> AnnotatedType<X> setAnnotatedType(AnnotatedType<X> 
annotatedType)
+    {
+        return (AnnotatedType<X>) 
annotatedTypeCache.put(annotatedType.getJavaClass(), annotatedType);
+    }
+
+
+    /**
      * Creates and configures new annotated type.
      * 
      * @param <X> class info
@@ -88,10 +115,10 @@ public final class AnnotatedElementFacto
     public <X> AnnotatedType<X> newAnnotatedType(Class<X> annotatedClass)
     {
         Asserts.assertNotNull(annotatedClass, "annotatedClass is null");
-        AnnotatedTypeImpl<X> annotatedType;
+        AnnotatedType<X> annotatedType;
         if(annotatedTypeCache.containsKey(annotatedClass))
         {
-            annotatedType = 
(AnnotatedTypeImpl<X>)annotatedTypeCache.get(annotatedClass);
+            annotatedType = 
(AnnotatedType<X>)annotatedTypeCache.get(annotatedClass);
         }
         else
         {
@@ -99,7 +126,7 @@ public final class AnnotatedElementFacto
             {
                 annotatedType = new AnnotatedTypeImpl<X>(webBeansContext, 
annotatedClass);
 
-                AnnotatedTypeImpl<X> oldType = 
(AnnotatedTypeImpl<X>)annotatedTypeCache.putIfAbsent(annotatedClass, 
annotatedType);
+                AnnotatedType<X> oldType = 
(AnnotatedType<X>)annotatedTypeCache.putIfAbsent(annotatedClass, annotatedType);
                 if(oldType != null)
                 {
                     annotatedType = oldType;

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=1149288&r1=1149287&r2=1149288&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
 Thu Jul 21 18:07:24 2011
@@ -1986,18 +1986,20 @@ public final class WebBeansUtil
     public <T> void defineInterceptor(ManagedBeanCreatorImpl<T> 
managedBeanCreator, ProcessInjectionTarget<T> injectionTargetEvent)
     {
         Class<?> clazz = 
injectionTargetEvent.getAnnotatedType().getJavaClass();
+        AnnotatedType annotatedType = injectionTargetEvent.getAnnotatedType();
+
         if 
(webBeansContext.getInterceptorsManager().isInterceptorEnabled(clazz))
         {
             ManagedBean<T> component;
 
-            
webBeansContext.getInterceptorUtil().checkInterceptorConditions(clazz);
+            
webBeansContext.getInterceptorUtil().checkInterceptorConditions(annotatedType);
             component = defineManagedBean(managedBeanCreator, 
injectionTargetEvent, false);
 
             if (component != null)
             {
+                Annotation[] anns = annotatedType.getAnnotations().toArray(new 
Annotation[annotatedType.getAnnotations().size()]);
                 
webBeansContext.getWebBeansInterceptorConfig().configureInterceptorClass(component,
-                        
webBeansContext.getAnnotationManager().getInterceptorBindingMetaAnnotations(
-                                clazz.getDeclaredAnnotations()));
+                        
webBeansContext.getAnnotationManager().getInterceptorBindingMetaAnnotations(anns));
             }
             else
             {
@@ -2184,6 +2186,11 @@ public final class WebBeansUtil
         //Fires ProcessAnnotatedType
         
webBeansContext.getBeanManagerImpl().fireEvent(processAnnotatedEvent,AnnotationUtil.EMPTY_ANNOTATION_ARRAY);
 
+        if (processAnnotatedEvent.isModifiedAnnotatedType())
+        {
+            
webBeansContext.getAnnotatedElementFactory().setAnnotatedType(processAnnotatedEvent.getAnnotatedType());
+        }
+
         return processAnnotatedEvent;
     }
 

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=1149288&r1=1149287&r2=1149288&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
 Thu Jul 21 18:07:24 2011
@@ -20,7 +20,10 @@ package org.apache.webbeans.xml;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.util.Set;
 
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.interceptor.Interceptor;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -33,6 +36,7 @@ import org.apache.webbeans.exception.Web
 import org.apache.webbeans.inject.AlternativesManager;
 import org.apache.webbeans.intercept.InterceptorsManager;
 import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.portable.events.ProcessAnnotatedTypeImpl;
 import org.apache.webbeans.spi.ScannerService;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
@@ -267,13 +271,37 @@ public final class WebBeansXMLConfigurat
             }
             else
             {
-                if 
(AnnotationUtil.hasAnnotation(clazz.getDeclaredAnnotations(), 
Interceptor.class) &&
+                Annotation[] classAnnotations;
+                AnnotatedType<?> annotatedType = 
webBeansContext.getAnnotatedElementFactory().newAnnotatedType(clazz);
+
+                ProcessAnnotatedTypeImpl<?> processAnnotatedEvent =
+                    
webBeansContext.getWebBeansUtil().fireProcessAnnotatedTypeEvent(annotatedType);
+
+                // if veto() is called
+                if (processAnnotatedEvent.isVeto())
+                {
+                    return;
+                }
+
+                annotatedType = processAnnotatedEvent.getAnnotatedType();
+
+                Set<Annotation> annTypeAnnotations = 
annotatedType.getAnnotations();
+                if (annTypeAnnotations != null)
+                {
+                    classAnnotations = annTypeAnnotations.toArray(new 
Annotation[annTypeAnnotations.size()]);
+                }
+                else
+                {
+                    classAnnotations = new Annotation[0];
+                }
+
+                if (AnnotationUtil.hasAnnotation(classAnnotations, 
Interceptor.class) &&
                     !webBeansContext.getAnnotationManager().
-                            
hasInterceptorBindingMetaAnnotation(clazz.getDeclaredAnnotations()))
+                            
hasInterceptorBindingMetaAnnotation(classAnnotations))
                 {
-                    throw new 
WebBeansConfigurationException(createConfigurationFailedMessage() + 
"Interceptor class : " +
-                                                             
child.getTextContent().trim() +
-                                                             " must have at 
least one @InterceptorBinding");
+                    throw new 
WebBeansConfigurationException(createConfigurationFailedMessage() + 
"Interceptor class : "
+                                                             + 
child.getTextContent().trim()
+                                                             + " must have at 
least one @InterceptorBinding");
                 }
 
                 boolean isBDAScanningEnabled=(scanner!=null && 
scanner.isBDABeansXmlScanningEnabled());

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=1149288&r1=1149287&r2=1149288&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
 Thu Jul 21 18:07:24 2011
@@ -19,10 +19,17 @@
 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.inject.spi.*;
 import javax.enterprise.util.AnnotationLiteral;
+import javax.interceptor.Interceptor;
+
+import org.apache.webbeans.config.WebBeansContext;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
 
 public class InterceptorExtension implements Extension
 {
@@ -35,11 +42,140 @@ public class InterceptorExtension implem
         event.addInterceptorBinding(LifecycleBinding.class);
     }
 
-    @SuppressWarnings("serial")
-    public void observe(@Observes ProcessAnnotatedType<NotAnnotatedBean> 
process)
+    public void observeNotAnnotatedBean(@Observes 
ProcessAnnotatedType<NotAnnotatedBean> process)
     {
         process.getAnnotatedType().getAnnotations().add(new 
AnnotationLiteral<LifecycleBinding>(){});
         process.setAnnotatedType(process.getAnnotatedType());
     }
 
+    public void observeLifecycleInterceptorPat(@Observes 
ProcessAnnotatedType<LifecycleInterceptorPat> process)
+    {
+        process.getAnnotatedType().getAnnotations().add(new 
AnnotationLiteral<LifecycleBinding>(){});
+        process.getAnnotatedType().getAnnotations().add(new 
AnnotationLiteral<Interceptor>(){});
+        process.setAnnotatedType(process.getAnnotatedType());
+    }
+
+    // manually add the correct LifecycleInterceptorBbd
+    public void observeLiveCycleInterceptorBbd(@Observes BeforeBeanDiscovery 
bbd)
+    {
+        WebBeansContext webBeansContext = WebBeansContext.getInstance();
+        AnnotatedTypeImpl<LifecycleInterceptorBbd> annotatedType =
+                new 
AnnotatedTypeImpl<LifecycleInterceptorBbd>(LifecycleInterceptorBbd.class );
+
+        Set<Annotation> anns = new HashSet<Annotation>();
+        anns.add(new AnnotationLiteral<LifecycleBinding>(){});
+        anns.add(new AnnotationLiteral<Interceptor>(){});
+        annotatedType.setAnnotations(anns);
+
+        bbd.addAnnotatedType(annotatedType);
+    }
+
+    public static class AnnotatedTypeImpl<X> implements AnnotatedType<X>
+    {
+        private Class<X> javaClass;
+        private Set<AnnotatedConstructor<X>>    annotatedConstructors = 
Collections.EMPTY_SET;
+        private Set<AnnotatedMethod<? super X>> annotatedMethods = 
Collections.EMPTY_SET;
+        private Set<AnnotatedField<? super X>>  annotatedFields = 
Collections.EMPTY_SET;
+        private Set<Type>                       typeClosures  = 
Collections.EMPTY_SET;
+        private Set<Annotation>                 annotations   = 
Collections.EMPTY_SET;
+
+
+        public AnnotatedTypeImpl(Class<X> javaClass)
+        {
+            this.javaClass = javaClass;
+        }
+
+        @Override
+        public Set<AnnotatedConstructor<X>> getConstructors()
+        {
+            return annotatedConstructors;
+        }
+
+        @Override
+        public Class<X> getJavaClass()
+        {
+            return javaClass;
+        }
+
+        @Override
+        public Set<AnnotatedMethod<? super X>> getMethods()
+        {
+            return annotatedMethods;
+        }
+
+        @Override
+        public Set<AnnotatedField<? super X>> getFields()
+        {
+            return annotatedFields;
+        }
+
+        @Override
+        public Type getBaseType()
+        {
+            return javaClass;
+        }
+
+        @Override
+        public Set<Type> getTypeClosure()
+        {
+            return typeClosures;
+        }
+
+        @Override
+        public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+        {
+            for (Annotation a: annotations)
+            {
+                if (a.annotationType().equals(annotationType))
+                {
+                    return (T) a;
+                }
+            }
+
+            return null;
+        }
+
+        @Override
+        public Set<Annotation> getAnnotations()
+        {
+            return annotations;
+        }
+
+        @Override
+        public boolean isAnnotationPresent(Class<? extends Annotation> 
annotationType)
+        {
+            return getAnnotation(annotationType) != null;
+        }
+
+        public void setAnnotatedConstructors(Set<AnnotatedConstructor<X>> 
annotatedConstructors)
+        {
+            this.annotatedConstructors = annotatedConstructors;
+        }
+
+        public void setAnnotatedFields(Set<AnnotatedField<? super X>> 
annotatedFields)
+        {
+            this.annotatedFields = annotatedFields;
+        }
+
+        public void setAnnotatedMethods(Set<AnnotatedMethod<? super X>> 
annotatedMethods)
+        {
+            this.annotatedMethods = annotatedMethods;
+        }
+
+        public void setAnnotations(Set<Annotation> annotations)
+        {
+            this.annotations = annotations;
+        }
+
+        public void setJavaClass(Class<X> javaClass)
+        {
+            this.javaClass = javaClass;
+        }
+
+        public void setTypeClosures(Set<Type> typeClosures)
+        {
+            this.typeClosures = typeClosures;
+        }
+    }
+
 }

Copied: 
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorBbd.java
 (from r1148655, 
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptor.java)
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorBbd.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorBbd.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptor.java&r1=1148655&r2=1149288&rev=1149288&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptor.java
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorBbd.java
 Thu Jul 21 18:07:24 2011
@@ -18,16 +18,18 @@
  */
 package org.apache.webbeans.newtests.interceptors.lifecycle;
 
-import java.io.Serializable;
-
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.interceptor.Interceptor;
 import javax.interceptor.InvocationContext;
+import java.io.Serializable;
 
-@LifecycleBinding
+/**
+ * this class has no &#064;LifecycleBinding. It will get added later via
+ * an Extension on {@link javax.enterprise.inject.spi.BeforeBeanDiscovery}.
+ */
 @Interceptor
-public class LifecycleInterceptor implements Serializable
+public class LifecycleInterceptorBbd implements Serializable
 {
     public static boolean POST_CONSTRUCT = false;
     

Propchange: 
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorBbd.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorPat.java
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorPat.java?rev=1149288&view=auto
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorPat.java
 (added)
+++ 
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleInterceptorPat.java
 Thu Jul 21 18:07:24 2011
@@ -0,0 +1,50 @@
+/*
+ * 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.newtests.interceptors.lifecycle;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.interceptor.InvocationContext;
+import java.io.Serializable;
+
+/**
+ * this class has no &#064;LifecycleBinding nor &#064;Interceptor.
+ * Those will get added later via
+ * an Extension on {@link javax.enterprise.inject.spi.ProcessAnnotatedType}.
+ */
+public class LifecycleInterceptorPat implements Serializable
+{
+    public static boolean POST_CONSTRUCT = false;
+    
+    public static boolean PRE_DESTROY = false;
+    
+    @PostConstruct
+    public void postConstruct(InvocationContext context)
+    {
+        POST_CONSTRUCT = true;
+        NotAnnotatedBean.PC = true;
+    }
+    
+    @PreDestroy
+    public void preDestroy(InvocationContext context)
+    {
+        PRE_DESTROY = true;
+        NotAnnotatedBean.PC = true;
+    }
+}

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=1149288&r1=1149287&r2=1149288&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
 Thu Jul 21 18:07:24 2011
@@ -109,5 +109,51 @@ public class LifecycleTest extends Abstr
         
         shutDownContainer();
     }
-    
+
+    /**
+     * Test an interceptor with no annotations but instead dynamically
+     * add the InterceptorBinding and stuff via AnnotatedType.
+     * Bbd stands for BeforeBeanDiscovery
+     */
+    @Test
+    public void testDynamicInterceptorBeforeBeanDiscovery()
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        beanXmls.add(getXmlPath(PACKAGE_NAME, "LifecycleTestBbd"));
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(NotAnnotatedBean.class);
+        beanClasses.add(LifecycleInterceptor.class);
+
+
+        addExtension(new InterceptorExtension());
+
+        startContainer(beanClasses, beanXmls);
+
+        shutDownContainer();
+    }
+
+    /**
+     * Test an interceptor with no annotations but instead dynamically
+     * add the InterceptorBinding and stuff via AnnotatedType.
+     * Bbd stands for BeforeBeanDiscovery
+     */
+    @Test
+    public void testDynamicInterceptorProcessAnnotatedType()
+    {
+        Collection<String> beanXmls = new ArrayList<String>();
+        beanXmls.add(getXmlPath(PACKAGE_NAME, "LifecycleTestPat"));
+
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        beanClasses.add(NotAnnotatedBean.class);
+        beanClasses.add(LifecycleInterceptor.class);
+
+
+        addExtension(new InterceptorExtension());
+
+        startContainer(beanClasses, beanXmls);
+
+        shutDownContainer();
+    }
+
 }

Copied: 
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestBbd.xml
 (from r1148655, 
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTest.xml)
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestBbd.xml?p2=openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestBbd.xml&p1=openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTest.xml&r1=1148655&r2=1149288&rev=1149288&view=diff
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTest.xml
 (original)
+++ 
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestBbd.xml
 Thu Jul 21 18:07:24 2011
@@ -19,6 +19,6 @@ under the License.
 -->
 <beans>
    <interceptors>
-      
<class>org.apache.webbeans.newtests.interceptors.lifecycle.LifecycleInterceptor</class>
+      
<class>org.apache.webbeans.newtests.interceptors.lifecycle.LifecycleInterceptorBbd</class>
    </interceptors>
 </beans>

Propchange: 
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestBbd.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestPat.xml
URL: 
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestPat.xml?rev=1149288&view=auto
==============================================================================
--- 
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestPat.xml
 (added)
+++ 
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/interceptors/lifecycle/LifecycleTestPat.xml
 Thu Jul 21 18:07:24 2011
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans>
+   <interceptors>
+      
<class>org.apache.webbeans.newtests.interceptors.lifecycle.LifecycleInterceptorPat</class>
+   </interceptors>
+</beans>


Reply via email to