openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r735258 - /incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
Date Sat, 17 Jan 2009 09:42:30 GMT
Author: gerdogdu
Date: Sat Jan 17 01:42:29 2009
New Revision: 735258

URL: http://svn.apache.org/viewvc?rev=735258&view=rev
Log:
Update producer method specialization.

Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=735258&r1=735257&r2=735258&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
Sat Jan 17 01:42:29 2009
@@ -97,8 +97,10 @@
         {
             ProducerComponentImpl<?> p = (ProducerComponentImpl<?>) component;
             component.setType(p.getParent().getType());
+            found = true;
         }
-        else
+        
+        if(!found)
         {
 
             component.setType(WebBeansUtil.getMaxPrecedenceSteroTypeDeploymentType(component));
@@ -331,8 +333,8 @@
         Set<ProducerComponentImpl<?>> producerComponents = new HashSet<ProducerComponentImpl<?>>();
 
         Class<?> clazz = component.getReturnType();
-
         Method[] declaredMethods = clazz.getDeclaredMethods();
+        boolean isSpecializes = false;
         for (Method declaredMethod : declaredMethods)
         {
             // Producer Method
@@ -342,20 +344,18 @@
 
                 if (AnnotationUtil.isMethodHasAnnotation(declaredMethod, Specializes.class))
                 {
-                    if (AnnotationUtil.isMethodHasAnnotation(declaredMethod, Override.class))
-                    {
-                        WebBeansUtil.configureProducerSpecialization(component, declaredMethod,
clazz.getSuperclass());
-                    }
-                    else
+                    if(ClassUtil.isStatic(declaredMethod.getModifiers()))
                     {
-                        throw new WebBeansConfigurationException("Producer method : " + declaredMethod.getName()
+ " in class : " + clazz.getName() + " must override its super class method");
-                    }
+                        throw new WebBeansConfigurationException("Specializing producer method
: " + declaredMethod.getName() + " in class : " + clazz.getName() + " can not be static");
+                    }                 
+                    
+                    isSpecializes = true;
                 }
 
                 Type[] observableTypes = AnnotationUtil.getMethodParameterGenericTypesWithGivenAnnotation(declaredMethod,
Fires.class);
                 EventUtil.checkObservableMethodParameterConditions(observableTypes, "method
parameter", "method : " + declaredMethod.getName() + "in class : " + clazz.getName());
 
-                ProducerComponentImpl<?> newComponent = createProducerComponent(declaredMethod.getReturnType(),
declaredMethod, component);
+                ProducerComponentImpl<?> newComponent = createProducerComponent(declaredMethod.getReturnType(),
declaredMethod, component,isSpecializes);
                 if (newComponent != null)
                 {
                     producerComponents.add(newComponent);
@@ -367,10 +367,15 @@
 
     }
 
-    private static <T> ProducerComponentImpl<T> createProducerComponent(Class<T>
returnType, Method method, AbstractComponent<?> parent)
+    private static <T> ProducerComponentImpl<T> createProducerComponent(Class<T>
returnType, Method method, AbstractComponent<?> parent,boolean isSpecializes)
     {
         ProducerComponentImpl<T> component = new ProducerComponentImpl<T>(parent,
returnType);
         component.setCreatorMethod(method);
+        
+        if(isSpecializes)
+        {
+            WebBeansUtil.configureProducerSpecialization(component, method, parent.getReturnType().getSuperclass());
  
+        }
 
         if (returnType.isPrimitive())
         {



Mime
View raw message