[jboss-cvs] JBoss Messaging SVN: r3805 - in branches/Branch_Stable/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:20:35 EST 2008
Author: clebert.suconic at jboss.com
Date: 2008-02-26 18:20:35 -0500 (Tue, 26 Feb 2008)
New Revision: 3805
Modified:
branches/Branch_Stable/src/main/org/jboss/jms/client/container/ConnectionAspect.java
branches/Branch_Stable/src/main/org/jboss/jms/client/container/ConsumerAspect.java
branches/Branch_Stable/src/main/org/jboss/jms/client/state/ConnectionState.java
branches/Branch_Stable/src/main/org/jboss/jms/client/state/SessionState.java
branches/Branch_Stable/src/main/org/jboss/messaging/util/JBMExecutor.java
Log:
JBMESSAGING-1212 - minimizing calls on the executor
Modified: branches/Branch_Stable/src/main/org/jboss/jms/client/container/ConnectionAspect.java
===================================================================
--- branches/Branch_Stable/src/main/org/jboss/jms/client/container/ConnectionAspect.java 2008-02-26 20:56:08 UTC (rev 3804)
+++ branches/Branch_Stable/src/main/org/jboss/jms/client/container/ConnectionAspect.java 2008-02-26 23:20:35 UTC (rev 3805)
@@ -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_Stable/src/main/org/jboss/jms/client/container/ConsumerAspect.java
===================================================================
--- branches/Branch_Stable/src/main/org/jboss/jms/client/container/ConsumerAspect.java 2008-02-26 20:56:08 UTC (rev 3804)
+++ branches/Branch_Stable/src/main/org/jboss/jms/client/container/ConsumerAspect.java 2008-02-26 23:20:35 UTC (rev 3805)
@@ -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_Stable/src/main/org/jboss/jms/client/state/ConnectionState.java
===================================================================
--- branches/Branch_Stable/src/main/org/jboss/jms/client/state/ConnectionState.java 2008-02-26 20:56:08 UTC (rev 3804)
+++ branches/Branch_Stable/src/main/org/jboss/jms/client/state/ConnectionState.java 2008-02-26 23:20:35 UTC (rev 3805)
@@ -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_Stable/src/main/org/jboss/jms/client/state/SessionState.java
===================================================================
--- branches/Branch_Stable/src/main/org/jboss/jms/client/state/SessionState.java 2008-02-26 20:56:08 UTC (rev 3804)
+++ branches/Branch_Stable/src/main/org/jboss/jms/client/state/SessionState.java 2008-02-26 23:20:35 UTC (rev 3805)
@@ -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_Stable/src/main/org/jboss/messaging/util/JBMExecutor.java
===================================================================
--- branches/Branch_Stable/src/main/org/jboss/messaging/util/JBMExecutor.java 2008-02-26 20:56:08 UTC (rev 3804)
+++ branches/Branch_Stable/src/main/org/jboss/messaging/util/JBMExecutor.java 2008-02-26 23:20:35 UTC (rev 3805)
@@ -52,6 +52,8 @@
public class JBMExecutor extends QueuedExecutor
{
+ private boolean needToSetClassLoader = true;
+
public JBMExecutor(Channel channel)
{
super(channel);
@@ -69,48 +71,41 @@
public TCLExecutor(Runnable realExecutor)
{
- tcl = AccessController.doPrivileged(
- new PrivilegedAction<ClassLoader>()
- {
- public ClassLoader run()
+ if (needToSetClassLoader)
+ {
+ tcl = AccessController.doPrivileged(
+ new PrivilegedAction<ClassLoader>()
{
- return Thread.currentThread().getContextClassLoader();
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
}
- }
- );
+ );
+ }
this.realExecutor = realExecutor;
}
+ @SuppressWarnings("unchecked")
public void run()
{
- AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public Object run()
- {
- Thread.currentThread().setContextClassLoader(tcl);
- return null;
- }
- }
- );
- try
+ if (needToSetClassLoader)
{
- realExecutor.run();
- }
- finally
- {
+ needToSetClassLoader = false;
+
AccessController.doPrivileged(
new PrivilegedAction()
{
public Object run()
{
- Thread.currentThread().setContextClassLoader(JBMExecutor.class.getClassLoader());
+ Thread.currentThread().setContextClassLoader(tcl);
return null;
}
}
);
}
+ realExecutor.run();
}
}
@@ -119,6 +114,19 @@
{
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