[jboss-cvs] JBossAS SVN: r62124 - in trunk/ejb3: src/main/org/jboss/ejb and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 5 05:37:21 EDT 2007


Author: wolfc
Date: 2007-04-05 05:37:21 -0400 (Thu, 05 Apr 2007)
New Revision: 62124

Added:
   trunk/ejb3/src/resources/test/ejbthree939/
   trunk/ejb3/src/resources/test/ejbthree939/META-INF/
   trunk/ejb3/src/resources/test/ejbthree939/META-INF/jboss.xml
   trunk/ejb3/src/resources/test/ejbthree939/ejbthree939test-service.xml
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/DummyInterface.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/MultiInterfaceMDB.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/unit/
   trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/unit/MultiInterfaceMDBTestCase.java
Modified:
   trunk/ejb3/build-test.xml
   trunk/ejb3/src/main/org/jboss/ejb/MessageDrivenImpl.java
Log:
EJBTHREE-939: messageListenerInterface on described MDB

Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml	2007-04-05 07:44:47 UTC (rev 62123)
+++ trunk/ejb3/build-test.xml	2007-04-05 09:37:21 UTC (rev 62124)
@@ -255,6 +255,7 @@
       <path refid="sun.servlet.classpath"/>
       <pathelement path="${jboss.dist}/client/jbossall-client.jar"/>
       <pathelement path="${jboss.dist}/client/jboss-ejb3-client.jar"/>
+      <path refid="jboss.microcontainer.classpath"/>
    </path>
 
    <!-- The "security" test needs JaasSecurityManagerServiceMBean -->
@@ -1874,6 +1875,26 @@
       </jar>
    </target>
    
+   <target name="ejbthree939"
+      description="Builds all jar files."
+      depends="compile-classes">
+
+      <mkdir dir="${build.lib}"/>
+
+      <jar jarfile="${build.lib}/ejbthree939.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/ejb3/test/ejbthree939/*.class"/>
+         </fileset>
+         <fileset dir="${resources}/test/ejbthree939" includes="META-INF/*"/>
+      </jar>
+   
+      <copy todir="${build.lib}">
+         <fileset dir="${resources}/test/ejbthree939">
+            <include name="*.xml"/>
+         </fileset>
+      </copy>
+   </target>
+   
    <target name="jaxws"
       description="Builds a simple jar."
       depends="compile-classes">
@@ -3188,7 +3209,7 @@
    
    <target name="jars" depends="appclient, tck5sec, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
       circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440, 
-      ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree751, ejbthree921, ejbthree936,
+      ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree751, ejbthree921, ejbthree936, ejbthree939,
       aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency, 
       securitydomain, enventry, 
       jms/managed, naming, bmt, jca/inflowmdb, pool, jms, security, reference21_30, factory, dd/web, txexceptions, 
@@ -4027,6 +4048,12 @@
       <antcall target="test" inheritRefs="true">
          <param name="test" value="ejbthree832"/>
       </antcall>
+      <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree936"/>
+      </antcall>
+      <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree939"/>
+      </antcall>
    </target>
 
    <target name="entity-tests" depends="init" description="Execute all tests">

Modified: trunk/ejb3/src/main/org/jboss/ejb/MessageDrivenImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb/MessageDrivenImpl.java	2007-04-05 07:44:47 UTC (rev 62123)
+++ trunk/ejb3/src/main/org/jboss/ejb/MessageDrivenImpl.java	2007-04-05 09:37:21 UTC (rev 62124)
@@ -21,6 +21,7 @@
  */
 package org.jboss.ejb;
 
+import java.lang.annotation.Annotation;
 import java.util.HashMap;
 
 import javax.ejb.MessageDriven;
@@ -40,7 +41,7 @@
    private String desc = "";
    private Class listenerInterface = Object.class;
 
-   private HashMap activationConfigProperties = new HashMap();
+   private HashMap<String, ActivationConfigProperty> activationConfigProperties = new HashMap<String, ActivationConfigProperty>();
 
    public MessageDrivenImpl(String name, ActivationConfigProperty[] activationConfigProperties)
    {
@@ -63,7 +64,7 @@
       return properties;
    }
 
-   public Class annotationType()
+   public Class<? extends Annotation> annotationType()
    {
       return javax.ejb.MessageDriven.class;
    }
@@ -86,6 +87,9 @@
       if (desc.length() == 0)
          desc = annotation.description();
       
+      if(listenerInterface == Object.class)
+         listenerInterface = annotation.messageListenerInterface();
+      
       for (ActivationConfigProperty property : annotation.activationConfig())
       {
          if (!activationConfigProperties.containsKey(property.propertyName()))

Added: trunk/ejb3/src/resources/test/ejbthree939/META-INF/jboss.xml
===================================================================
--- trunk/ejb3/src/resources/test/ejbthree939/META-INF/jboss.xml	                        (rev 0)
+++ trunk/ejb3/src/resources/test/ejbthree939/META-INF/jboss.xml	2007-04-05 09:37:21 UTC (rev 62124)
@@ -0,0 +1,12 @@
+<jboss
+        xmlns="http://java.sun.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                            http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+        version="3.0">
+   <enterprise-beans>
+      <message-driven>
+         <ejb-name>MultiInterfaceMDB</ejb-name>
+      </message-driven>
+   </enterprise-beans>
+</jboss>

Added: trunk/ejb3/src/resources/test/ejbthree939/ejbthree939test-service.xml
===================================================================
--- trunk/ejb3/src/resources/test/ejbthree939/ejbthree939test-service.xml	                        (rev 0)
+++ trunk/ejb3/src/resources/test/ejbthree939/ejbthree939test-service.xml	2007-04-05 09:37:21 UTC (rev 62124)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+   <mbean code="org.jboss.mq.server.jmx.Queue"
+      name="jboss.mq.destination:service=Queue,name=ejbthree939">
+      <attribute name="JNDIName">queue/ejbthree939</attribute>
+      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+   </mbean>
+</server>
\ No newline at end of file

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/DummyInterface.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/DummyInterface.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/DummyInterface.java	2007-04-05 09:37:21 UTC (rev 62124)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree939;
+
+/**
+ * This interface is just a dummy, do not remove though.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface DummyInterface
+{
+
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/MultiInterfaceMDB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/MultiInterfaceMDB.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/MultiInterfaceMDB.java	2007-04-05 09:37:21 UTC (rev 62124)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree939;
+
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+
+/**
+ * This bean has a deployment descriptor which may override the
+ * message listener interface.
+ * 
+ * Implements a dummy interface as well to fool MDB.getMessagingType()
+ * because that made the bug slip past us.
+ * 
+ * Now that getMessagingType can't guess the correct interface, it must
+ * use messageListenerInterface.
+ * 
+ * But this one wasn't set in the deployment descriptor and the one
+ * from the annotation is ignored (/ not merged).
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at MessageDriven(activationConfig =
+        {
+        @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
+        @ActivationConfigProperty(propertyName="destination", propertyValue="queue/ejbthree939")
+        },
+        messageListenerInterface=MessageListener.class)
+public class MultiInterfaceMDB implements MessageListener, DummyInterface
+{
+   @Resource(mappedName="java:/ConnectionFactory")
+   private QueueConnectionFactory qFactory;
+   
+   public void onMessage(Message message)
+   {
+      System.out.println("*** MultiInterfaceMDB onMessage");
+      
+      try
+      {
+         if(message.getJMSReplyTo() != null)
+            sendReply((Queue) message.getJMSReplyTo(), message.getJMSMessageID());
+      }
+      catch(JMSException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   private void sendReply(Queue destination, String messageID) throws JMSException
+   {
+      QueueConnection conn = qFactory.createQueueConnection();
+      try
+      {
+         QueueSession session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+         QueueSender sender = session.createSender(destination);
+         TextMessage message = session.createTextMessage("SUCCESS");
+         message.setJMSCorrelationID(messageID);
+         sender.send(message, DeliveryMode.NON_PERSISTENT, 4, 500);
+      }
+      finally
+      {
+         conn.close();
+      }
+   }
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/unit/MultiInterfaceMDBTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/unit/MultiInterfaceMDBTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/ejbthree939/unit/MultiInterfaceMDBTestCase.java	2007-04-05 09:37:21 UTC (rev 62124)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.ejbthree939.unit;
+
+import javax.jms.DeliveryMode;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Test a MDB which uses messageListenerInterface.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MultiInterfaceMDBTestCase extends JBossTestCase
+{
+
+   public MultiInterfaceMDBTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void test1() throws Exception
+   {
+      QueueConnectionFactory qFactory = (QueueConnectionFactory) getInitialContext().lookup("ConnectionFactory");
+      QueueConnection conn = qFactory.createQueueConnection();
+      try
+      {
+         QueueSession session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+         
+         Queue replyQueue = session.createTemporaryQueue();
+         MessageConsumer consumer = session.createConsumer(replyQueue);
+         conn.start();
+         
+         Queue sendQueue = (Queue) getInitialContext().lookup("queue/ejbthree939");
+         QueueSender sender = session.createSender(sendQueue);
+         TextMessage message = session.createTextMessage("Hello world");
+         message.setJMSReplyTo(replyQueue);
+//         sender.send(message);
+         sender.send(message, DeliveryMode.NON_PERSISTENT, 4, 500);
+         
+         TextMessage reply = (TextMessage) consumer.receive(1000);
+         assertNotNull("No reply received", reply);
+         assertEquals("SUCCESS", reply.getText());
+         
+         conn.stop();
+      }
+      finally
+      {
+         conn.close();
+      }
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MultiInterfaceMDBTestCase.class, "ejbthree939test-service.xml,ejbthree939.jar");
+   }
+
+}




More information about the jboss-cvs-commits mailing list