[jboss-cvs] JBossAS SVN: r63351 - trunk/connector/src/main/org/jboss/resource/adapter/jms.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 5 10:52:46 EDT 2007


Author: scott.stark at jboss.org
Date: 2007-06-05 10:52:46 -0400 (Tue, 05 Jun 2007)
New Revision: 63351

Modified:
   trunk/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java
Log:
Synch with the 4.2 exception changes

Modified: trunk/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java	2007-06-05 14:44:44 UTC (rev 63350)
+++ trunk/connector/src/main/org/jboss/resource/adapter/jms/JmsSession.java	2007-06-05 14:52:46 UTC (rev 63351)
@@ -1,24 +1,24 @@
 /*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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.
-*/
+ * 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.resource.adapter.jms;
 
 import java.io.Serializable;
@@ -28,6 +28,7 @@
 import javax.jms.BytesMessage;
 import javax.jms.Destination;
 import javax.jms.IllegalStateException;
+import javax.jms.InvalidDestinationException;
 import javax.jms.JMSException;
 import javax.jms.MessageListener;
 import javax.jms.MapMessage;
@@ -271,6 +272,11 @@
 
    public Topic createTopic(String topicName) throws JMSException
    {
+      if(info.getType() == JmsConnectionFactory.QUEUE)
+      {
+         throw new IllegalStateException("Cannot create topic for javax.jms.QueueSession");         
+      }
+
       Session session = getSession();
       if (trace)
          log.trace("createTopic " + session + " topicName=" + topicName);
@@ -308,7 +314,12 @@
 
    public TopicSubscriber createDurableSubscriber(Topic topic, String name) throws JMSException
    {
-      TopicSession session = getTopicSession();
+      if(info.getType() == JmsConnectionFactory.QUEUE)
+      {
+         throw new IllegalStateException("Cannot create durable subscriber from javax.jms.QueueSession");         
+      }
+      
+      Session session = getSession();
       if (trace)
          log.trace("createDurableSubscriber " + session + " topic=" + topic + " name=" + name);
       TopicSubscriber result = session.createDurableSubscriber(topic, name);
@@ -347,6 +358,11 @@
 
    public TemporaryTopic createTemporaryTopic() throws JMSException
    {
+      if(info.getType() == JmsConnectionFactory.QUEUE)
+      {
+         throw new IllegalStateException("Cannot create temporary topic for javax.jms.QueueSession");         
+      }
+      
       Session session = getSession();
       if (trace)
          log.trace("createTemporaryTopic " + session);
@@ -359,6 +375,11 @@
 
    public void unsubscribe(String name) throws JMSException
    {
+      if(info.getType() == JmsConnectionFactory.QUEUE)
+      {
+         throw new IllegalStateException("Cannot unsubscribe for javax.jms.QueueSession");         
+      }
+
       Session session = getSession();
       if (trace)
          log.trace("unsubscribe " + session + " name=" + name);
@@ -369,6 +390,13 @@
 
    public QueueBrowser createBrowser(Queue queue) throws JMSException
    {
+      
+      if(info.getType() == JmsConnectionFactory.TOPIC)
+      {
+         throw new IllegalStateException("Cannot create browser for javax.jms.TopicSession");
+         
+      }
+
       Session session = getSession();
       if (trace)
          log.trace("createBrowser " + session + " queue=" + queue);
@@ -391,6 +419,12 @@
 
    public Queue createQueue(String queueName) throws JMSException
    {
+      if(info.getType() == JmsConnectionFactory.TOPIC)
+      {
+         throw new IllegalStateException("Cannot create browser or javax.jms.TopicSession");
+         
+      }
+
       Session session = getSession();
       if (trace)
          log.trace("createQueue " + session + " queueName=" + queueName);
@@ -440,6 +474,11 @@
 
    public TemporaryQueue createTemporaryQueue() throws JMSException
    {
+      if(info.getType() == JmsConnectionFactory.TOPIC)
+      {
+         throw new IllegalStateException("Cannot create temporary queue for javax.jms.TopicSession");
+         
+      }
       Session session = getSession();
       if (trace)
          log.trace("createTemporaryQueue " + session);
@@ -633,11 +672,17 @@
    
    QueueSession getQueueSession() throws JMSException
    {
-      return (QueueSession) getSession();
+      Session s = getSession();
+      if( !(s instanceof QueueSession) )
+         throw new InvalidDestinationException("Attempting to use QueueSession methods on: "+this);
+      return (QueueSession) s; 
    }
    
    TopicSession getTopicSession() throws JMSException
    {
-      return (TopicSession) getSession();
+      Session s = getSession();
+      if( !(s instanceof TopicSession) )
+         throw new InvalidDestinationException("Attempting to use TopicSession methods on: "+this);
+      return (TopicSession) s; 
    }
 }




More information about the jboss-cvs-commits mailing list