[weld-commits] Weld SVN: r5386 - in core/trunk: tests/src/test/java/org/jboss/weld/tests/producer/method and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Jan 6 12:53:50 EST 2010


Author: pete.muir at jboss.org
Date: 2010-01-06 12:53:50 -0500 (Wed, 06 Jan 2010)
New Revision: 5386

Added:
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/JmsTemplate.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/JmsTemplateConfigurationProducer.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Long.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Short.java
Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/NamedProducerTest.java
Log:
WELD-354

Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java	2010-01-06 17:53:08 UTC (rev 5385)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java	2010-01-06 17:53:50 UTC (rev 5386)
@@ -95,8 +95,10 @@
    }
 
    /**
-    * Gets the property name from a getter method
+    * Gets the property name from a getter method.
     * 
+    * We extend JavaBean conventions, allowing the getter method to have parameters
+    * 
     * @param method The getter method
     * @return The name of the property. Returns null if method wasn't JavaBean
     *         getter-styled
@@ -104,11 +106,11 @@
    public static String getPropertyName(Method method)
    {
       String methodName = method.getName();
-      if (methodName.matches("^(get).*") && method.getParameterTypes().length == 0)
+      if (methodName.matches("^(get).*"))
       {
          return Introspector.decapitalize(methodName.substring(3));
       }
-      else if (methodName.matches("^(is).*") && method.getParameterTypes().length == 0)
+      else if (methodName.matches("^(is).*"))
       {
          return Introspector.decapitalize(methodName.substring(2));
       }

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/JmsTemplate.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/JmsTemplate.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/JmsTemplate.java	2010-01-06 17:53:50 UTC (rev 5386)
@@ -0,0 +1,18 @@
+package org.jboss.weld.tests.producer.method;
+
+public class JmsTemplate
+{
+   
+   private final int receiveTimeout;
+   
+   public JmsTemplate(int receiveTimeout)
+   {
+      this.receiveTimeout = receiveTimeout;
+   }
+   
+   public int getReceiveTimeout()
+   {
+      return receiveTimeout;
+   }
+
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/JmsTemplate.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/JmsTemplateConfigurationProducer.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/JmsTemplateConfigurationProducer.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/JmsTemplateConfigurationProducer.java	2010-01-06 17:53:50 UTC (rev 5386)
@@ -0,0 +1,31 @@
+package org.jboss.weld.tests.producer.method;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+public class JmsTemplateConfigurationProducer
+{
+   
+   public static final int LONG_RECEIVE_TIMEOUT = 3 * 3600;
+   public static final int SHORT_RECEIVE_TIMEOUT = 100;
+
+   @Produces @Long
+   private int longReceiveTimeout = LONG_RECEIVE_TIMEOUT;
+   
+   @Produces @Short
+   private int shortReceiveTimeout = SHORT_RECEIVE_TIMEOUT;
+
+   @Produces
+   @Named
+   public JmsTemplate getErrorQueueTemplate(@Long int receiveTimeout)
+   {
+      return new JmsTemplate(receiveTimeout);
+   }
+
+   @Produces
+   @Named
+   public JmsTemplate getLogQueueTemplate(@Short int receiveTimeout)
+   {
+      return new JmsTemplate(receiveTimeout);
+   }
+}
\ No newline at end of file


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/JmsTemplateConfigurationProducer.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Long.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Long.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Long.java	2010-01-06 17:53:50 UTC (rev 5386)
@@ -0,0 +1,25 @@
+package org.jboss.weld.tests.producer.method;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * @author Dan Allen
+ */
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+ at Inherited
+public @interface Long {
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Long.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/NamedProducerTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/NamedProducerTest.java	2010-01-06 17:53:08 UTC (rev 5385)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/NamedProducerTest.java	2010-01-06 17:53:50 UTC (rev 5386)
@@ -1,5 +1,10 @@
 package org.jboss.weld.tests.producer.method;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
 import javax.enterprise.inject.spi.Bean;
 
 import org.jboss.testharness.impl.packaging.Artifact;
@@ -9,6 +14,7 @@
 @Artifact
 public class NamedProducerTest extends AbstractWeldTest
 {
+   
    @Test
    public void testNamedProducer()
    {
@@ -19,5 +25,18 @@
       String[] itoen = (String[]) getCurrentManager().getReference(itoenBean, Object.class, getCurrentManager().createCreationalContext(itoenBean));
       assert itoen.length == 2;
    }
+   
+   @Test
+   public void testDefaultNamedProducerMethod() 
+   {
+      Set<Bean<?>> beans = getCurrentManager().getBeans(JmsTemplate.class);
+      assert beans.size() == 2;
+      List<String> beanNames = new ArrayList<String>(Arrays.asList("errorQueueTemplate", "logQueueTemplate"));
+      for (Bean<?> b : beans)
+      {
+         beanNames.remove(b.getName());
+      }
+      assert beanNames.isEmpty();
+   }
 
 }

Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Short.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Short.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Short.java	2010-01-06 17:53:50 UTC (rev 5386)
@@ -0,0 +1,25 @@
+package org.jboss.weld.tests.producer.method;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+/**
+ * @author Dan Allen
+ */
+ at Target( { TYPE, METHOD, PARAMETER, FIELD })
+ at Retention(RUNTIME)
+ at Documented
+ at Qualifier
+ at Inherited
+public @interface Short {
+}


Property changes on: core/trunk/tests/src/test/java/org/jboss/weld/tests/producer/method/Short.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native



More information about the weld-commits mailing list