[seam-commits] Seam SVN: r12770 - in modules/jms/trunk: impl/src/main/java/org/jboss/seam/jms/impl/inject and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Thu May 20 22:44:31 EDT 2010


Author: jganoff
Date: 2010-05-20 22:44:30 -0400 (Thu, 20 May 2010)
New Revision: 12770

Modified:
   modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSession.java
   modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java
   modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java
Log:
JmsSession is no longer a qualifier

Modified: modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSession.java
===================================================================
--- modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSession.java	2010-05-21 01:50:38 UTC (rev 12769)
+++ modules/jms/trunk/api/src/main/java/org/jboss/seam/jms/annotations/JmsSession.java	2010-05-21 02:44:30 UTC (rev 12770)
@@ -23,7 +23,6 @@
 
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
 import static java.lang.annotation.ElementType.PARAMETER;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
 
@@ -31,23 +30,22 @@
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 
-import javax.enterprise.util.Nonbinding;
-import javax.inject.Qualifier;
-
 /**
- * Seam 3 JMS Qualifier for {@link javax.jms.Session} types
+ * Specifies configuration for injected {@link javax.jms.Session}
  * 
  * @author Jordan Ganoff
  */
- at Qualifier
 @Documented
- at Target( { FIELD, METHOD, TYPE, PARAMETER })
+ at Target( { FIELD, METHOD, PARAMETER })
 @Retention(RUNTIME)
 public @interface JmsSession
 {
-   @Nonbinding
-   public abstract boolean transacted() default false;
-
-   @Nonbinding
-   public abstract int acknowledgementType() default javax.jms.Session.AUTO_ACKNOWLEDGE;
+   /**
+    * @see javax.jms.Session#getTransacted()
+    */
+   boolean transacted() default false;
+   /**
+    * @see javax.jms.Session#getAcknowledgeMode()
+    */
+   int acknowledgementMode() default javax.jms.Session.AUTO_ACKNOWLEDGE;
 }

Modified: modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java
===================================================================
--- modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java	2010-05-21 01:50:38 UTC (rev 12769)
+++ modules/jms/trunk/impl/src/main/java/org/jboss/seam/jms/impl/inject/SessionProducer.java	2010-05-21 02:44:30 UTC (rev 12770)
@@ -21,8 +21,6 @@
  */
 package org.jboss.seam.jms.impl.inject;
 
-import static org.jboss.seam.jms.impl.inject.InjectionUtil.getExpectedQualifier;
-
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.inject.Disposes;
 import javax.enterprise.inject.Produces;
@@ -37,17 +35,17 @@
 class SessionProducer
 {
    @Produces
-   public Session getGenericSession(InjectionPoint ip, Connection c) throws JMSException
-   {
-      return c.createSession(false, Session.AUTO_ACKNOWLEDGE);
-   }
-
-   @Produces
-   @JmsSession
    public Session getSession(InjectionPoint ip, Connection c) throws JMSException
    {
-      JmsSession s = getExpectedQualifier(JmsSession.class, ip.getQualifiers());
-      return c.createSession(s.transacted(), s.acknowledgementType());
+      if (ip != null && ip.getAnnotated().isAnnotationPresent(JmsSession.class))
+      {
+         JmsSession s = ip.getAnnotated().getAnnotation(JmsSession.class);
+         return c.createSession(s.transacted(), s.acknowledgementMode());
+      }
+      else
+      {
+         return c.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      }
    }
 
    public void closeSession(@Disposes Session s) throws JMSException

Modified: modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java
===================================================================
--- modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java	2010-05-21 01:50:38 UTC (rev 12769)
+++ modules/jms/trunk/impl/src/test/java/org/jboss/seam/jms/test/inject/InjectConnectionTest.java	2010-05-21 02:44:30 UTC (rev 12770)
@@ -24,10 +24,12 @@
 import javax.enterprise.inject.Instance;
 import javax.inject.Inject;
 import javax.jms.Connection;
+import javax.jms.JMSException;
 import javax.jms.Session;
 
 import org.jboss.arquillian.api.Deployment;
 import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.jms.annotations.JmsSession;
 import org.jboss.seam.jms.test.Util;
 import org.jboss.shrinkwrap.api.spec.JavaArchive;
 import org.junit.Assert;
@@ -52,6 +54,10 @@
 
    @Inject
    private Instance<Session> s;
+   
+   @Inject
+   @JmsSession(transacted=false, acknowledgementMode=Session.CLIENT_ACKNOWLEDGE)
+   private Instance<Session> configuredSession;
 
    @Test
    public void injectConnection()
@@ -70,5 +76,13 @@
    {
       Assert.assertEquals(c.get(), c2.get());
    }
-
+   
+   @Test
+   public void configuredSession() throws JMSException
+   {
+      Session s = configuredSession.get();
+      Assert.assertNotNull(s);
+      Assert.assertFalse(s.getTransacted());
+      Assert.assertEquals(Session.CLIENT_ACKNOWLEDGE, s.getAcknowledgeMode());
+   }
 }



More information about the seam-commits mailing list