openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1486620 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: config/BeansDeployer.java util/WebBeansUtil.java
Date Mon, 27 May 2013 13:37:23 GMT
Author: rmannibucau
Date: Mon May 27 13:37:22 2013
New Revision: 1486620

URL: http://svn.apache.org/r1486620
Log:
OWB-867 don't log classes without constructor when not mandatory

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/BeansDeployer.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.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=1486620&r1=1486619&r2=1486620&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
Mon May 27 13:37:22 2013
@@ -69,6 +69,7 @@ import org.apache.webbeans.util.WebBeans
 import org.apache.webbeans.util.WebBeansUtil;
 import org.apache.webbeans.xml.WebBeansXMLConfigurator;
 
+import javax.enterprise.context.NormalScope;
 import javax.enterprise.inject.Model;
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.spi.AnnotatedField;
@@ -604,29 +605,60 @@ public class BeansDeployer
             defineEnterpriseWebBean((Class<Object>) implClass, (ProcessAnnotatedTypeImpl<Object>)
processAnnotatedEvent);
         }
         else if((ClassUtil.isConcrete(beanClass) || WebBeansUtil.isDecorator(processAnnotatedEvent.getAnnotatedType()))
&&
-                isValidManagedBean(beanClass))
+                isValidManagedBean(processAnnotatedEvent.getAnnotatedType()))
         {
             defineManagedBean(processAnnotatedEvent);
         }
     }
 
-    private boolean isValidManagedBean(Class beanClass)
+    private boolean isValidManagedBean(final AnnotatedType<?> type)
     {
+        final Class<?> beanClass = type.getJavaClass();
+        final WebBeansUtil webBeansUtil = webBeansContext.getWebBeansUtil();
+
+        // done separately to be able to swallow the logging when not relevant and avoid
to pollute logs
+        if (!webBeansUtil.isConstructorOk(beanClass))
+        {
+            if (isNormalScoped(type))
+            {
+                logger.info("Bean implementation class : " + beanClass.getName() + " must
define at least one Constructor");
+            } // else not an issue
+            return false;
+        }
+
         try
         {
-            webBeansContext.getWebBeansUtil().checkManagedBean(beanClass);
+            webBeansUtil.checkManagedBean(beanClass);
         }
-        catch (DefinitionException e)
+        catch (final DefinitionException e)
         {
             logger.info("skipped deployment of: " + beanClass.getName() + " reason: " + e.getMessage());
             logger.log(Level.FINER, "skipped deployment of: " + beanClass.getName() + " details:
", e);
             return false;
         }
         //we are not allowed to catch possible exceptions thrown by the following method
-        webBeansContext.getWebBeansUtil().checkManagedBeanCondition(beanClass);
+        webBeansUtil.checkManagedBeanCondition(beanClass);
         return true;
     }
 
+    private static boolean isNormalScoped(final AnnotatedType<?> type)
+    {
+        final Set<Annotation> annotations = type.getAnnotations();
+        if (annotations != null)
+        {
+            for (final Annotation a : annotations)
+            {
+                if (AnnotationUtil.hasMetaAnnotation(a.annotationType().getAnnotations(),
NormalScope.class)
+                        || AnnotationUtil.hasAnnotation(a.annotationType().getAnnotations(),
NormalScope.class))
+                {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
     /**
      * Discovers and deploys alternatives, interceptors and decorators from XML.
      * 

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=1486620&r1=1486619&r2=1486620&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
Mon May 27 13:37:22 2013
@@ -276,12 +276,6 @@ public final class WebBeansUtil
                                                      + clazz.getName() + " can not be non-static
inner class");
         }
 
-        if (!isConstructorOk(clazz))
-        {
-            throw new WebBeansConfigurationException("Bean implementation class : " + clazz.getName()
-                                                     + " must define at least one Constructor");
-        }
-
         if(Extension.class.isAssignableFrom(clazz))
         {
             throw new WebBeansConfigurationException("Bean implementation class can not implement
"



Mime
View raw message