geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r650251 - in /geronimo/sandbox/concurrent: geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ geronimo-concurrent/src/main/java/org/a...
Date Mon, 21 Apr 2008 20:45:34 GMT
Author: gawor
Date: Mon Apr 21 13:45:11 2008
New Revision: 650251

URL: http://svn.apache.org/viewvc?rev=650251&view=rev
Log:
created more generic thread lifecycle listener interface

Added:
    geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ThreadLifecycleListener.java
      - copied, changed from r650242, geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ThreadStoppedListener.java
Removed:
    geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ThreadStoppedListener.java
Modified:
    geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/AbstractManagedThreadFactory.java
    geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ManagedThread.java
    geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedThreadFactory.java
    geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/GeronimoManagedThread.java
    geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/StandaloneManagedThreadFactory.java

Modified: geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/AbstractManagedThreadFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/AbstractManagedThreadFactory.java?rev=650251&r1=650250&r2=650251&view=diff
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/AbstractManagedThreadFactory.java
(original)
+++ geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/AbstractManagedThreadFactory.java
Mon Apr 21 13:45:11 2008
@@ -27,7 +27,7 @@
 import org.apache.commons.logging.LogFactory;
 
 public class AbstractManagedThreadFactory 
-    implements ManagedThreadFactory, ThreadStoppedListener {
+    implements ManagedThreadFactory, ThreadLifecycleListener {
 
     private final static Log LOG = LogFactory.getLog(AbstractManagedThreadFactory.class);
     
@@ -114,6 +114,9 @@
 
     protected ManagedThread createThread(ThreadGroup group, Runnable runnable, String name)
{
         return new ManagedThread(group, runnable, name, this);
+    }
+    
+    public void threadStarted(Thread thread) {        
     }
     
     public void threadStopped(Thread thread) {        

Modified: geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ManagedThread.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ManagedThread.java?rev=650251&r1=650250&r2=650251&view=diff
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ManagedThread.java
(original)
+++ geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ManagedThread.java
Mon Apr 21 13:45:11 2008
@@ -31,7 +31,7 @@
     }
     
     // thread-specific properties
-    protected ThreadStoppedListener threadStoppedListener;            
+    protected ThreadLifecycleListener threadLifecycleListener;            
     protected long hungTaskThreshold; 
     
     // task-specific properties
@@ -41,21 +41,21 @@
     protected TaskState state;
        
     public ManagedThread(Runnable runnable, 
-                         ThreadStoppedListener threadStoppedListener) {
+                         ThreadLifecycleListener threadLifecycleListener) {
         super(runnable);
-        setThreadStoppedListener(threadStoppedListener);
+        setThreadLifecycleListener(threadLifecycleListener);
     }
     
     public ManagedThread(ThreadGroup group,
                          Runnable runnable, 
                          String name,
-                         ThreadStoppedListener threadStoppedListener) {
+                         ThreadLifecycleListener threadLifecycleListener) {
         super(group, runnable, name);
-        setThreadStoppedListener(threadStoppedListener);
+        setThreadLifecycleListener(threadLifecycleListener);
     }
     
-    public void setThreadStoppedListener(ThreadStoppedListener threadStoppedListener) {
-        this.threadStoppedListener = threadStoppedListener;
+    public void setThreadLifecycleListener(ThreadLifecycleListener threadLifecycleListener)
{
+        this.threadLifecycleListener = threadLifecycleListener;
     }
     
     /**
@@ -99,11 +99,16 @@
         this.taskIdentityDescription = null;
     }
          
+    public void start() {
+        super.start();
+        this.threadLifecycleListener.threadStarted(this);
+    }
+    
     public void run() {
         try {
             super.run();
         } finally {
-            this.threadStoppedListener.threadStopped(this);
+            this.threadLifecycleListener.threadStopped(this);
         }
     }
     

Copied: geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ThreadLifecycleListener.java
(from r650242, geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ThreadStoppedListener.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ThreadLifecycleListener.java?p2=geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ThreadLifecycleListener.java&p1=geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ThreadStoppedListener.java&r1=650242&r2=650251&rev=650251&view=diff
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ThreadStoppedListener.java
(original)
+++ geronimo/sandbox/concurrent/geronimo-concurrent-core/src/main/java/org/apache/geronimo/concurrent/thread/ThreadLifecycleListener.java
Mon Apr 21 13:45:11 2008
@@ -16,8 +16,10 @@
  */
 package org.apache.geronimo.concurrent.thread;
 
-public interface ThreadStoppedListener {
+public interface ThreadLifecycleListener {
 
+    void threadStarted(Thread thread);
+    
     void threadStopped(Thread thread);
     
 }

Modified: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedThreadFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedThreadFactory.java?rev=650251&r1=650250&r2=650251&view=diff
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedThreadFactory.java
(original)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/executor/ServerManagedThreadFactory.java
Mon Apr 21 13:45:11 2008
@@ -28,7 +28,7 @@
 import org.apache.geronimo.concurrent.impl.thread.GeronimoManagedThreadFactory;
 import org.apache.geronimo.concurrent.impl.thread.ManagedThreadGBean;
 import org.apache.geronimo.concurrent.thread.ManagedThread;
-import org.apache.geronimo.concurrent.thread.ThreadStoppedListener;
+import org.apache.geronimo.concurrent.thread.ThreadLifecycleListener;
 import org.apache.geronimo.management.ManagedConstants;
 
 /**
@@ -36,7 +36,7 @@
  * ServerManagedExecutorService or ServerManagedScheduledExecutorService.
  */
 public class ServerManagedThreadFactory 
-    implements ManagedThreadFactory, ThreadStoppedListener {
+    implements ManagedThreadFactory, ThreadLifecycleListener {
 
     private GeronimoManagedThreadFactory factory;
     private NotificationHelper notificationHelper;
@@ -63,7 +63,7 @@
         GeronimoManagedThread thread = (GeronimoManagedThread)this.factory.newThread(runnable);

         
         // set listener so that this class gets notifications of thread stop
-        thread.setThreadStoppedListener(this);
+        thread.setThreadLifecycleListener(this);
                 
         this.threads.add(thread);
         
@@ -73,6 +73,10 @@
         return thread;
     }
             
+    public void threadStarted(Thread thread) {
+        this.factory.threadStarted(thread);
+    }
+    
     public void threadStopped(Thread thread) {
         this.threads.remove(thread);
         this.factory.threadStopped(thread);

Modified: geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/GeronimoManagedThread.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/GeronimoManagedThread.java?rev=650251&r1=650250&r2=650251&view=diff
==============================================================================
--- geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/GeronimoManagedThread.java
(original)
+++ geronimo/sandbox/concurrent/geronimo-concurrent/src/main/java/org/apache/geronimo/concurrent/impl/thread/GeronimoManagedThread.java
Mon Apr 21 13:45:11 2008
@@ -17,7 +17,7 @@
 package org.apache.geronimo.concurrent.impl.thread;
 
 import org.apache.geronimo.concurrent.thread.ManagedThread;
-import org.apache.geronimo.concurrent.thread.ThreadStoppedListener;
+import org.apache.geronimo.concurrent.thread.ThreadLifecycleListener;
 
 public class GeronimoManagedThread extends ManagedThread {
     
@@ -27,8 +27,8 @@
     public GeronimoManagedThread(ThreadGroup group,
                                  Runnable runnable, 
                                  String name,
-                                 ThreadStoppedListener threadStoppedListener) {
-        super(group, runnable, name, threadStoppedListener);
+                                 ThreadLifecycleListener threadLifecycleListener) {
+        super(group, runnable, name, threadLifecycleListener);
     }
 
     public ManagedThreadGBean getGbean() {

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=650251&r1=650250&r2=650251&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
Mon Apr 21 13:45:11 2008
@@ -28,14 +28,14 @@
 import org.apache.geronimo.concurrent.ManagedContextHandler;
 import org.apache.geronimo.concurrent.thread.ManagedRunnable;
 import org.apache.geronimo.concurrent.thread.ManagedThread;
-import org.apache.geronimo.concurrent.thread.ThreadStoppedListener;
+import org.apache.geronimo.concurrent.thread.ThreadLifecycleListener;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelRegistry;
 import org.apache.geronimo.kernel.lifecycle.LifecycleListener;
 
-public class StandaloneManagedThreadFactory implements ManagedThreadFactory, ThreadStoppedListener
{
+public class StandaloneManagedThreadFactory implements ManagedThreadFactory, ThreadLifecycleListener
{
 
     private GeronimoManagedThreadFactory threadFactory;    
     private ManagedContextHandler contextHandler;
@@ -67,6 +67,10 @@
 
     protected boolean isRunning() {
         return this.moduleLifecyleListener.isRunning();
+    }
+    
+    public void threadStarted(Thread thread) {       
+        this.threadFactory.threadStarted(thread);
     }
     
     public void threadStopped(Thread thread) {



Mime
View raw message