[jboss-cvs] JBoss Messaging SVN: r3806 - in branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss: jms/client/state and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 26 18:21:47 EST 2008
Author: clebert.suconic at jboss.com
Date: 2008-02-26 18:21:47 -0500 (Tue, 26 Feb 2008)
New Revision: 3806
Modified:
branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/container/ConnectionAspect.java
branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/container/ConsumerAspect.java
branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/state/ConnectionState.java
branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/state/SessionState.java
branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/JBMExecutor.java
Log:
JBMESSAGING-1212 - minimizing calls on the executor
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/container/ConnectionAspect.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/container/ConnectionAspect.java 2008-02-26 23:20:35 UTC (rev 3805)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/container/ConnectionAspect.java 2008-02-26 23:21:47 UTC (rev 3806)
@@ -150,6 +150,8 @@
public Object handleStop(Invocation invocation) throws Throwable
{
ConnectionState currentState = getConnectionState(invocation);
+ // If the session is being sent to the Cache, we need to clear the Thread because of the ContextClassLoader
+ currentState.clearExecutors();
currentState.setStarted(false);
currentState.setJustCreated(false);
return invocation.invokeNext();
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/container/ConsumerAspect.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/container/ConsumerAspect.java 2008-02-26 23:20:35 UTC (rev 3805)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/container/ConsumerAspect.java 2008-02-26 23:21:47 UTC (rev 3806)
@@ -156,6 +156,8 @@
//And then we cancel any messages still in the message callback handler buffer
consumerState.getClientConsumer().cancelBuffer();
+
+ sessionState.getExecutor().clearClassLoader();
return l;
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/state/ConnectionState.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/state/ConnectionState.java 2008-02-26 23:20:35 UTC (rev 3805)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/state/ConnectionState.java 2008-02-26 23:21:47 UTC (rev 3806)
@@ -176,6 +176,25 @@
// Public ---------------------------------------------------------------------------------------
+ /**
+ *
+ * Session Executors will store the ClassLoader on the threads they were created.
+ * When a JMSSession is reused by JCA it can reuse it on different application context (i.e. different ClassLoaders)
+ * This method should be called before the Session is stored on the JCA's cache
+ * @throws InterruptedException
+ *
+ * */
+ public void clearExecutors() throws InterruptedException
+ {
+ Iterator iterator = getChildren().iterator();
+ while (iterator.hasNext())
+ {
+ SessionState state = (SessionState) iterator.next();
+ state.clearExecutorThread();
+ }
+
+ }
+
public ResourceManager getResourceManager()
{
return resourceManager;
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/state/SessionState.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/state/SessionState.java 2008-02-26 23:20:35 UTC (rev 3805)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/jms/client/state/SessionState.java 2008-02-26 23:21:47 UTC (rev 3806)
@@ -360,6 +360,11 @@
// Public ---------------------------------------------------------------------------------------
+ public void clearExecutorThread() throws InterruptedException
+ {
+ this.executor.clearClassLoader();
+ }
+
public void setTreatAsNonTransactedWhenNotEnlisted(boolean b)
{
treatAsNonTransactedWhenNotEnlisted = b;
@@ -418,7 +423,7 @@
return xaResource;
}
- public QueuedExecutor getExecutor()
+ public JBMExecutor getExecutor()
{
return executor;
}
Modified: branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/JBMExecutor.java
===================================================================
--- branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/JBMExecutor.java 2008-02-26 23:20:35 UTC (rev 3805)
+++ branches/Branch_JBossMessaging_1_4_0_SP3_CP/src/main/org/jboss/messaging/util/JBMExecutor.java 2008-02-26 23:21:47 UTC (rev 3806)
@@ -22,6 +22,9 @@
package org.jboss.messaging.util;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
import EDU.oswego.cs.dl.util.concurrent.Channel;
@@ -49,6 +52,8 @@
public class JBMExecutor extends QueuedExecutor
{
+ private boolean needToSetClassLoader = true;
+
public JBMExecutor(Channel channel)
{
super(channel);
@@ -61,33 +66,67 @@
class TCLExecutor implements Runnable
{
- Runnable realExecutor;
- ClassLoader tcl;
+ private Runnable realExecutor;
+ private ClassLoader tcl;
public TCLExecutor(Runnable realExecutor)
{
- tcl = Thread.currentThread().getContextClassLoader();
+ if (needToSetClassLoader)
+ {
+ tcl = AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ }
+ );
+ }
+
this.realExecutor = realExecutor;
}
+ @SuppressWarnings("unchecked")
public void run()
{
- Thread.currentThread().setContextClassLoader(tcl);
- try
+ if (needToSetClassLoader)
{
- realExecutor.run();
+ needToSetClassLoader = false;
+
+ AccessController.doPrivileged(
+ new PrivilegedAction()
+ {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(tcl);
+ return null;
+ }
+ }
+ );
}
- finally
- {
- Thread.currentThread().setContextClassLoader(JBMExecutor.class.getClassLoader());
- }
+ realExecutor.run();
}
}
-
+
+
public void execute(Runnable runnable) throws InterruptedException
{
super.execute(new TCLExecutor(runnable));
}
+
+ public void clearClassLoader() throws InterruptedException
+ {
+ super.execute(new Runnable()
+ {
+ @SuppressWarnings("unchecked")
+ public void run()
+ {
+ needToSetClassLoader = true;
+ }
+ });
+
+ }
public void clearAllExceptCurrentTask()
More information about the jboss-cvs-commits
mailing list