openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r916504 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/util/ test/java/org/apache/webbeans/newtests/producer/ test/java/org/apache/webbeans/newtests/producer/specializes/ test/java/org/apache/webbeans/test/unittes...
Date Fri, 26 Feb 2010 00:15:06 GMT
Author: gerdogdu
Date: Fri Feb 26 00:15:05 2010
New Revision: 916504

URL: http://svn.apache.org/viewvc?rev=916504&view=rev
Log:
[OWB-308] thanks to YING WANG

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/specializes/
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/specializes/SpecializesProducer1Test.java
  (with props)
Modified:
    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
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/specializes/SpecializesProducer1Test.java

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=916504&r1=916503&r2=916504&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 Feb 26 00:15:05 2010
@@ -549,6 +549,8 @@
                     annotatedMethod.getDeclaringType().getJavaClass().getSuperclass().getName()
+ " is not annotated with @Produces" + " for annotated method : " + annotatedMethod);
         }
 
+        /* To avoid multiple invocations of setBeanName(), following code is delayed to
+         * configSpecializedProducerMethodBeans() when checkSpecializations.
         Annotation[] anns = AnnotationUtil.getQualifierAnnotations(superMethod.getAnnotations());
 
         for (Annotation ann : anns)
@@ -557,6 +559,7 @@
         }
         
         WebBeansUtil.configuredProducerSpecializedName(bean, annotatedMethod.getJavaMember(),
superMethod);
+        */
         
         bean.setSpecializedBean(true);        
     }

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=916504&r1=916503&r2=916504&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 Feb 26 00:15:05 2010
@@ -1664,7 +1664,14 @@
             	}
                                 
                 AbstractOwbBean<?> comp = (AbstractOwbBean<?>)specialized;
-
+                if (comp.isSpecializedBean())
+               	{
+                	// This comp is already configured in previous invocation
+                	// return directly, else Exception might be fired when set
+                	// bean name again.
+                	return;
+               	}
+                
                 if(superBean.getName() != null)
                 {
                     if(comp.getName() != null)
@@ -1968,6 +1975,8 @@
             throw new WebBeansConfigurationException("Producer method specialization is failed.
Method " + method.getName() + " found in super class : " + superClass.getName() + " is not
annotated with @Produces");
         }
 
+        /* To avoid multiple invocations of setBeanName(), following code is delayed to
+         * configSpecializedProducerMethodBeans() when checkSpecializations.
         Annotation[] anns = AnnotationUtil.getQualifierAnnotations(superMethod.getAnnotations());
 
         for (Annotation ann : anns)
@@ -1976,7 +1985,8 @@
         }
         
         WebBeansUtil.configuredProducerSpecializedName(component, method, superMethod);
-
+		*/
+        
         component.setSpecializedBean(true);
         
     }

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/specializes/SpecializesProducer1Test.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/specializes/SpecializesProducer1Test.java?rev=916504&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/specializes/SpecializesProducer1Test.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/specializes/SpecializesProducer1Test.java
Fri Feb 26 00:15:05 2010
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ * or agreed to in writing, software distributed under the License is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.apache.webbeans.newtests.producer.specializes;
+
+import java.lang.annotation.Annotation;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.AnnotationLiteral;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.apache.webbeans.test.annotation.binding.Binding1;
+import org.apache.webbeans.test.annotation.binding.Binding2;
+import org.apache.webbeans.test.component.producer.specializes.SpecializesProducer1;
+import org.apache.webbeans.test.component.producer.specializes.superclazz.SpecializesProducer1SuperClazz;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SpecializesProducer1Test extends AbstractUnitTest
+{
+
+    @Test
+    public void testSpecializedProducer1()
+    {
+        Collection<URL> beanXmls = new ArrayList<URL>();
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+
+        beanClasses.add(SpecializesProducer1SuperClazz.class);
+        beanClasses.add(SpecializesProducer1.class);
+        
+        startContainer(beanClasses, beanXmls);        
+        
+        Annotation binding1 = new AnnotationLiteral<Binding1>()
+        {
+        };
+        Annotation binding2 = new AnnotationLiteral<Binding2>()
+        {
+        };
+
+        Set beans = getBeanManager().getBeans(int.class, new Annotation[] { binding1, binding2
});
+        System.out.print("Size of the bean set is " + beans.size());
+        Assert.assertTrue(beans.size() == 1);
+        Bean<Integer> bean = (Bean<Integer>)beans.iterator().next();
+        CreationalContext<Integer> cc = getBeanManager().createCreationalContext(bean);
+        Integer number = (Integer) getBeanManager().getReference(bean, int.class, cc);
+        
+        Assert.assertEquals(10000, number.intValue());
+        
+        shutDownContainer();       
+        
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/producer/specializes/SpecializesProducer1Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/specializes/SpecializesProducer1Test.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/specializes/SpecializesProducer1Test.java?rev=916504&r1=916503&r2=916504&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/specializes/SpecializesProducer1Test.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/producer/specializes/SpecializesProducer1Test.java
Fri Feb 26 00:15:05 2010
@@ -55,7 +55,9 @@
         };
 
         Object number = getManager().getInstanceByType(int.class, new Annotation[] { binding1,
binding2 });
-
-        Assert.assertEquals(10000, number);
+        //This test is not valid since specialize configuration requires
+        //all producers at deployment step in container. See:
+        //org.apache.webbeans.newtests.producer.specializes.SpecializesProducer1Test
+        //Assert.assertEquals(10000, number);
     }
 }



Mime
View raw message