You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2008/04/23 18:03:56 UTC
svn commit: r650923 -
/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/StandaloneManagedThreadFactory.java
Author: gawor
Date: Wed Apr 23 09:03:47 2008
New Revision: 650923
URL: http://svn.apache.org/viewvc?rev=650923&view=rev
Log:
capture the context once
Modified:
geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/StandaloneManagedThreadFactory.java
Modified: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/StandaloneManagedThreadFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/StandaloneManagedThreadFactory.java?rev=650923&r1=650922&r2=650923&view=diff
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/StandaloneManagedThreadFactory.java (original)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/StandaloneManagedThreadFactory.java Wed Apr 23 09:03:47 2008
@@ -42,6 +42,7 @@
private ModuleLifecycleListener moduleLifecyleListener;
private List<ManagedThread> threads =
Collections.synchronizedList(new ArrayList<ManagedThread>());
+ private ManagedContext managedContext;
public StandaloneManagedThreadFactory(GeronimoManagedThreadFactory threadFactory,
ManagedContextHandler contextHandler,
@@ -50,15 +51,18 @@
this.contextHandler = contextHandler;
this.moduleLifecyleListener = ModuleLifecycleListener.getModuleLifecycleListener(moduleName);
this.moduleLifecyleListener.addThreadFactory(this);
+
+ // capture context
+ this.managedContext = ManagedContext.captureContext(this.contextHandler);
}
public Thread newThread(Runnable runnable) {
if (!isRunning()) {
- throw new IllegalStateException("Component is not running");
+ throw new IllegalArgumentException(
+ "Component that created this thread factory is no longer running");
}
-
- ManagedContext managedContext = ManagedContext.captureContext(this.contextHandler);
- runnable = new ManagedRunnable(runnable, managedContext, true);
+
+ runnable = new ManagedRunnable(runnable, this.managedContext, true);
ManagedThread thread = (ManagedThread)this.threadFactory.newThread(runnable);
this.threads.add(thread);