[jboss-cvs] JBossAS SVN: r76819 - in trunk: connector/src/resources/jms-rar/META-INF and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 8 07:04:20 EDT 2008


Author: jesper.pedersen
Date: 2008-08-08 07:04:20 -0400 (Fri, 08 Aug 2008)
New Revision: 76819

Added:
   trunk/testsuite/src/main/org/jboss/test/messagedriven/test/SimpleQueueMessageDrivenNoDestinationTypeUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/messagedriven/test/SimpleTopicMessageDrivenNoDestinationTypeUnitTestCase.java
Modified:
   trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java
   trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivationSpec.java
   trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSessionPool.java
   trunk/connector/src/resources/jms-rar/META-INF/ra.xml
   trunk/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java
Log:
[JBAS-5841] Allow the JMS RAR to determine the destinationType at runtime

Modified: trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java	2008-08-08 11:00:32 UTC (rev 76818)
+++ trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivation.java	2008-08-08 11:04:20 UTC (rev 76819)
@@ -58,6 +58,7 @@
  * A generic jms Activation.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
  * @version $Revision$
  */
 public class JmsActivation implements ExceptionListener
@@ -106,6 +107,9 @@
    
    /** The destination */
    protected Destination destination;
+
+   /** The destination type */
+   protected boolean isTopic = false;
    
    /** The connection */
    protected Connection connection;
@@ -206,6 +210,14 @@
    {
       return destination;
    }
+
+   /**
+    * @return the destination type
+    */
+   public boolean isTopic()
+   {
+      return isTopic;
+   }
    
    /**
     * @return the provider adapter 
@@ -430,15 +442,39 @@
     */
    protected void setupDestination(Context ctx) throws Exception
    {
-      Class<?> destinationType;
-      if (spec.isTopic())
-         destinationType = Topic.class;
+      String destinationName = spec.getDestination();
+
+      String destinationTypeString = spec.getDestinationType();
+      if (destinationTypeString != null && !destinationTypeString.trim().equals(""))
+      {
+         log.debug("Destination type defined as " + destinationTypeString);
+
+         Class<?> destinationType;
+         if (Topic.class.getName().equals(destinationTypeString))
+         {
+            destinationType = Topic.class;
+            isTopic = true;
+         }
+         else
+         {
+            destinationType = Queue.class;
+         }
+
+         log.debug("Retrieving destination " + destinationName + " of type " + destinationType.getName());
+         destination = (Destination) Util.lookup(ctx, destinationName, destinationType);
+      }
       else
-         destinationType = Queue.class;
+      {
+         log.debug("Destination type not defined");
+         log.debug("Retrieving destination " + destinationName + " of type " + Destination.class.getName());
 
-      String destinationName = spec.getDestination();
-      log.debug("Retrieving destination " + destinationName + " of type " + destinationType.getName());
-      destination = (Destination) Util.lookup(ctx, destinationName, destinationType);
+         destination = (Destination) Util.lookup(ctx, destinationName, Destination.class);
+         if (destination instanceof Topic)
+         {
+            isTopic = true;
+         }
+      }
+
       log.debug("Got destination " + destination + " from " + destinationName);
    }
    
@@ -463,7 +499,8 @@
       String user = spec.getUser();
       String pass = spec.getPassword();
       String clientID = spec.getClientId();
-      if (spec.isTopic())
+
+      if (isTopic)
          connection = setupTopicConnection(ctx, user, pass, clientID);
       else
          connection = setupQueueConnection(ctx, user, pass, clientID);

Modified: trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivationSpec.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivationSpec.java	2008-08-08 11:00:32 UTC (rev 76818)
+++ trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsActivationSpec.java	2008-08-08 11:04:20 UTC (rev 76819)
@@ -21,9 +21,7 @@
  */
 package org.jboss.resource.adapter.jms.inflow;
 
-import javax.jms.Queue;
 import javax.jms.Session;
-import javax.jms.Topic;
 import javax.resource.ResourceException;
 import javax.resource.spi.ActivationSpec;
 import javax.resource.spi.InvalidPropertyException;
@@ -36,6 +34,7 @@
  * A generic jms ActivationSpec.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="jesper.pedersen at jboss.org">Jesper Pedersen</a>
  * @version $Revision$
  */
 public class JmsActivationSpec implements ActivationSpec
@@ -50,7 +49,7 @@
    private String destination;
 
    /** The destination type */
-   private boolean isTopic = false;
+   private String destinationType;
 
    /** The message selector */
    private String messageSelector;
@@ -235,10 +234,7 @@
     */
    public String getDestinationType()
    {
-      if (isTopic)
-         return Topic.class.getName();
-      else
-         return Queue.class.getName();
+      return destinationType;
    }
 
    /**
@@ -246,21 +242,10 @@
     */
    public void setDestinationType(String destinationType)
    {
-      if (Topic.class.getName().equals(destinationType))
-         this.isTopic = true;
-      else
-         this.isTopic = false;
+      this.destinationType = destinationType;
    }
 
    /**
-    * @return whether this is for a topic.
-    */
-   public boolean isTopic()
-   {
-      return isTopic;
-   }
-
-   /**
     * @return the messageSelector.
     */
    public String getMessageSelector()
@@ -655,7 +640,7 @@
       buffer.append(Strings.defaultToString(this)).append('(');
       buffer.append("ra=").append(ra);
       buffer.append(" destination=").append(destination);
-      buffer.append(" isTopic=").append(isTopic);
+      buffer.append(" destinationType=").append(destinationType);
       if (messageSelector != null)
          buffer.append(" selector=").append(messageSelector);
       buffer.append(" tx=").append(sessionTransacted);
@@ -730,5 +715,4 @@
    {
       this.isSameRMOverrideValue = isSameRMOverrideValue;
    }
-
 }

Modified: trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSessionPool.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSessionPool.java	2008-08-08 11:00:32 UTC (rev 76818)
+++ trunk/connector/src/main/org/jboss/resource/adapter/jms/inflow/JmsServerSessionPool.java	2008-08-08 11:04:20 UTC (rev 76819)
@@ -274,7 +274,7 @@
       JmsActivationSpec spec = activation.getActivationSpec();
       String selector = spec.getMessageSelector();
       int maxMessages = spec.getMaxMessagesInt();
-      if (spec.isTopic())
+      if (activation.isTopic())
       {
          Topic topic = (Topic) activation.getDestination();
          String subscriptionName = spec.getSubscriptionName();

Modified: trunk/connector/src/resources/jms-rar/META-INF/ra.xml
===================================================================
--- trunk/connector/src/resources/jms-rar/META-INF/ra.xml	2008-08-08 11:00:32 UTC (rev 76818)
+++ trunk/connector/src/resources/jms-rar/META-INF/ra.xml	2008-08-08 11:04:20 UTC (rev 76819)
@@ -108,9 +108,6 @@
                   <required-config-property>
                       <config-property-name>destination</config-property-name>
                   </required-config-property>
-                  <required-config-property>
-                      <config-property-name>destinationType</config-property-name>
-                  </required-config-property>
                </activationspec>
             </messagelistener>
          </messageadapter>

Modified: trunk/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java	2008-08-08 11:00:32 UTC (rev 76818)
+++ trunk/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java	2008-08-08 11:04:20 UTC (rev 76819)
@@ -59,9 +59,11 @@
 
    protected static ObjectName testQueue = ObjectNameFactory.create("jboss.mq.destination:service=Queue,name=testQueue");
    protected static Properties testQueueProps = new Properties();
+   protected static Properties testQueueNoDestinationTypeProps = new Properties();
    
    protected static ObjectName testTopic = ObjectNameFactory.create("jboss.mq.destination:service=Topic,name=testTopic");
    protected static Properties testTopicProps = new Properties();
+   protected static Properties testTopicNoDestinationTypeProps = new Properties();
    
    protected static ObjectName testDurableTopic = ObjectNameFactory.create("jboss.mq.destination:service=Topic,name=testDurableTopic");
    protected static Properties testDurableTopicProps = new Properties();
@@ -98,9 +100,15 @@
       testQueueProps.put("destination", "queue/testQueue");
       testQueueProps.put("destinationType", "javax.jms.Queue");
 
+      testQueueNoDestinationTypeProps.put("destination", "queue/testQueue");
+      testQueueNoDestinationTypeProps.put("destinationType", "");
+
       testTopicProps.put("destination", "topic/testTopic");
       testTopicProps.put("destinationType", "javax.jms.Topic");
 
+      testTopicNoDestinationTypeProps.put("destination", "topic/testTopic");
+      testTopicNoDestinationTypeProps.put("destinationType", "");
+
       testDurableTopicProps.put("destination", "topic/testDurableTopic");
       testDurableTopicProps.put("destinationType", "javax.jms.Topic");
       //testDurableTopicProps.put("clientID", "DurableSubscriberExample");

Added: trunk/testsuite/src/main/org/jboss/test/messagedriven/test/SimpleQueueMessageDrivenNoDestinationTypeUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/messagedriven/test/SimpleQueueMessageDrivenNoDestinationTypeUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/messagedriven/test/SimpleQueueMessageDrivenNoDestinationTypeUnitTestCase.java	2008-08-08 11:04:20 UTC (rev 76819)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.messagedriven.test;
+
+import org.jboss.test.messagedriven.support.SimpleMessageDrivenUnitTest;
+
+/**
+ * Basic tests of message driven beans with no destination type specified as it is now
+ * optional.
+ *
+ * The destinationType will be an empty string such that the JmsActivation
+ * must resolve the property based on the deployed destination.
+ *
+ * Based on SimpleQueueMessageDrivenUnitTestCase by Adrian Brock.
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version <tt>$Revision: 1.4</tt>
+ */
+public class SimpleQueueMessageDrivenNoDestinationTypeUnitTestCase extends SimpleMessageDrivenUnitTest
+{
+   public SimpleQueueMessageDrivenNoDestinationTypeUnitTestCase(String name)
+   {
+      super(name, testQueue, testQueueNoDestinationTypeProps);
+   }
+}

Added: trunk/testsuite/src/main/org/jboss/test/messagedriven/test/SimpleTopicMessageDrivenNoDestinationTypeUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/messagedriven/test/SimpleTopicMessageDrivenNoDestinationTypeUnitTestCase.java	                        (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/messagedriven/test/SimpleTopicMessageDrivenNoDestinationTypeUnitTestCase.java	2008-08-08 11:04:20 UTC (rev 76819)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.messagedriven.test;
+
+import org.jboss.test.messagedriven.support.SimpleMessageDrivenUnitTest;
+
+/**
+ * Basic tests of message driven beans with no destination type specified as it is now
+ * optional.
+ *
+ * The destinationType will be an empty string such that the JmsActivation
+ * must resolve the property based on the deployed destination.
+ *
+ * Based on SimpleTopicMessageDrivenUnitTestCase by Adrian Brock.
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ * @version <tt>$Revision: 1.4</tt>
+ */
+public class SimpleTopicMessageDrivenNoDestinationTypeUnitTestCase extends SimpleMessageDrivenUnitTest
+{
+   public SimpleTopicMessageDrivenNoDestinationTypeUnitTestCase(String name)
+   {
+      super(name, testTopic, testTopicNoDestinationTypeProps);
+   }
+}




More information about the jboss-cvs-commits mailing list