openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1432771 - in /openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans: component/creation/ util/
Date Sun, 13 Jan 2013 23:54:18 GMT
Author: arne
Date: Sun Jan 13 23:54:17 2013
New Revision: 1432771

URL: http://svn.apache.org/viewvc?rev=1432771&view=rev
Log:
OWB-747: fixed specialization

Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.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/AbstractInjectionTargetBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java?rev=1432771&r1=1432770&r2=1432771&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/AbstractInjectionTargetBeanBuilder.java
Sun Jan 13 23:54:17 2013
@@ -57,6 +57,7 @@ import org.apache.webbeans.component.Res
 import org.apache.webbeans.config.WebBeansContext;
 import org.apache.webbeans.container.InjectionResolver;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.exception.inject.DefinitionException;
 import org.apache.webbeans.spi.api.ResourceReference;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.Asserts;
@@ -104,12 +105,22 @@ public abstract class AbstractInjectionT
     {
         if (getAnnotated().isAnnotationPresent(Specializes.class))
         {
-            defineName(getSuperAnnotated(), WebBeansUtil.getManagedBeanDefaultName(getAnnotated().getJavaClass().getSimpleName()));
+            AnnotatedType<? super T> superAnnotated = getSuperAnnotated();
+            defineName(superAnnotated, WebBeansUtil.getManagedBeanDefaultName(superAnnotated.getJavaClass().getSimpleName()));
         }
         if (getName() == null)
         {
             defineName(getAnnotated(), WebBeansUtil.getManagedBeanDefaultName(getAnnotated().getJavaClass().getSimpleName()));
         }
+        else
+        {
+            // TODO XXX We have to check stereotypes here, too
+            if (getAnnotated().getJavaClass().isAnnotationPresent(Named.class))
+            {
+                throw new DefinitionException("@Specialized Class : " + getAnnotated().getJavaClass().getName()
+                        + " may not explicitly declare a bean name");
+            }
+        }
     }
 
     protected AnnotatedConstructor<T> getBeanConstructor()

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java?rev=1432771&r1=1432770&r2=1432771&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerFieldBeanBuilder.java
Sun Jan 13 23:54:17 2013
@@ -44,7 +44,8 @@ public class ProducerFieldBeanBuilder<T,
     {
         if (getAnnotated().isAnnotationPresent(Specializes.class))
         {
-            defineName(getSuperAnnotated(), WebBeansUtil.getProducerDefaultName(getSuperAnnotated().getJavaMember().getName()));
+            AnnotatedField<?> superAnnotated = getSuperAnnotated();
+            defineName(superAnnotated, WebBeansUtil.getProducerDefaultName(superAnnotated.getJavaMember().getName()));
         }
         if (getName() == null)
         {

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java?rev=1432771&r1=1432770&r2=1432771&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/component/creation/ProducerMethodBeanBuilder.java
Sun Jan 13 23:54:17 2013
@@ -29,10 +29,12 @@ import javax.enterprise.inject.Produces;
 import javax.enterprise.inject.Specializes;
 import javax.enterprise.inject.spi.AnnotatedMethod;
 import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.inject.Named;
 
 import org.apache.webbeans.component.InjectionTargetBean;
 import org.apache.webbeans.component.ProducerMethodBean;
 import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.exception.inject.DefinitionException;
 import org.apache.webbeans.util.AnnotationUtil;
 import org.apache.webbeans.util.ClassUtil;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -95,12 +97,22 @@ public class ProducerMethodBeanBuilder<T
         if (getAnnotated().isAnnotationPresent(Specializes.class))
         {
             specialized = true;
-            defineName(getSuperAnnotated(), WebBeansUtil.getProducerDefaultName(getSuperAnnotated().getJavaMember().getName()));
+            AnnotatedMethod<?> superAnnotated = getSuperAnnotated();
+            defineName(superAnnotated, WebBeansUtil.getProducerDefaultName(superAnnotated.getJavaMember().getName()));
         }
         if (getName() == null)
         {
             defineName(getAnnotated(), WebBeansUtil.getProducerDefaultName(getAnnotated().getJavaMember().getName()));
         }
+        else
+        {
+            // TODO XXX We have to check stereotypes here, too
+            if (getAnnotated().isAnnotationPresent(Named.class))
+            {
+                throw new DefinitionException("@Specialized Producer method : " + getAnnotated().getJavaMember().getName()
+                        + " may not explicitly declare a bean name");
+            }
+        }
     }
 
     protected AnnotatedMethod<?> getSuperAnnotated()

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=1432771&r1=1432770&r2=1432771&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
Sun Jan 13 23:54:17 2013
@@ -1389,7 +1389,7 @@ public final class WebBeansUtil
 
                 if(superBean.getName() != null)
                 {
-                    if(comp.getName() != null)
+                    if (!superBean.getName().equals(comp.getName()))
                     {
                         throw new DefinitionException("@Specialized Class : " + specializedClass.getName()
                                 + " may not explicitly declare a bean name");



Mime
View raw message