[jboss-cvs] JBoss Messaging SVN: r2548 - in branches/Branch_1_2_0_SP: src/main/org/jboss/jms/client/container and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 15 18:04:39 EDT 2007


Author: clebert.suconic at jboss.com
Date: 2007-03-15 18:04:39 -0400 (Thu, 15 Mar 2007)
New Revision: 2548

Removed:
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/util/ThreadContextClassLoaderChanger.java
Modified:
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnection.java
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnectionConsumer.java
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnectionFactory.java
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossMessageProducer.java
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossQueueBrowser.java
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossSession.java
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/container/JmsClientAspectXMLLoader.java
   branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/ServerPeer.java
   branches/Branch_1_2_0_SP/util/release-admin.xml
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-254 & http://jira.jboss.org/jira/browse/JBMESSAGING-922 fixes

Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnection.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnection.java	2007-03-14 18:49:42 UTC (rev 2547)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnection.java	2007-03-15 22:04:39 UTC (rev 2548)
@@ -49,7 +49,6 @@
 import org.jboss.jms.client.state.ConnectionState;
 import org.jboss.jms.delegate.ConnectionDelegate;
 import org.jboss.jms.delegate.SessionDelegate;
-import org.jboss.jms.util.ThreadContextClassLoaderChanger;
 
 /**
  * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
@@ -94,34 +93,12 @@
 
    public String getClientID() throws JMSException
    {
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
-
-      try
-      {
-         tccc.set(getClass().getClassLoader());
-
-         return delegate.getClientID();
-      }
-      finally
-      {
-         tccc.restore();
-      }
+      return delegate.getClientID();
    }
 
    public void setClientID(String clientID) throws JMSException
    {
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
-
-      try
-      {
-         tccc.set(getClass().getClassLoader());
-
-         delegate.setClientID(clientID);
-      }
-      finally
-      {
-         tccc.restore();
-      }
+      delegate.setClientID(clientID);
    }
 
    public ConnectionMetaData getMetaData() throws JMSException
@@ -289,20 +266,9 @@
          acknowledgeMode = Session.SESSION_TRANSACTED;
       }
 
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
-
-      try
-      {
-         tccc.set(getClass().getClassLoader());
-
-         SessionDelegate sessionDelegate =
-            delegate.createSessionDelegate(transacted, acknowledgeMode, isXA);
-         return new JBossSession(sessionDelegate, type);
-      }
-      finally
-      {
-         tccc.restore();
-      }
+      SessionDelegate sessionDelegate =
+         delegate.createSessionDelegate(transacted, acknowledgeMode, isXA);
+      return new JBossSession(sessionDelegate, type);
    }
 
    // Temporarily commented out as it seems to produce random test failures

Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnectionConsumer.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnectionConsumer.java	2007-03-14 18:49:42 UTC (rev 2547)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnectionConsumer.java	2007-03-15 22:04:39 UTC (rev 2548)
@@ -40,7 +40,6 @@
 import org.jboss.jms.destination.JBossDestination;
 import org.jboss.jms.message.MessageProxy;
 import org.jboss.jms.util.MessageQueueNameHelper;
-import org.jboss.jms.util.ThreadContextClassLoaderChanger;
 import org.jboss.logging.Logger;
 
 import EDU.oswego.cs.dl.util.concurrent.SynchronizedInt;
@@ -117,23 +116,12 @@
          this.maxMessages = 1;
       }
 
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
+      // Create a consumer. The MessageCallbackhandler knows we are a connection consumer so will
+      // not call pre or postDeliver so messages won't be acked, or stored in session/tx.
+      sess = conn.createSessionDelegate(false, Session.CLIENT_ACKNOWLEDGE, false);
 
-      try
-      {
-         tccc.set(getClass().getClassLoader());
+      cons = sess.createConsumerDelegate(dest, messageSelector, false, subName, true);
 
-         // Create a consumer. The MessageCallbackhandler knows we are a connection consumer so will
-         // not call pre or postDeliver so messages won't be acked, or stored in session/tx.
-         sess = conn.createSessionDelegate(false, Session.CLIENT_ACKNOWLEDGE, false);
-
-         cons = sess.createConsumerDelegate(dest, messageSelector, false, subName, true);
-      }
-      finally
-      {
-         tccc.restore();
-      }
-
       ConsumerState state = (ConsumerState)((DelegateSupport)cons).getState();
 
       this.consumerID = state.getConsumerID();      

Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnectionFactory.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnectionFactory.java	2007-03-14 18:49:42 UTC (rev 2547)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossConnectionFactory.java	2007-03-15 22:04:39 UTC (rev 2548)
@@ -42,7 +42,6 @@
 import org.jboss.jms.delegate.ConnectionFactoryDelegate;
 import org.jboss.jms.referenceable.SerializableObjectRefAddr;
 import org.jboss.jms.server.endpoint.CreateConnectionResult;
-import org.jboss.jms.util.ThreadContextClassLoaderChanger;
 import org.jboss.logging.Logger;
 
 /**
@@ -188,35 +187,24 @@
                                                       boolean isXA, int type)
       throws JMSException
    {
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
-      
       try
       {
-         tccc.set(getClass().getClassLoader());
-
-         try
-         {
-            ClientAOPStackLoader.getInstance().load(delegate);
-         }
-         catch(Exception e)
-         {
-            // Need to log message since no guarantee that client will log it
-            final String msg = "Failed to download and/or install client side AOP stack";
-            log.error(msg, e);
-            throw new RuntimeException(msg, e);
-         }
-   
-         // The version used by the connection is the minimum of the server version for the
-         // connection factory and the client code version
-         
-         CreateConnectionResult res = delegate.createConnectionDelegate(username, password, -1);        
-         
-         return new JBossConnection(res.getDelegate(), type);
+         ClientAOPStackLoader.getInstance().load(delegate);
       }
-      finally
+      catch(Exception e)
       {
-         tccc.restore();
+         // Need to log message since no guarantee that client will log it
+         final String msg = "Failed to download and/or install client side AOP stack";
+         log.error(msg, e);
+         throw new RuntimeException(msg, e);
       }
+
+      // The version used by the connection is the minimum of the server version for the
+      // connection factory and the client code version
+
+      CreateConnectionResult res = delegate.createConnectionDelegate(username, password, -1);
+
+      return new JBossConnection(res.getDelegate(), type);
    }
    
    // Private --------------------------------------------------------------------------------------

Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossMessageProducer.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossMessageProducer.java	2007-03-14 18:49:42 UTC (rev 2547)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossMessageProducer.java	2007-03-15 22:04:39 UTC (rev 2548)
@@ -35,7 +35,6 @@
 
 import org.jboss.jms.delegate.ProducerDelegate;
 import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.util.ThreadContextClassLoaderChanger;
 import org.jboss.logging.Logger;
 
 /**
@@ -162,18 +161,7 @@
          throw new InvalidDestinationException("Not a JBossDestination:" + destination);
       }
 
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
-
-      try
-      {
-         tccc.set(getClass().getClassLoader());
-
-         delegate.send((JBossDestination)destination, m, deliveryMode, priority, timeToLive);
-      }
-      finally
-      {
-         tccc.restore();
-      }      
+      delegate.send((JBossDestination)destination, m, deliveryMode, priority, timeToLive);
    }
 
 

Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossQueueBrowser.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossQueueBrowser.java	2007-03-14 18:49:42 UTC (rev 2547)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossQueueBrowser.java	2007-03-15 22:04:39 UTC (rev 2548)
@@ -29,7 +29,6 @@
 import java.util.Enumeration;
 
 import org.jboss.jms.delegate.BrowserDelegate;
-import org.jboss.jms.util.ThreadContextClassLoaderChanger;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -69,18 +68,7 @@
 
    public Enumeration getEnumeration() throws JMSException
    {
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
-
-      try
-      {
-         tccc.set(getClass().getClassLoader());
-         delegate.reset();
-      }
-      finally
-      {
-         tccc.restore();
-      }
-      
+      delegate.reset();
       return new BrowserEnumeration();
    }
 

Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossSession.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossSession.java	2007-03-14 18:49:42 UTC (rev 2547)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/JBossSession.java	2007-03-15 22:04:39 UTC (rev 2548)
@@ -65,7 +65,6 @@
 import org.jboss.jms.destination.JBossTemporaryTopic;
 import org.jboss.jms.destination.JBossTopic;
 import org.jboss.jms.message.MessageProxy;
-import org.jboss.jms.util.ThreadContextClassLoaderChanger;
 import org.jboss.logging.Logger;
 
 /**
@@ -191,18 +190,7 @@
    {
       if (log.isTraceEnabled()) { log.trace("setMessageListener(" + listener + ") called"); }
 
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
-
-      try
-      {
-         tccc.set(getClass().getClassLoader());
-
-         delegate.setMessageListener(listener);
-      }
-      finally
-      {
-         tccc.restore();
-      }
+      delegate.setMessageListener(listener);
    }
 
    public void run()
@@ -218,19 +206,8 @@
          throw new InvalidDestinationException("Not a JBossDestination:" + d);
       }
            
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
-
-      try
-      {
-         tccc.set(getClass().getClassLoader());
-
-         ProducerDelegate producerDelegate = delegate.createProducerDelegate((JBossDestination)d);
-         return new JBossMessageProducer(producerDelegate);
-      }
-      finally
-      {
-         tccc.restore();
-      }
+      ProducerDelegate producerDelegate = delegate.createProducerDelegate((JBossDestination)d);
+      return new JBossMessageProducer(producerDelegate);
    }
 
   public MessageConsumer createConsumer(Destination d) throws JMSException
@@ -257,21 +234,10 @@
 
       log.debug("attempting to create consumer for destination:" + d + (messageSelector == null ? "" : ", messageSelector: " + messageSelector) + (noLocal ? ", noLocal = true" : ""));
 
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
+      ConsumerDelegate cd = delegate.
+         createConsumerDelegate((JBossDestination)d, messageSelector, noLocal, null, false);
 
-      try
-      {
-         tccc.set(getClass().getClassLoader());
-
-         ConsumerDelegate cd = delegate.
-            createConsumerDelegate((JBossDestination)d, messageSelector, noLocal, null, false);
-         
-         return new JBossMessageConsumer(cd);
-      }
-      finally
-      {
-         tccc.restore();
-      }
+      return new JBossMessageConsumer(cd);
    }
 
    public Queue createQueue(String queueName) throws JMSException
@@ -310,21 +276,10 @@
          throw new InvalidDestinationException("Not a JBossTopic:" + topic);
       }
 
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
+      ConsumerDelegate cd =
+         delegate.createConsumerDelegate((JBossTopic)topic, null, false, name, false);
 
-      try
-      {
-         tccc.set(getClass().getClassLoader());
-
-         ConsumerDelegate cd =
-            delegate.createConsumerDelegate((JBossTopic)topic, null, false, name, false);
-
-         return new JBossMessageConsumer(cd);
-      }
-      finally
-      {
-         tccc.restore();
-      }
+      return new JBossMessageConsumer(cd);
    }
 
    public TopicSubscriber createDurableSubscriber(Topic topic,
@@ -382,21 +337,10 @@
          messageSelector = null;
       }
 
-      ThreadContextClassLoaderChanger tccc = new ThreadContextClassLoaderChanger();
+      BrowserDelegate del =
+         delegate.createBrowserDelegate((JBossQueue)queue, messageSelector);
 
-      try
-      {
-         tccc.set(getClass().getClassLoader());
-
-         BrowserDelegate del =
-            delegate.createBrowserDelegate((JBossQueue)queue, messageSelector);
-         
-         return new JBossQueueBrowser(queue, messageSelector, del);
-      }
-      finally
-      {
-         tccc.restore();
-      }
+      return new JBossQueueBrowser(queue, messageSelector, del);
    }
 
    public TemporaryQueue createTemporaryQueue() throws JMSException

Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/container/JmsClientAspectXMLLoader.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/container/JmsClientAspectXMLLoader.java	2007-03-14 18:49:42 UTC (rev 2547)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/client/container/JmsClientAspectXMLLoader.java	2007-03-15 22:04:39 UTC (rev 2548)
@@ -90,7 +90,7 @@
             
             Document doc = docBuilder.parse(source);
             
-            this.deployXML(doc, null);              
+            this.deployXML(doc, null, this.getClass().getClassLoader());              
          }
          finally
          {

Modified: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/ServerPeer.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/ServerPeer.java	2007-03-14 18:49:42 UTC (rev 2547)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/server/ServerPeer.java	2007-03-15 22:04:39 UTC (rev 2548)
@@ -1284,7 +1284,7 @@
    private void loadServerAOPConfig() throws Exception
    {
       URL url = this.getClass().getClassLoader().getResource("aop-messaging-server.xml");
-      AspectXmlLoader.deployXML(url);
+      AspectXmlLoader.deployXML(url, this.getClass().getClassLoader());
    }
 
    private void unloadServerAOPConfig() throws Exception

Deleted: branches/Branch_1_2_0_SP/src/main/org/jboss/jms/util/ThreadContextClassLoaderChanger.java
===================================================================
--- branches/Branch_1_2_0_SP/src/main/org/jboss/jms/util/ThreadContextClassLoaderChanger.java	2007-03-14 18:49:42 UTC (rev 2547)
+++ branches/Branch_1_2_0_SP/src/main/org/jboss/jms/util/ThreadContextClassLoaderChanger.java	2007-03-15 22:04:39 UTC (rev 2548)
@@ -1,78 +0,0 @@
-/*
-  * 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.
-  */
-package org.jboss.jms.util;
-
-/**
- * A thread context classloader changer. This class is an abomination. It is here for experimental
- * purposes only. The way it changes the class loader (and more important, the way it stores the
- * saved thread context class loader) is inneficient and dangerous.
- *
- * TODO: Do not use it in the production version.
- *       See http://www.jboss.org/index.html?module=bb&op=viewtopic&t=74434 for an alternative solution.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ThreadContextClassLoaderChanger
-{
-   // Constants -----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   private ClassLoader savedThreadContextClassLoader;
-
-   public void set(ClassLoader cl)
-   {
-      Thread currentThread = Thread.currentThread();
-      savedThreadContextClassLoader = currentThread.getContextClassLoader();
-      currentThread.setContextClassLoader(cl);
-   }
-
-   /**
-    * Use it from a finally block.
-    */
-   public void restore()
-   {
-      if (savedThreadContextClassLoader == null)
-      {
-         return;
-      }
-
-      Thread.currentThread().setContextClassLoader(savedThreadContextClassLoader);
-      savedThreadContextClassLoader = null;
-   }
-   // Attributes ----------------------------------------------------
-   
-   // Constructors --------------------------------------------------
-   
-   // Public --------------------------------------------------------
-
-   // Package protected ---------------------------------------------
-   
-   // Protected -----------------------------------------------------
-   
-   // Private -------------------------------------------------------
-   
-   // Inner classes -------------------------------------------------   
-}

Modified: branches/Branch_1_2_0_SP/util/release-admin.xml
===================================================================
--- branches/Branch_1_2_0_SP/util/release-admin.xml	2007-03-14 18:49:42 UTC (rev 2547)
+++ branches/Branch_1_2_0_SP/util/release-admin.xml	2007-03-15 22:04:39 UTC (rev 2548)
@@ -192,6 +192,13 @@
       </condition>
       <antcall target="expand-jar"/>
       <antcall target="expand-sar"/>
+
+      <move todir="${jboss.home}/server/${config.name}/conf">
+          <fileset dir="${jboss.home}/server/${config.name}/deploy/jboss-messaging.sar">
+             <include name="messaging-*.properties"/>
+          </fileset>
+       </move>
+
    </target>
 
    <target name="expand-sar" if="is.sar">




More information about the jboss-cvs-commits mailing list