[jboss-cvs] JBoss Messaging SVN: r3488 - in branches/Branch_Stable/src/main/org/jboss: messaging/util and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Dec 12 13:43:54 EST 2007
Author: clebert.suconic at jboss.com
Date: 2007-12-12 13:43:54 -0500 (Wed, 12 Dec 2007)
New Revision: 3488
Added:
branches/Branch_Stable/src/main/org/jboss/messaging/util/JBMExecutor.java
Removed:
branches/Branch_Stable/src/main/org/jboss/messaging/util/ClearableQueuedExecutor.java
Modified:
branches/Branch_Stable/src/main/org/jboss/jms/client/state/SessionState.java
Log:
http://jira.jboss.com/jira/browse/JBMESSAGING-1200
Modified: branches/Branch_Stable/src/main/org/jboss/jms/client/state/SessionState.java
===================================================================
--- branches/Branch_Stable/src/main/org/jboss/jms/client/state/SessionState.java 2007-12-12 15:41:40 UTC (rev 3487)
+++ branches/Branch_Stable/src/main/org/jboss/jms/client/state/SessionState.java 2007-12-12 18:43:54 UTC (rev 3488)
@@ -29,10 +29,11 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-
import javax.jms.MessageListener;
import javax.jms.Session;
+import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
+import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
import org.jboss.jms.client.container.ClientConsumer;
import org.jboss.jms.client.delegate.ClientBrowserDelegate;
import org.jboss.jms.client.delegate.ClientConsumerDelegate;
@@ -46,12 +47,9 @@
import org.jboss.jms.tx.MessagingXAResource;
import org.jboss.jms.tx.ResourceManager;
import org.jboss.logging.Logger;
-import org.jboss.messaging.util.ClearableQueuedExecutor;
+import org.jboss.messaging.util.JBMExecutor;
import org.jboss.messaging.util.Version;
-import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
-
/**
* State corresponding to a session. This state is acessible inside aspects/interceptors.
*
@@ -85,7 +83,7 @@
private Object currentTxId;
// Executor used for executing onMessage methods
- private ClearableQueuedExecutor executor;
+ private JBMExecutor executor;
private boolean recoverCalled;
@@ -143,7 +141,7 @@
currentTxId = parent.getResourceManager().createLocalTx();
}
- executor = new ClearableQueuedExecutor(new LinkedQueue());
+ executor = new JBMExecutor(new LinkedQueue());
clientAckList = new ArrayList();
Deleted: branches/Branch_Stable/src/main/org/jboss/messaging/util/ClearableQueuedExecutor.java
===================================================================
--- branches/Branch_Stable/src/main/org/jboss/messaging/util/ClearableQueuedExecutor.java 2007-12-12 15:41:40 UTC (rev 3487)
+++ branches/Branch_Stable/src/main/org/jboss/messaging/util/ClearableQueuedExecutor.java 2007-12-12 18:43:54 UTC (rev 3488)
@@ -1,73 +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.messaging.util;
-
-import EDU.oswego.cs.dl.util.concurrent.Channel;
-import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
-
-/**
- * A ClearableQueuedExecutor
- *
- * This class extends the QueuedExector with a method to clear all but the currently
- * executing task without shutting it down.
- *
- * We need this functionality when failing over a session.
- *
- * In that case we need to clear all tasks apart from the currently executing one.
- *
- * We can't just shutdownAfterProcessingCurrentTask then use another instance
- * after failover since when failover resumes the current task and the next delivery
- * will be executed on different threads and smack into each other.
- *
- * http://jira.jboss.org/jira/browse/JBMESSAGING-904
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class ClearableQueuedExecutor extends QueuedExecutor
-{
- public ClearableQueuedExecutor()
- {
- }
-
- public ClearableQueuedExecutor(Channel channel)
- {
- super(channel);
- }
-
- public void clearAllExceptCurrentTask()
- {
- try
- {
- while (queue_.poll(0) != null);
- }
- catch (InterruptedException ex)
- {
- Thread.currentThread().interrupt();
- }
- }
-
-}
-
Added: branches/Branch_Stable/src/main/org/jboss/messaging/util/JBMExecutor.java
===================================================================
--- branches/Branch_Stable/src/main/org/jboss/messaging/util/JBMExecutor.java (rev 0)
+++ branches/Branch_Stable/src/main/org/jboss/messaging/util/JBMExecutor.java 2007-12-12 18:43:54 UTC (rev 3488)
@@ -0,0 +1,105 @@
+/*
+ * 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.messaging.util;
+
+import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
+import EDU.oswego.cs.dl.util.concurrent.Channel;
+
+
+/** Any Executor being used on client side has to clean its contextClassLoader, as that could cause leaks.
+ * This class encapsulates the necessary cleanup to avoid that leak.
+ *
+ * This class also extends the QueuedExector with a method to clear all but the currently
+ * executing task without shutting it down.
+ *
+ * We need this functionality when failing over a session.
+ *
+ * In that case we need to clear all tasks apart from the currently executing one.
+ *
+ * We can't just shutdownAfterProcessingCurrentTask then use another instance
+ * after failover since when failover resumes the current task and the next delivery
+ * will be executed on different threads and smack into each other.
+ *
+ * http://jira.jboss.org/jira/browse/JBMESSAGING-904
+ * http://jira.jboss.com/jira/browse/JBMESSAGING-1200
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:clebert.suconic at jboss.com">Clebert Suconic</a>
+ **/
+public class JBMExecutor extends QueuedExecutor
+{
+
+ public JBMExecutor(Channel channel)
+ {
+ super(channel);
+ }
+
+ public JBMExecutor()
+ {
+ }
+
+ class TCLExecutor implements Runnable
+ {
+
+ Runnable realExecutor;
+ ClassLoader tcl;
+
+ public TCLExecutor(Runnable realExecutor)
+ {
+ tcl = Thread.currentThread().getContextClassLoader();
+ this.realExecutor = realExecutor;
+ }
+
+ public void run()
+ {
+ Thread.currentThread().setContextClassLoader(tcl);
+ try
+ {
+ realExecutor.run();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(JBMExecutor.class.getClassLoader());
+ }
+ }
+ }
+
+ public void execute(Runnable runnable) throws InterruptedException
+ {
+ super.execute(new TCLExecutor(runnable));
+ }
+
+
+ public void clearAllExceptCurrentTask()
+ {
+ try
+ {
+ while (queue_.poll(0) != null);
+ }
+ catch (InterruptedException ex)
+ {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+}
Property changes on: branches/Branch_Stable/src/main/org/jboss/messaging/util/JBMExecutor.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
More information about the jboss-cvs-commits
mailing list