[jboss-cvs] JBossAS SVN: r95910 - in branches/JBPAPP_5_0: testsuite/imports/sections and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Nov 2 05:58:24 EST 2009


Author: jaikiran
Date: 2009-11-02 05:58:24 -0500 (Mon, 02 Nov 2009)
New Revision: 95910

Added:
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/SimpleMDBForQueueCreation.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/SimpleMDBForTopicCreation.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/unit/
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/unit/AutoCreateDestinationForMDBTestCase.java
   branches/JBPAPP_5_0/testsuite/src/resources/ejb3/jbpapp3026/
   branches/JBPAPP_5_0/testsuite/src/resources/ejb3/jbpapp3026/META-INF/
   branches/JBPAPP_5_0/testsuite/src/resources/ejb3/jbpapp3026/META-INF/jboss.xml
Modified:
   branches/JBPAPP_5_0/messaging/src/main/org/jboss/jms/server/destination/JBossMessagingCreateDestinationFactory.java
   branches/JBPAPP_5_0/testsuite/imports/sections/ejb3.xml
Log:
JBPAPP-3026 Auto creation of destinations for EJB3 MDBs will now replace the forward slashes with dot character to keep JBoss Messaging happy

Modified: branches/JBPAPP_5_0/messaging/src/main/org/jboss/jms/server/destination/JBossMessagingCreateDestinationFactory.java
===================================================================
--- branches/JBPAPP_5_0/messaging/src/main/org/jboss/jms/server/destination/JBossMessagingCreateDestinationFactory.java	2009-11-02 10:19:55 UTC (rev 95909)
+++ branches/JBPAPP_5_0/messaging/src/main/org/jboss/jms/server/destination/JBossMessagingCreateDestinationFactory.java	2009-11-02 10:58:24 UTC (rev 95910)
@@ -110,7 +110,7 @@
    
    public Object create(DeploymentUnit unit, JBossMessageDrivenBeanMetaData mdb) throws DeploymentException
    {
-      String destinationName = null;
+      String destinationJNDIName = null;
       String destinationType = null;
       
       ActivationConfigMetaData activationConfig = mdb.getActivationConfig();
@@ -119,14 +119,14 @@
          ActivationConfigPropertiesMetaData properties = activationConfig.getActivationConfigProperties();
          if (properties != null)
          {
-            destinationName = getActivationConfigProperty(properties, "destination");
+            destinationJNDIName = getActivationConfigProperty(properties, "destination");
             destinationType = getActivationConfigProperty(properties, "destinationType");
          }
       }
 
       // TODO message-destination-link?
       
-      if (destinationName == null || destinationName.trim().length() == 0)
+      if (destinationJNDIName == null || destinationJNDIName.trim().length() == 0)
       {
          log.warn("Unable to determine destination for " + mdb.getName());
          return null;
@@ -154,6 +154,8 @@
       ServiceMetaData result = new ServiceMetaData();
       result.setConstructor(new ServiceConstructorMetaData());
       ObjectName objectName;
+      // See https://jira.jboss.org/jira/browse/JBPAPP-3026
+      String destinationName = this.createDestinationNameFromJNDIName(destinationJNDIName);
       if (isTopic)
       {
          objectName = ObjectNameFactory.create("jboss.messaging.destination:service=Topic,name=" + destinationName);
@@ -170,7 +172,7 @@
       
       ServiceAttributeMetaData attribute = new ServiceAttributeMetaData();
       attribute.setName("JNDIName");
-      attribute.setValue(new ServiceTextValueMetaData(destinationName));
+      attribute.setValue(new ServiceTextValueMetaData(destinationJNDIName));
       result.addAttribute(attribute);
 
       attribute = new ServiceAttributeMetaData();
@@ -212,4 +214,25 @@
          return null;
       return property.getValue();
    }
+   
+   /**
+    * JBoss Messaging does not allow the use of forward slashes in the destination name (which is used in the 
+    * MBean ObjectName for the destination). However, the destination *jndi* name is allowed to have forward
+    * slashes. So create a proper destination name out of the destination *jndi* name.
+    * See https://jira.jboss.org/jira/browse/JBPAPP-3026 for more details
+    * 
+    * This method, just replaces all the forward slashes with a dot.
+    * 
+    * @param destinationJNDIName The jndi name of the destination
+    * @return Returns the destination name, created out of the destination jndi name.
+    *   Returns null if the <code>destinationJNDIName</code> is null.
+    */
+   private String createDestinationNameFromJNDIName(String destinationJNDIName)
+   {
+      if (destinationJNDIName == null)
+      {
+         return null;
+      }
+      return destinationJNDIName.replace('/', '.');
+   }
 }

Modified: branches/JBPAPP_5_0/testsuite/imports/sections/ejb3.xml
===================================================================
--- branches/JBPAPP_5_0/testsuite/imports/sections/ejb3.xml	2009-11-02 10:19:55 UTC (rev 95909)
+++ branches/JBPAPP_5_0/testsuite/imports/sections/ejb3.xml	2009-11-02 10:58:24 UTC (rev 95910)
@@ -75,6 +75,17 @@
       </jar>
    </target>
    
+   <target name="jbpapp3026" depends="compile">
+      <mkdir dir="${build.lib}" />
+      
+      <jar destfile="${build.lib}/createdestination-mdb.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/test/ejb3/jbpapp3026/**" />
+         </fileset>
+         <fileset dir="${build.resources}/ejb3/jbpapp3026" includes="**"/>
+      </jar>
+   </target>
+   
    <!-- This issue affected the ejb3 AS module -->
    <target name="ejbthree1597" depends="compile">
       <mkdir dir="${build.lib}"/>
@@ -158,7 +169,8 @@
    <target name="_jars-ejb3" depends="ejb3-servlet,jbas6161,jbas6239,ejbthree1597,jbas5713,
       ejb3-webservice,
       jbpapp2260,
-      jbpapp2473
+      jbpapp2473,
+      jbpapp3026
       ">
       <mkdir dir="${build.lib}" />
 

Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/SimpleMDBForQueueCreation.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/SimpleMDBForQueueCreation.java	                        (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/SimpleMDBForQueueCreation.java	2009-11-02 10:58:24 UTC (rev 95910)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ejb3.jbpapp3026;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import org.jboss.logging.Logger;
+
+/**
+ * SimpleMDBForQueueCreation
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at MessageDriven(activationConfig =
+{
+   @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
+   @ActivationConfigProperty(propertyName="destination", propertyValue="queue/create-destination/testQueue")
+})
+public class SimpleMDBForQueueCreation implements MessageListener
+{
+
+   private static Logger logger = Logger.getLogger(SimpleMDBForTopicCreation.class);
+   
+   public void onMessage(Message arg0)
+   {
+      logger.info("Received message " + arg0);
+      
+   }
+
+}

Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/SimpleMDBForTopicCreation.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/SimpleMDBForTopicCreation.java	                        (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/SimpleMDBForTopicCreation.java	2009-11-02 10:58:24 UTC (rev 95910)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ejb3.jbpapp3026;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import org.jboss.logging.Logger;
+
+/**
+ * SimpleMDBForTopicCreation
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at MessageDriven(activationConfig =
+{
+   @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Topic"),
+   @ActivationConfigProperty(propertyName="destination", propertyValue="topic/create-destination/testTopic")
+})
+public class SimpleMDBForTopicCreation implements MessageListener
+{
+   private static Logger logger = Logger.getLogger(SimpleMDBForTopicCreation.class);
+   
+   public void onMessage(Message arg0)
+   {
+      logger.info("Received message " + arg0);
+      
+   }
+
+}

Added: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/unit/AutoCreateDestinationForMDBTestCase.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/unit/AutoCreateDestinationForMDBTestCase.java	                        (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/ejb3/jbpapp3026/unit/AutoCreateDestinationForMDBTestCase.java	2009-11-02 10:58:24 UTC (rev 95910)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.test.ejb3.jbpapp3026.unit;
+
+import javax.jms.Queue;
+import javax.jms.Topic;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestCase;
+
+/**
+ * AutoCreateDestinationForMDBTestCase
+ * 
+ * Tests that destinations which are set to be auto created (through the use of 
+ * "create-destination" on the MDB) are created successfully, when the
+ * destination jndi name has forward slashes.
+ * 
+ * See https://jira.jboss.org/jira/browse/JBPAPP-3026 for details
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class AutoCreateDestinationForMDBTestCase extends JBossTestCase
+{
+
+   /**
+    * Constructor
+    * @param name
+    */
+   public AutoCreateDestinationForMDBTestCase(String name)
+   {
+      super(name);
+   }
+
+   /**
+    * 
+    * @return
+    * @throws Exception
+    */
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(AutoCreateDestinationForMDBTestCase.class, "createdestination-mdb.jar");
+   }
+   
+   /**
+    * Tests that a queue containing forward slashes in it's destination jndi name 
+    * is correctly created.
+    * 
+    * @throws Exception
+    */
+   public void testQueueCreationForMDB() throws Exception
+   {
+      // make sure the deployment was deployed successfully
+      serverFound();
+      // lookup queue
+      // successful lookup, in itself should be sufficient enough to prove that 
+      // the queue was created by the "create-destination" activation config property
+      // of the MDB
+      Queue queue = (Queue) this.getInitialContext().lookup("queue/create-destination/testQueue");
+      assertNotNull("Queue lookup returned null", queue);
+   }
+   
+   /**
+    * Tests that a topic containing forward slashes in it's destination jndi name 
+    * is correctly created.
+    * 
+    * @throws Exception
+    */
+   public void testTopicCreationForMDB() throws Exception
+   {
+      // make sure the deployment was deployed successfully
+      serverFound();
+      // lookup topic
+      // successful lookup, in itself should be sufficient enough to prove that 
+      // the topic was created by the "create-destination" activation config property
+      // of the MDB
+      Topic topic = (Topic) this.getInitialContext().lookup("topic/create-destination/testTopic");
+      assertNotNull("Topic lookup returned null", topic);
+   }
+}

Added: branches/JBPAPP_5_0/testsuite/src/resources/ejb3/jbpapp3026/META-INF/jboss.xml
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/resources/ejb3/jbpapp3026/META-INF/jboss.xml	                        (rev 0)
+++ branches/JBPAPP_5_0/testsuite/src/resources/ejb3/jbpapp3026/META-INF/jboss.xml	2009-11-02 10:58:24 UTC (rev 95910)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<jboss
+        xmlns="http://www.jboss.com/xml/ns/javaee"
+        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee
+                            http://www.jboss.org/j2ee/schema/jboss_5_0.xsd"
+        version="3.0">
+   <enterprise-beans>
+      <message-driven>
+         <ejb-name>SimpleMDBForTopicCreation</ejb-name>
+         <create-destination>true</create-destination>
+      </message-driven>
+      <message-driven>
+         <ejb-name>SimpleMDBForQueueCreation</ejb-name>
+         <create-destination>true</create-destination>
+      </message-driven>
+   </enterprise-beans>
+</jboss>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list