openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1428995 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/creation/ config/ util/
Date Fri, 04 Jan 2013 17:38:40 GMT
Author: arne
Date: Fri Jan  4 17:38:40 2013
New Revision: 1428995

URL: http://svn.apache.org/viewvc?rev=1428995&view=rev
Log:
OWB-745: Removed DefinitionUtil.defineInjectedFields

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectedTargetBeanCreator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.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/component/creation/AbstractInjectedTargetBeanCreator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectedTargetBeanCreator.java?rev=1428995&r1=1428994&r2=1428995&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectedTargetBeanCreator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectedTargetBeanCreator.java
Fri Jan  4 17:38:40 2013
@@ -26,7 +26,6 @@ import org.apache.webbeans.component.Abs
 import org.apache.webbeans.component.ProducerFieldBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.config.WebBeansContext;
-import org.apache.webbeans.util.WebBeansAnnotatedTypeUtil;
 
 /**
  * Abstract implementation of {@link InjectedTargetBeanCreator}.
@@ -65,16 +64,7 @@ public abstract class AbstractInjectedTa
      */
     public void defineInjectedFields()
     {
-        AbstractInjectionTargetBean bean = getBean();
-        if(isDefaultMetaDataProvider())
-        {
-            bean.getWebBeansContext().getDefinitionUtil().defineInjectedFields(bean);
-        }
-        else
-        {
-            WebBeansAnnotatedTypeUtil.defineInjectedFields(bean, getAnnotatedType());
-        }
-        
+        webBeansContext.getAnnotatedTypeUtil().defineInjectedFields(getBean(), getAnnotatedType());
     }
 
     /**

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=1428995&r1=1428994&r2=1428995&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
Fri Jan  4 17:38:40 2013
@@ -829,97 +829,6 @@ public final class DefinitionUtil
         return component;
     }
 
-    public <T> void defineInjectedFields(AbstractInjectionTargetBean<T> component)
-    {
-        Class<T> clazz = component.getReturnType();
-
-        // From component
-        defineInternalInjectedFields(component, clazz, false);
-
-        // From inherited super class
-        defineInternalInjectedFieldsRecursively(component, clazz);
-
-    }
-
-    public <T> void defineInternalInjectedFieldsRecursively(AbstractInjectionTargetBean<T>
component, Class<T> clazz)
-    {
-        // From inheritance
-        Class<?> superClazz = clazz.getSuperclass();
-        
-        if (!superClazz.equals(Object.class))
-        {
-            // From super class
-            defineInternalInjectedFields(component, (Class<T>) superClazz, true);
-
-            // From super class type hierarchy
-            defineInternalInjectedFieldsRecursively(component, (Class<T>) superClazz);
-        }
-
-    }
-
-    public <T> void defineInternalInjectedFields(AbstractInjectionTargetBean<T>
component, Class<T> clazz, boolean fromSuperClazz)
-    {
-
-        final AnnotationManager annotationManager = webBeansContext.getAnnotationManager();
-
-        Field[] fields = webBeansContext.getSecurityService().doPrivilegedGetDeclaredFields(clazz);
-
-        if (fields.length != 0)
-        {
-            for (Field field : fields)
-            {
-                //Check for public fields
-                if(Modifier.isPublic(field.getModifiers()) && !Modifier.isStatic(field.getModifiers()))
-                {
-                    if(webBeansContext.getBeanManagerImpl().isNormalScope(component.getScope()))
-                    {
-                        throw new WebBeansConfigurationException("If bean has a public field,
bean scope must be defined as @Scope. Bean is : "
-                                                                 + component.toString());
-                    }
-                }                
-                                
-                if(!field.isAnnotationPresent(Inject.class))
-                {
-                    continue;
-                }
-
-                Annotation[] anns = field.getDeclaredAnnotations();
-
-                // Injected fields can not be @Produces
-                if (AnnotationUtil.hasAnnotation(anns, Produces.class))
-                {
-                    throw new WebBeansConfigurationException("Injection fields can not be
annotated with @Produces");
-                }
-
-                Annotation[] qualifierAnns = annotationManager.getQualifierAnnotations(anns);
-
-                if (qualifierAnns.length > 0)
-                {
-                    if (qualifierAnns.length > 0)
-                    {
-                        annotationManager.checkForNewQualifierForDeployment(field.getGenericType(),
clazz, field.getName(), anns);
-                    }
-
-                    int mod = field.getModifiers();
-                    
-                    if (!Modifier.isStatic(mod) && !Modifier.isFinal(mod))
-                    {
-                        if(fromSuperClazz)
-                        {
-                            component.addInjectedFieldToSuper(field);    
-                        }
-                        else
-                        {
-                            component.addInjectedField(field);
-                        }
-                        
-                        addFieldInjectionPointMetaData(component, field);               
                
-                    }
-                }                                    
-            }
-        }
-    }
-
     public <T> void defineInjectedMethods(AbstractInjectionTargetBean<T> bean)
     {
         Asserts.assertNotNull(bean, "bean parameter can not be null");

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java?rev=1428995&r1=1428994&r2=1428995&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/ManagedBeanConfigurator.java
Fri Jan  4 17:38:40 2013
@@ -177,7 +177,7 @@ public final class ManagedBeanConfigurat
 
 
         webBeansContext.getAnnotatedTypeUtil().defineDisposalMethods(component, component.getAnnotatedType());
-        definitionUtil.defineInjectedFields(component);
+        webBeansContext.getAnnotatedTypeUtil().defineInjectedFields(component, component.getAnnotatedType());
         definitionUtil.defineInjectedMethods(component);
         definitionUtil.defineObserverMethods(component, clazz);
 

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java?rev=1428995&r1=1428994&r2=1428995&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansAnnotatedTypeUtil.java
Fri Jan  4 17:38:40 2013
@@ -36,7 +36,6 @@ import org.apache.webbeans.inject.impl.I
 import org.apache.webbeans.logger.WebBeansLoggerFacade;
 import org.apache.webbeans.spi.api.ResourceReference;
 
-import javax.decorator.Delegate;
 import javax.enterprise.context.Dependent;
 import javax.enterprise.event.Observes;
 import javax.enterprise.event.Reception;
@@ -165,9 +164,14 @@ public final class WebBeansAnnotatedType
         }
     }
     
-    public static <T,X> void addFieldInjectionPointMetaData(AbstractOwbBean<T>
owner, AnnotatedField<X> annotField)
+    public <T,X> void addFieldInjectionPointMetaData(AbstractOwbBean<T> owner,
AnnotatedField<X> annotField)
     {
-        owner.addInjectionPoint(owner.getWebBeansContext().getInjectionPointFactory().getFieldInjectionPointData(owner,
annotField));
+        InjectionPoint injectionPoint = owner.getWebBeansContext().getInjectionPointFactory().getFieldInjectionPointData(owner,
annotField);
+        if (injectionPoint != null)
+        {
+            webBeansContext.getDefinitionUtil().addImplicitComponentForInjectionPoint(injectionPoint);
+            owner.addInjectionPoint(injectionPoint);
+        }
     }
     
     @SuppressWarnings("unchecked")
@@ -335,24 +339,32 @@ public final class WebBeansAnnotatedType
         webBeansContext.getDefinitionUtil().defineInternalInjectedMethodsRecursively(bean,
annotatedType.getJavaClass());
     }
     
-    public static <X> void defineInjectedFields(AbstractInjectionTargetBean<X>
bean,AnnotatedType<X> annotatedType)
+    public <X> void defineInjectedFields(AbstractInjectionTargetBean<X> bean,AnnotatedType<X>
annotatedType)
     {
         AnnotationManager annotationManager = bean.getWebBeansContext().getAnnotationManager();
 
         Set<AnnotatedField<? super X>> annotatedFields = annotatedType.getFields();
  
         for(AnnotatedField<? super X> annotatedField: annotatedFields)
         {
+            if(Modifier.isPublic(annotatedField.getJavaMember().getModifiers()) &&
!annotatedField.isStatic())
+            {
+                if(webBeansContext.getBeanManagerImpl().isNormalScope(bean.getScope()))
+                {
+                    throw new WebBeansConfigurationException("If bean has a public field,
bean scope must be defined as @Scope. Bean is : "
+                            + bean.toString());
+                }
+            }                
+            
             if(!annotatedField.isAnnotationPresent(Inject.class))
             {
                 continue;
             }
 
-            if (annotatedField.isAnnotationPresent(Produces.class) || annotatedField.isAnnotationPresent(Delegate.class))
+            if (annotatedField.isAnnotationPresent(Produces.class))
             {
-                continue;
+                throw new WebBeansConfigurationException("Injection fields can not be annotated
with @Produces");
             }
             
-            
             Field field = annotatedField.getJavaMember();
             Annotation[] anns = AnnotationUtil.getAnnotationsFromSet(annotatedField.getAnnotations());
             if(Modifier.isPublic(field.getModifiers()))
@@ -382,8 +394,6 @@ public final class WebBeansAnnotatedType
                 }
             }                                    
         }
-        
-        bean.getWebBeansContext().getDefinitionUtil().defineInternalInjectedFieldsRecursively(bean,
annotatedType.getJavaClass());
     }
     
     

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=1428995&r1=1428994&r2=1428995&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
Fri Jan  4 17:38:40 2013
@@ -585,7 +585,7 @@ public final class WebBeansUtil
             comp.setConstructor(defineConstructor(clazz));
             definitionUtil.addConstructorInjectionPointMetaData(comp, comp.getConstructor());
 
-            definitionUtil.defineInjectedFields(comp);
+            webBeansContext.getAnnotatedTypeUtil().defineInjectedFields(comp, comp.getAnnotatedType());
             definitionUtil.defineInjectedMethods(comp);
         }
         else if (EJBWebBeansConfigurator.isSessionBean(clazz, webBeansContext))



Mime
View raw message