openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1647199 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java portable/events/generics/GProcessAnnotatedType.java
Date Sun, 21 Dec 2014 19:53:26 GMT
Author: rmannibucau
Date: Sun Dec 21 19:53:26 2014
New Revision: 1647199

URL: http://svn.apache.org/r1647199
Log:
ProcessAnnotatedType shouldn't be usable after it was fired

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessAnnotatedType.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java?rev=1647199&r1=1647198&r2=1647199&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
Sun Dec 21 19:53:26 2014
@@ -62,13 +62,13 @@ import org.apache.webbeans.logger.WebBea
 import org.apache.webbeans.portable.AbstractProducer;
 import org.apache.webbeans.portable.AnnotatedElementFactory;
 import org.apache.webbeans.portable.BaseProducerProducer;
-import org.apache.webbeans.portable.events.ProcessAnnotatedTypeImpl;
 import org.apache.webbeans.portable.events.ProcessBeanImpl;
 import org.apache.webbeans.portable.events.ProcessSyntheticAnnotatedTypeImpl;
 import org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl;
 import org.apache.webbeans.portable.events.discovery.AfterDeploymentValidationImpl;
 import org.apache.webbeans.portable.events.discovery.AfterTypeDiscoveryImpl;
 import org.apache.webbeans.portable.events.discovery.BeforeBeanDiscoveryImpl;
+import org.apache.webbeans.portable.events.generics.GProcessAnnotatedType;
 import org.apache.webbeans.portable.events.generics.GProcessManagedBean;
 import org.apache.webbeans.spi.BeanArchiveService;
 import org.apache.webbeans.spi.JNDIService;
@@ -865,11 +865,12 @@ public class BeansDeployer
                     // Fires ProcessAnnotatedType
                     if (!annotatedType.getJavaClass().isAnnotation())
                     {
-                        ProcessAnnotatedTypeImpl<?> processAnnotatedEvent = webBeansContext.getWebBeansUtil().fireProcessAnnotatedTypeEvent(annotatedType);
+                        GProcessAnnotatedType processAnnotatedEvent = webBeansContext.getWebBeansUtil().fireProcessAnnotatedTypeEvent(annotatedType);
                         if (!processAnnotatedEvent.isVeto())
                         {
                             annotatedTypes.add(processAnnotatedEvent.getAnnotatedType());
                         }
+                        processAnnotatedEvent.setAfter();
                     }
                     else
                     {
@@ -1195,7 +1196,7 @@ public class BeansDeployer
                     annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(clazz);
                 }
 
-                ProcessAnnotatedTypeImpl<?> processAnnotatedEvent =
+                GProcessAnnotatedType processAnnotatedEvent =
                         webBeansContext.getWebBeansUtil().fireProcessAnnotatedTypeEvent(annotatedType);
 
                 // if veto() is called
@@ -1205,6 +1206,7 @@ public class BeansDeployer
                 }
 
                 annotatedType = processAnnotatedEvent.getAnnotatedType();
+                processAnnotatedEvent.setAfter();
 
                 Set<Annotation> annTypeAnnotations = annotatedType.getAnnotations();
                 if (annTypeAnnotations != null)

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessAnnotatedType.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessAnnotatedType.java?rev=1647199&r1=1647198&r2=1647199&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessAnnotatedType.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/generics/GProcessAnnotatedType.java
Sun Dec 21 19:53:26 2014
@@ -25,11 +25,48 @@ import org.apache.webbeans.portable.even
 @SuppressWarnings("unchecked")
 public class GProcessAnnotatedType extends ProcessAnnotatedTypeImpl implements GenericBeanEvent
 {
+    private boolean after = false;
+
     public GProcessAnnotatedType(AnnotatedType annotatedType )
     {
         super(annotatedType);
     }
 
+    public void setAfter()
+    {
+        this.after = true;
+    }
+
+    @Override
+    public AnnotatedType getAnnotatedType()
+    {
+        if (after)
+        {
+            throw new IllegalStateException("Can't call ProcessAnnotatedType.getAnnotatedType()
after the event");
+        }
+        return super.getAnnotatedType();
+    }
+
+    @Override
+    public void setAnnotatedType(AnnotatedType type)
+    {
+        if (after)
+        {
+            throw new IllegalStateException("Can't call ProcessAnnotatedType.setAnnotatedType(at)
after the event");
+        }
+        super.setAnnotatedType(type);
+    }
+
+    @Override
+    public void veto()
+    {
+        if (after)
+        {
+            throw new IllegalStateException("Can't call ProcessAnnotatedType.veto() after
the event");
+        }
+        super.veto();
+    }
+
     @Override
     public Class<?> getBeanClassFor(Class<?> eventClass)
     {



Mime
View raw message