[jboss-cvs] JBossAS SVN: r65615 - in branches/JBPAPP_4_2: server/src/etc/conf/default and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Sep 25 18:14:01 EDT 2007


Author: clebert.suconic at jboss.com
Date: 2007-09-25 18:14:01 -0400 (Tue, 25 Sep 2007)
New Revision: 65615

Modified:
   branches/JBPAPP_4_2/build/build-distr.xml
   branches/JBPAPP_4_2/server/src/etc/conf/default/standardjboss.xml
   branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
Log:
JBAS-4591 and JBPAPP-349 - dynamic destinations on MDBs

Modified: branches/JBPAPP_4_2/build/build-distr.xml
===================================================================
--- branches/JBPAPP_4_2/build/build-distr.xml	2007-09-25 22:12:46 UTC (rev 65614)
+++ branches/JBPAPP_4_2/build/build-distr.xml	2007-09-25 22:14:01 UTC (rev 65615)
@@ -552,6 +552,12 @@
         <include name="**"/>
       </fileset>
     </copy>
+  	
+  	<replace file="${install.server}/${target}/conf/standardjboss.xml">
+	  	<replacefilter token="jboss.mq:service=DestinationManager" value="jboss.messaging:service=ServerPeer"/>
+	  	<replacefilter token="&gt;createTopic&lt;" value="&gt;deployTopic&lt;"/>
+	  	<replacefilter token="&gt;createQueue&lt;" value="&gt;deployQueue&lt;"/>
+  	</replace>
 
   	
   	<delete dir="${install.server}/${target}/deploy/jms"/>

Modified: branches/JBPAPP_4_2/server/src/etc/conf/default/standardjboss.xml
===================================================================
--- branches/JBPAPP_4_2/server/src/etc/conf/default/standardjboss.xml	2007-09-25 22:12:46 UTC (rev 65614)
+++ branches/JBPAPP_4_2/server/src/etc/conf/default/standardjboss.xml	2007-09-25 22:14:01 UTC (rev 65615)
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!DOCTYPE jboss PUBLIC
-   "-//JBoss//DTD JBOSS 4.0//EN"
-   "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
+   "-//JBoss//DTD JBOSS 4.2//EN"
+   "http://www.jboss.org/j2ee/dtd/jboss_4_2.dtd">
 
 <!-- ===================================================================== -->
 <!--  Standard JBoss EJB Configurations                                    -->
@@ -358,7 +358,12 @@
       <proxy-factory-config>
         <JMSProviderAdapterJNDI>DefaultJMSProvider</JMSProviderAdapterJNDI>
         <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
-        <CreateJBossMQDestination>true</CreateJBossMQDestination>
+        <!--   Deprecated parameter (still supported for backward compatibility)
+        <CreateJBossMQDestination>true</CreateJBossMQDestination> -->
+        <CreateDestination>true</CreateDestination>
+        <DestinationManager>jboss.mq:service=DestinationManager</DestinationManager>
+        <CreateTopicMethod>createTopic</CreateTopicMethod>
+        <CreateQueueMethod>createQueue</CreateQueueMethod>
         <!-- WARN: Don't set this to zero until a bug in the pooled executor is fixed -->
         <MinimumSize>1</MinimumSize>
         <MaximumSize>15</MaximumSize>
@@ -440,7 +445,12 @@
       <proxy-factory-config>
         <JMSProviderAdapterJNDI>DefaultJMSProvider</JMSProviderAdapterJNDI>
         <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
-        <CreateJBossMQDestination>true</CreateJBossMQDestination>
+        <!--   Deprecated parameter (still supported for backward compatibility)
+        <CreateJBossMQDestination>true</CreateJBossMQDestination> -->
+        <CreateDestination>true</CreateDestination>
+        <DestinationManager>jboss.mq:service=DestinationManager</DestinationManager>
+        <CreateTopicMethod>createTopic</CreateTopicMethod>
+        <CreateQueueMethod>createQueue</CreateQueueMethod>
         <!-- WARN: Don't set this to zero until a bug in the pooled executor is fixed -->
         <MinimumSize>1</MinimumSize>
         <MaximumSize>1</MaximumSize>

Modified: branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java
===================================================================
--- branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java	2007-09-25 22:12:46 UTC (rev 65614)
+++ branches/JBPAPP_4_2/server/src/main/org/jboss/ejb/plugins/jms/JMSContainerInvoker.java	2007-09-25 22:14:01 UTC (rev 65615)
@@ -190,7 +190,13 @@
 
    protected boolean deliveryActive = true;
 
-   protected boolean createJBossMQDestination = true;
+   protected boolean createDestination = true;
+   
+   protected String destinationManager = "jboss.mq:service=DestinationManager";
+   
+   protected String createTopicMethod = "createTopic";
+   
+   protected String createQueueMethod = "createQueue";
 
    /**
     * Set the invoker meta data so that the ProxyFactory can initialize
@@ -273,7 +279,7 @@
 
    public boolean getCreateJBossMQDestination()
    {
-      return createJBossMQDestination;
+      return createDestination;
    }
 
    public void startDelivery()
@@ -363,15 +369,45 @@
       {
          if ("false".equalsIgnoreCase(MetaData.getElementContent(MetaData.getUniqueChild(element, "CreateJBossMQDestination"))))
          {
-            createJBossMQDestination = false;
+            createDestination = false;
          }
       }
       catch (Exception ignore)
       {
       }
       
+      
       try
       {
+         if ("false".equalsIgnoreCase(MetaData.getElementContent(MetaData.getUniqueChild(element, "CreateDestination"))))
+         {
+            createDestination = false;
+         }
+      }
+      catch (Exception ignore)
+      {
+      }
+      
+	  String localDestination = getValue(element, "DestinationManager");
+	  if (localDestination!=null)
+	  {
+		  destinationManager = localDestination;
+	  }  	  
+      
+	  String localMethod = getValue(element, "CreateTopicMethod");
+	  if (localMethod!=null)
+	  {
+		  createTopicMethod = localMethod;
+	  }  	  
+
+	  localMethod = getValue(element, "CreateQueueMethod");
+	  if (localMethod!=null)
+	  {
+		  createQueueMethod = localMethod;
+	  }  	  
+      
+      try
+      {
          String maxMessages = MetaData.getElementContent
             (MetaData.getUniqueChild(element, "MaxMessages"));
          maxMessagesNr = Integer.parseInt(maxMessages);
@@ -463,6 +499,27 @@
          serverSessionPoolFactoryJNDI = "java:/" + serverSessionPoolFactoryJNDI;
       }
    }
+   
+   private String getValue(Element element, String name)
+   {
+	  try
+	  {
+	 	  Element elementValue = MetaData.getUniqueChild(element, name);
+	 	  
+	 	  if (elementValue!=null)
+	 	  {
+	 		 return MetaData.getElementContent(elementValue);
+	 	  }
+	 	  else
+	 	  {
+	 	 	  return null;
+	 	  }
+	  }
+	  catch (Exception ignored)
+	  {
+		  return null;
+	  }
+   }
 
    /**
     * Initialize the container invoker. Sets up a connection, a server session
@@ -639,13 +696,13 @@
                // First we try the specified topic
                if (destinationJNDI != null)
                   topic = (Topic) context.lookup(destinationJNDI);
-               else if (createJBossMQDestination == false)
+               else if (createDestination == false)
                   throw new DeploymentException("Unable to determine destination for '" + container.getBeanMetaData().getEjbName()
                         + "' use destination-jndi-name in jboss.xml, an activation config property or a message-destination-link");
             }
             catch (NamingException e)
             {
-               if (createJBossMQDestination == false)
+               if (createDestination == false)
                   throw new DeploymentException("Could not find the topic destination-jndi-name=" + destinationJNDI, e);
                log.warn("Could not find the topic destination-jndi-name=" + destinationJNDI, e);
             }
@@ -654,7 +711,6 @@
                throw new DeploymentException("Expected a Topic destination-jndi-name=" + destinationJNDI, e);
             }
 
-            // FIXME: This is not portable, only works for JBossMQ
             if (topic == null)
                topic = (Topic) createDestination(Topic.class,
                   context,
@@ -757,13 +813,13 @@
                // First we try the specified queue
                if (destinationJNDI != null)
                   queue = (Queue) context.lookup(destinationJNDI);
-               else if (createJBossMQDestination == false)
+               else if (createDestination == false)
                   throw new DeploymentException("Unable to determine destination for '" + container.getBeanMetaData().getEjbName()
                         + "' use destination-jndi-name in jboss.xml, an activation config property or a message-destination-link");
             }
             catch (NamingException e)
             {
-               if (createJBossMQDestination == false)
+               if (createDestination == false)
                   throw new DeploymentException("Could not find the queue destination-jndi-name=" + destinationJNDI, e);
                log.warn("Could not find the queue destination-jndi-name=" + destinationJNDI);
             }
@@ -772,7 +828,6 @@
                throw new DeploymentException("Expected a Queue destination-jndi-name=" + destinationJNDI);
             }
 
-            // FIXME: This is not portable, only works for JBossMQ
             if (queue == null)
                queue = (Queue) createDestination(Queue.class,
                   context,
@@ -1096,11 +1151,11 @@
          String methodName;
          if (type == Topic.class)
          {
-            methodName = "createTopic";
+            methodName = createTopicMethod;
          }
          else if (type == Queue.class)
          {
-            methodName = "createQueue";
+            methodName = createQueueMethod;
          }
          else
          {
@@ -1109,11 +1164,24 @@
                ("Expected javax.jms.Queue or javax.jms.Topic: " + type);
          }
 
-         // invoke the server to create the destination
-         server.invoke(new ObjectName("jboss.mq:service=DestinationManager"),
-            methodName,
-            new Object[]{jndiSuffix},
-            new String[]{"java.lang.String"});
+         try
+         {
+	         // invoke the server to create the destination
+	         server.invoke(new ObjectName(destinationManager),
+	            methodName,
+	            new Object[]{jndiSuffix},
+	            new String[]{"java.lang.String"});
+         }
+         catch (javax.management.ReflectionException exRefl)
+         {
+        	 log.debug("Using alternate signature (name, jndiName)");
+        	 // invoke the server to create the destination
+	         server.invoke(new ObjectName(destinationManager),
+	            methodName,
+	            new Object[]{jndiSuffix, jndiName},
+	            new String[]{"java.lang.String", "java.lang.String"});
+        	 
+         }
          
          // try to look it up again
          return (Destination) ctx.lookup(jndiName);




More information about the jboss-cvs-commits mailing list