openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1797486 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery: AfterBeanDiscoveryImpl.java AfterDeploymentValidationImpl.java AfterTypeDiscoveryImpl.java
Date Sat, 03 Jun 2017 10:32:33 GMT
Author: struberg
Date: Sat Jun  3 10:32:32 2017
New Revision: 1797486

URL: http://svn.apache.org/viewvc?rev=1797486&view=rev
Log:
OWB-1186 checkState on more observer methods

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterTypeDiscoveryImpl.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java?rev=1797486&r1=1797485&r2=1797486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterBeanDiscoveryImpl.java
Sat Jun  3 10:32:32 2017
@@ -39,6 +39,7 @@ import org.apache.webbeans.container.Bea
 import org.apache.webbeans.exception.WebBeansConfigurationException;
 import org.apache.webbeans.intercept.InterceptorsManager;
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.portable.events.EventBase;
 import org.apache.webbeans.portable.events.generics.GProcessSyntheticBean;
 import org.apache.webbeans.portable.events.generics.GProcessSyntheticObserverMethod;
 import org.apache.webbeans.util.AnnotationUtil;
@@ -52,7 +53,7 @@ import java.util.logging.Logger;
  * @version $Rev$ $Date$
  *
  */
-public class AfterBeanDiscoveryImpl implements AfterBeanDiscovery, ExtensionAware
+public class AfterBeanDiscoveryImpl extends EventBase implements AfterBeanDiscovery, ExtensionAware
 {
     private BeanManagerImpl beanManager = null;
 
@@ -60,7 +61,6 @@ public class AfterBeanDiscoveryImpl impl
     private final WebBeansContext webBeansContext;
 
     private Extension extension;
-    private boolean started;
 
     public AfterBeanDiscoveryImpl(WebBeansContext webBeansContext)
     {
@@ -68,11 +68,6 @@ public class AfterBeanDiscoveryImpl impl
         beanManager = this.webBeansContext.getBeanManagerImpl();
     }
 
-    public void setStarted()
-    {
-        started = true;
-    }
-
     @Override
     public void setExtension(Extension extension)
     {
@@ -85,10 +80,7 @@ public class AfterBeanDiscoveryImpl impl
     @Override
     public void addBean(Bean<?> bean)
     {
-        if (started)
-        {
-            throw new IllegalStateException("Don't call AfterBeanDiscovery.addBean(bean)
after the event is fired");
-        }
+        checkState();
 
         AnnotatedType<?> annotatedType = webBeansContext.getAnnotatedElementFactory().newAnnotatedType(bean.getBeanClass());
 
@@ -191,10 +183,7 @@ public class AfterBeanDiscoveryImpl impl
     @Override
     public void addContext(Context context)
     {
-        if (started)
-        {
-            throw new IllegalStateException("Don't call AfterBeanDiscovery.addContext(...)
after the event is fired");
-        }
+        checkState();
         beanManager.addContext(context);
 
     }
@@ -205,10 +194,7 @@ public class AfterBeanDiscoveryImpl impl
     @Override
     public void addDefinitionError(Throwable t)
     {
-        if (started)
-        {
-            throw new IllegalStateException("Don't call AfterBeanDiscovery.addBean(bean)
after the event is fired");
-        }
+        checkState();
         beanManager.getErrorStack().pushError(t);
     }
 
@@ -218,10 +204,7 @@ public class AfterBeanDiscoveryImpl impl
     @Override
     public void addObserverMethod(ObserverMethod<?> observerMethod)
     {
-        if (started)
-        {
-            throw new IllegalStateException("Don't call AfterBeanDiscovery.addObserverMethod(...)
after the event is fired");
-        }
+        checkState();
         GProcessSyntheticObserverMethod event = new GProcessSyntheticObserverMethod(null,observerMethod,
extension);
         if (!event.isVetoed())
         {
@@ -236,10 +219,7 @@ public class AfterBeanDiscoveryImpl impl
      */
     public <T> AnnotatedType<T> getAnnotatedType(Class<T> type, String
id)
     {
-        if (started)
-        {
-            throw new IllegalStateException("Don't call AfterBeanDiscovery.getAnnotatedType(...)
after the event is fired");
-        }
+        checkState();
         return (AnnotatedType<T>) beanManager.getAdditionalAnnotatedType(type, id);
     }
 
@@ -248,10 +228,7 @@ public class AfterBeanDiscoveryImpl impl
      */
     public <T> Iterable<AnnotatedType<T>> getAnnotatedTypes(Class<T>
type)
     {
-        if (started)
-        {
-            throw new IllegalStateException("Don't call AfterBeanDiscovery.getAnnotatedTypes(...)
after the event is fired");
-        }
+        checkState();
         return beanManager.getAnnotatedTypes(type);
     }
 
@@ -259,6 +236,7 @@ public class AfterBeanDiscoveryImpl impl
     @Override
     public <T> BeanConfigurator<T> addBean()
     {
+        checkState();
         throw new UnsupportedOperationException("CDI 2.0 not yet imlemented");
     }
 
@@ -266,6 +244,7 @@ public class AfterBeanDiscoveryImpl impl
     @Override
     public <T> ObserverMethodConfigurator<T> addObserverMethod()
     {
+        checkState();
         throw new UnsupportedOperationException("CDI 2.0 not yet imlemented");
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java?rev=1797486&r1=1797485&r2=1797486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterDeploymentValidationImpl.java
Sat Jun  3 10:32:32 2017
@@ -21,6 +21,7 @@ package org.apache.webbeans.portable.eve
 import javax.enterprise.inject.spi.AfterDeploymentValidation;
 
 import org.apache.webbeans.container.BeanManagerImpl;
+import org.apache.webbeans.portable.events.EventBase;
 
 /**
  * Event that is fired by the container after it validates
@@ -29,20 +30,15 @@ import org.apache.webbeans.container.Bea
  * @version $Rev$ $Date$
  *
  */
-public class AfterDeploymentValidationImpl implements AfterDeploymentValidation
+public class AfterDeploymentValidationImpl extends EventBase implements AfterDeploymentValidation
 {
     private final BeanManagerImpl beanManagerImpl;
-    private boolean started;
 
     public AfterDeploymentValidationImpl(BeanManagerImpl beanManagerImpl)
     {
         this.beanManagerImpl = beanManagerImpl;
     }
 
-    public void setStarted()
-    {
-        started = true;
-    }
 
     /**
      * {@inheritDoc}
@@ -50,10 +46,7 @@ public class AfterDeploymentValidationIm
     @Override
     public void addDeploymentProblem(Throwable t)
     {
-        if (started)
-        {
-            throw new IllegalStateException("Only call container eevnt methods in their lifecycle");
-        }
+        checkState();
         beanManagerImpl.getErrorStack().pushError(t);
     }
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterTypeDiscoveryImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterTypeDiscoveryImpl.java?rev=1797486&r1=1797485&r2=1797486&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterTypeDiscoveryImpl.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/discovery/AfterTypeDiscoveryImpl.java
Sat Jun  3 10:32:32 2017
@@ -86,6 +86,7 @@ public class AfterTypeDiscoveryImpl exte
     @Override
     public <T> AnnotatedTypeConfigurator<T> addAnnotatedType(Class<T> forClass,
String id)
     {
+        checkState();
         throw new UnsupportedOperationException("CDI 2.0 not yet imlemented");
     }
 



Mime
View raw message