[jboss-cvs] JBossAS SVN: r58397 - in trunk/ejb3/src/main/org/jboss/ejb3: . jms mdb

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Nov 15 09:02:04 EST 2006


Author: wolfc
Date: 2006-11-15 09:01:58 -0500 (Wed, 15 Nov 2006)
New Revision: 58397

Added:
   trunk/ejb3/src/main/org/jboss/ejb3/jms/
   trunk/ejb3/src/main/org/jboss/ejb3/jms/JMSDestinationFactory.java
   trunk/ejb3/src/main/org/jboss/ejb3/jms/ServerPeerJMSDestinationFactory.java
   trunk/ejb3/src/main/org/jboss/ejb3/jms/package.html
Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
Log:
refactored JMS destination creation

Added: trunk/ejb3/src/main/org/jboss/ejb3/jms/JMSDestinationFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/jms/JMSDestinationFactory.java	2006-11-15 13:49:52 UTC (rev 58396)
+++ trunk/ejb3/src/main/org/jboss/ejb3/jms/JMSDestinationFactory.java	2006-11-15 14:01:58 UTC (rev 58397)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.jms;
+
+import javax.jms.Destination;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class JMSDestinationFactory
+{
+   private static final JMSDestinationFactory instance = new ServerPeerJMSDestinationFactory();
+   
+   public static JMSDestinationFactory getInstance()
+   {
+      // TODO: implement proper plugin point
+      return instance;
+   }
+   
+   public abstract void createDestination(Class<? extends Destination> type, String jndiSuffix) throws Exception;
+}

Added: trunk/ejb3/src/main/org/jboss/ejb3/jms/ServerPeerJMSDestinationFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/jms/ServerPeerJMSDestinationFactory.java	2006-11-15 13:49:52 UTC (rev 58396)
+++ trunk/ejb3/src/main/org/jboss/ejb3/jms/ServerPeerJMSDestinationFactory.java	2006-11-15 14:01:58 UTC (rev 58397)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.jms;
+
+import javax.jms.Destination;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.management.ObjectName;
+
+import org.jboss.ejb3.KernelAbstraction;
+import org.jboss.ejb3.KernelAbstractionFactory;
+import org.jboss.logging.Logger;
+
+/**
+ * Use ServerPeer for creation of destinations.
+ * 
+ * JBoss AS 5.0
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ServerPeerJMSDestinationFactory extends JMSDestinationFactory
+{
+   private static final Logger log = Logger.getLogger(ServerPeerJMSDestinationFactory.class);
+   
+   // Do not instantiate outside package
+   ServerPeerJMSDestinationFactory()
+   {
+      
+   }
+   
+   public void createDestination(Class<? extends Destination> type, String jndiSuffix) throws Exception
+   {
+      String methodName;
+      String destinationContext;
+      if (type == Topic.class)
+      {
+         destinationContext = "topic";
+         methodName = "createTopic";
+      }
+      else if (type == Queue.class)
+      {
+         destinationContext = "queue";
+         methodName = "createQueue";
+      }
+      else
+      {
+         // type was not a Topic or Queue, bad user
+         throw new IllegalArgumentException
+                 ("Expected javax.jms.Queue or javax.jms.Topic: " + type);
+      }
+      
+      String name = jndiSuffix;
+      String jndiName = destinationContext + "/" + jndiSuffix;
+      
+      ObjectName serverPeerName = new ObjectName("jboss.messaging:service=ServerPeer");
+      
+      KernelAbstraction kernel = KernelAbstractionFactory.getInstance();
+      // invoke the server to create the destination
+      Object result = kernel.invoke(serverPeerName,
+              methodName,
+              new Object[]{name, jndiName},
+              new String[]{"java.lang.String", "java.lang.String"});
+      
+      log.info("result = " + result);
+   }
+}

Added: trunk/ejb3/src/main/org/jboss/ejb3/jms/package.html
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/jms/package.html	2006-11-15 13:49:52 UTC (rev 58396)
+++ trunk/ejb3/src/main/org/jboss/ejb3/jms/package.html	2006-11-15 14:01:58 UTC (rev 58397)
@@ -0,0 +1,8 @@
+<html>
+	<head>
+		<title>org.jboss.ejb3.jms</title>
+	</head>
+	<body>
+		This package provides a custom JBoss interface to JBoss Messaging.
+	</body>
+</html>
\ No newline at end of file

Modified: trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2006-11-15 13:49:52 UTC (rev 58396)
+++ trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2006-11-15 14:01:58 UTC (rev 58397)
@@ -29,6 +29,7 @@
 import org.jboss.ejb3.*;
 import org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.ejb3.jms.JMSDestinationFactory;
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
 import org.jboss.ejb3.timerservice.TimerServiceFactory;
 import org.jboss.jms.jndi.JMSProviderAdapter;
@@ -470,7 +471,7 @@
     * @throws IllegalArgumentException Type is not Queue or Topic.
     * @throws Exception                Description of Exception
     */
-   protected Destination createDestination(final Class type,
+   private Destination createDestination(final Class<? extends Destination> type,
                                            final Context ctx,
                                            final String jndiName,
                                            final String jndiSuffix)
@@ -502,7 +503,7 @@
       }
    }
    
-   protected void createTemporaryDestination(Class type, String jndiSuffix) throws Exception
+   private void createTemporaryDestination(Class<? extends Destination> type, String jndiSuffix) throws Exception
    {
       //
       // jason: we should do away with this...
@@ -513,25 +514,26 @@
 
       // MBeanServer server = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
       
-      String methodName;
-      String destinationContext;
-      if (type == Topic.class)
-      {
-         destinationContext = "topic";
-         methodName = "createTopic";
-      }
-      else if (type == Queue.class)
-      {
-         destinationContext = "queue";
-         methodName = "createQueue";
-      }
-      else
-      {
-         // type was not a Topic or Queue, bad user
-         throw new IllegalArgumentException
-                 ("Expected javax.jms.Queue or javax.jms.Topic: " + type);
-      }
+//      String methodName;
+//      String destinationContext;
+//      if (type == Topic.class)
+//      {
+//         destinationContext = "topic";
+//         methodName = "createTopic";
+//      }
+//      else if (type == Queue.class)
+//      {
+//         destinationContext = "queue";
+//         methodName = "createQueue";
+//      }
+//      else
+//      {
+//         // type was not a Topic or Queue, bad user
+//         throw new IllegalArgumentException
+//                 ("Expected javax.jms.Queue or javax.jms.Topic: " + type);
+//      }
       
+      /* No longer supported (AS 4.x)
       ObjectName destinationManagerName = new ObjectName("jboss.mq:service=DestinationManager");
       
       KernelAbstraction kernel = KernelAbstractionFactory.getInstance();
@@ -551,6 +553,10 @@
       {
          jndiContext.rebind(binding, result);
       }
+      */
+      
+      //throw new UnsupportedOperationException("Can't create destination " + destinationContext + "/" + jndiSuffix);
+      JMSDestinationFactory.getInstance().createDestination(type, jndiSuffix);
    }
    
    /**




More information about the jboss-cvs-commits mailing list