[jboss-cvs] JBossAS SVN: r60392 - branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/jms.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 7 12:43:16 EST 2007
Author: wolfc
Date: 2007-02-07 12:43:16 -0500 (Wed, 07 Feb 2007)
New Revision: 60392
Added:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/jms/DestinationManagerJMSDestinationFactory.java
Modified:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/jms/JMSDestinationFactory.java
Log:
Using DestinationManager
Added: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/jms/DestinationManagerJMSDestinationFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/jms/DestinationManagerJMSDestinationFactory.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/jms/DestinationManagerJMSDestinationFactory.java 2007-02-07 17:43:16 UTC (rev 60392)
@@ -0,0 +1,92 @@
+/*
+ * 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.jms;
+
+import javax.jms.Destination;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.management.ObjectName;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.ejb3.InitialContextFactory;
+import org.jboss.ejb3.KernelAbstraction;
+import org.jboss.ejb3.KernelAbstractionFactory;
+
+/**
+ * Use DestinationManager for creation of destinations.
+ *
+ * JBoss AS 4.2
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class DestinationManagerJMSDestinationFactory extends JMSDestinationFactory
+{
+
+ /* (non-Javadoc)
+ * @see org.jboss.ejb3.jms.JMSDestinationFactory#createDestination(java.lang.Class, java.lang.String)
+ */
+ @Override
+ 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);
+ }
+
+ ObjectName destinationManagerName = new ObjectName("jboss.mq:service=DestinationManager");
+
+ KernelAbstraction kernel = KernelAbstractionFactory.getInstance();
+ // invoke the server to create the destination
+ Object result = kernel.invoke(destinationManagerName,
+ methodName,
+ new Object[]{jndiSuffix},
+ new String[]{"java.lang.String"});
+
+ InitialContext jndiContext = InitialContextFactory.getInitialContext();
+ String binding = destinationContext + "/" + jndiSuffix;
+ try
+ {
+ jndiContext.lookup(binding);
+ }
+ catch (NamingException e)
+ {
+ jndiContext.rebind(binding, result);
+ }
+ }
+
+}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/jms/JMSDestinationFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/jms/JMSDestinationFactory.java 2007-02-07 16:59:08 UTC (rev 60391)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/jms/JMSDestinationFactory.java 2007-02-07 17:43:16 UTC (rev 60392)
@@ -31,7 +31,7 @@
*/
public abstract class JMSDestinationFactory
{
- private static final JMSDestinationFactory instance = new ServerPeerJMSDestinationFactory();
+ private static final JMSDestinationFactory instance = new DestinationManagerJMSDestinationFactory();
public static JMSDestinationFactory getInstance()
{
More information about the jboss-cvs-commits
mailing list