Tidied version of code attached (shutdownThreads.patch).

What I meant to say in that last email was that I didn't touch
WorkManagerFactoryBean
although it does create a thread pool in some circumstances. I've had a look
at that again now and have attached another patch (shutdownThreadsWMFB.patch
).

cheers, Jerry
On Sat, Mar 1, 2008 at 9:40 PM, Jerry Shea <[EMAIL PROTECTED]> wrote:

> JIRA does not appear to be up - code attached. I didn't touch although I
> guess this should use a JencksWorkManager if it creates a thread pool.
>
> Cheers, Jerry
>
>   On Thu, Feb 28, 2008 at 7:05 PM, Guillaume Nodet <[EMAIL PROTECTED]>
> wrote:
>
> > The project is not dead per se.  This is just that the project has
> > fullfilled its purpose
> > and is no longer actively developped.
> > If there is a need for another release,  I'll do it.
> > So please, raise a JIRA and attach a patch, i'll review and apply it.
> >
> > On Thu, Feb 28, 2008 at 8:31 AM, Andrei Ivanov <[EMAIL PROTECTED]>
> > wrote:
> > > I think it would be nice if you could open an issue for jencks and
> > >  attach the code there...
> > >  Maybe it will even be included in a next version...
> > >  Hmm... http://jira.goopen.org/jira/browse/JCA seems to be dead...
> > >  Well... kind of like this project...
> > >  Post it here then...
> > >  Thank you.
> > >
> > >
> > >
> > >  On 2/28/08, Jerry Shea <[EMAIL PROTECTED]> wrote:
> > >  > I have solved my problem by inhertiting from the Geronimo work
> > manager and
> > >  > doing exactly that. Do you want the code?
> > >  >
> > >  >
> > >  >
> > >  > On Thu, Feb 28, 2008 at 12:59 AM, Guillaume Nodet <[EMAIL PROTECTED]>
> > wrote:
> > >  >
> > >  > > Well, the code seems ok to me, as the thread pools are given to
> > the
> > >  > > work manager.
> > >  > > So they need to be created and shut down from the one that
> > creates the
> > >  > > work manager.
> > >  > > In the jencks case, i'm not sure who does that (haven't looked
> > yet),
> > >  > > but it should be easy
> > >  > > to fix, maybe by inheriting the geronimo work manager and
> > overriding
> > >  > > doStop if needed.
> > >  > >
> > >  > >
> > >  > >
> > >  > >
> > >  > > On Wed, Feb 27, 2008 at 1:58 PM, Andrei Ivanov <
> > [EMAIL PROTECTED]>
> > >  > wrote:
> > >  > > >
> > >  >
> > http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java?view=log
> > >  > > >
> > >  > > >  It seems that code was removed in rev 392847:
> > >  > > >  Make thread pools manageable and make our WorkManager use our
> > thread
> > >  > pools
> > >  > > >   under the covers.
> > >  > > >
> > >  >
> > http://svn.apache.org/viewvc/geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/work/GeronimoWorkManager.java?r1=381272&r2=392847
> > >  > > >
> > >  > > >
> > >  > > >
> > >  > > >  On 2/27/08, Jerry Shea <[EMAIL PROTECTED]> wrote:
> > >  > > >  > geronimo-connector-2.1 has the same problem (empty doStop
> > method)
> > >  > > >  > unfortunately...
> > >  > > >  >
> > >  > > >  > I'm having difficulty finding any more info on
> > geronimo-connector.
> > >  > It's even
> > >  > > >  > proving difficult to find its subversion repository or maybe
> > its just
> > >  > too
> > >  > > >  > late at night ;)
> > >  > > >  >
> > >  > > >  >
> > >  > > >  >
> > >  > > >  >
> > >  > > >  >
> > >  > > >  > On Wed, Feb 27, 2008 at 9:03 PM, Guillaume Nodet <
> > [EMAIL PROTECTED]>
> > >  > wrote:
> > >  > > >  >
> > >  > > >  > > Yeah, good idea.  Maybe a simple version bump would work ?
> > >  > > >  > > Have you tried that, or is there any api changes that we
> > need to
> > >  > deal with
> > >  > > >  > ?
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  > > On Wed, Feb 27, 2008 at 11:02 AM, Jerry Shea <
> > [EMAIL PROTECTED]>
> > >  > wrote:
> > >  > > >  > > > It looks like a more recent version of
> > GeronimoWorkMnaager shuts
> > >  > down
> > >  > > >  > its
> > >  > > >  > > > thread pools in the doStop method - see here:
> > >  > > >  > > >
> > >  > > >  >
> > >  >
> > http://www.docjar.com/html/api/org/apache/geronimo/connector/work/GeronimoWorkManager.java.html
> > >  > > >  > > >
> > >  > > >  > > > Are there any plans to upgrade the the version of
> > >  > geronimo-connector
> > >  > > >  > that
> > >  > > >  > > > Jencks 2.1 depends on? I'm more than happy to assist if
> > needed...
> > >  > > >  > > >
> > >  > > >  > > > Cheers, Jerry
> > >  > > >  > > >
> > >  > > >  > > >
> > >  > > >  > > >
> > >  > > >  > > > On Wed, Feb 27, 2008 at 8:55 PM, JerryShea <
> > [EMAIL PROTECTED]>
> > >  > wrote:
> > >  > > >  > > >
> > >  > > >  > > > >
> > >  > > >  > > > > Hi,
> > >  > > >  > > > >
> > >  > > >  > > > > I've cut and pasted the jencks JCA config from
> > >  > > >  > > > > http://jencks.org/Message+Driven+POJOs and if
> > >  > I use
> > >  > > >  > it like this:
> > >  > > >  > > > >        AbstractApplicationContext ctx = new
> > >  > > >  > > > ClassPathXmlApplicationContext(new
> > >  > > >  > > > > String[] {
> > >  > > >  > > > >                "/spring-jencks.xml",
> > >  > > >  > > > >        });
> > >  > > >  > > > >        Thread.sleep(3000);
> > >  > > >  > > > >        ctx.destroy();
> > >  > > >  > > > >
> > >  > > >  > > > > after the spring application context has been created,
> > a number
> > >  > of
> > >  > > >  > threads
> > >  > > >  > > > > are started up (JCAContainer.afterPropertiesSetcreates a
> > >  > Geronimo
> > >  > > >  > work
> > >  > > >  > > > > manager which in turn creates a thread pool).
> > >  > > >  > > > >
> > >  > > >  > > > > When ctx.destroy is called, JCAContainer.destroy gets
> > called
> > >  > which in
> > >  > > >  > turn
> > >  > > >  > > > > calls geronimoWorkManager.doStop() which does...
> > nothing!
> > >  > > >  > > > >
> > >  > > >  > > > > Shouldn't something be shutting down the thread pool?
> > The
> > >  > threads that
> > >  > > >  > are
> > >  > > >  > > > > created remain alive and prevent my application from
> > closing
> > >  > down.
> > >  > > >  > > > >
> > >  > > >  > > > > Thx, Jerry
> > >  > > >  > > > >
> > >  > > >  > > > > --
> > >  > > >  > > > > View this message in context:
> > >  > > >  > > >
> > >  > > >  >
> > >  >
> > http://www.nabble.com/Jencks-Message-driven-POJOS-threads-left-running-after-ctx.destroy-tp15709825p15709825.html
> > >  > > >  > > > > Sent from the jencks - user mailing list archive at
> > Nabble.com <http://nabble.com/>.
> > >  > > >  > > > >
> > >  > > >  > > > >
> > >  > > >  > > > >
> > >  > > >  >
> > >  >
> > ---------------------------------------------------------------------
> > >  > > >  > > > > To unsubscribe from this list, please visit:
> > >  > > >  > > > >
> > >  > > >  > > > >    http://xircles.codehaus.org/manage_email
> > >  > > >  > > > >
> > >  > > >  > > > >
> > >  > > >  > > > >
> > >  > > >  > > >
> > >  > > >  > > >
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  > > --
> > >  > > >  > > Cheers,
> > >  > > >  > > Guillaume Nodet
> > >  > > >  > > ------------------------
> > >  > > >  > > Blog: http://gnodet.blogspot.com/
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  >
> > >  >
> > ---------------------------------------------------------------------
> > >  > > >  > > To unsubscribe from this list, please visit:
> > >  > > >  > >
> > >  > > >  > >    http://xircles.codehaus.org/manage_email
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  > >
> > >  > > >  >
> > >  > > >  >
> > >  > > >
> > >  > > >
> > >  >
> > ---------------------------------------------------------------------
> > >  > > >  To unsubscribe from this list, please visit:
> > >  > > >
> > >  > > >     http://xircles.codehaus.org/manage_email
> > >  > > >
> > >  > > >
> > >  > > >
> > >  > >
> > >  > >
> > >  > >
> > >  > > --
> > >  > >
> > >  > >
> > >  > >
> > >  > > Cheers,
> > >  > > Guillaume Nodet
> > >  > > ------------------------
> > >  > > Blog: http://gnodet.blogspot.com/
> > >  > >
> > >  > >
> > >  >
> > ---------------------------------------------------------------------
> > >  > > To unsubscribe from this list, please visit:
> > >  > >
> > >  > >    http://xircles.codehaus.org/manage_email
> > >  > >
> > >  > >
> > >  > >
> > >  >
> > >  >
> > >
> > >  ---------------------------------------------------------------------
> > >  To unsubscribe from this list, please visit:
> > >
> > >     http://xircles.codehaus.org/manage_email
> > >
> > >
> > >
> >
> >
> >
> > --
> >  Cheers,
> > Guillaume Nodet
> > ------------------------
> > Blog: http://gnodet.blogspot.com/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >    http://xircles.codehaus.org/manage_email
> >
> >
> >
>
Index: src/main/java/org/jencks/JencksWorkManager.java
===================================================================
--- src/main/java/org/jencks/JencksWorkManager.java     (revision 0)
+++ src/main/java/org/jencks/JencksWorkManager.java     (revision 0)
@@ -0,0 +1,36 @@
+package org.jencks;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+
+import org.apache.geronimo.connector.work.GeronimoWorkManager;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.jencks.factory.GeronimoDefaults;
+
+/**
+ * Jencks-specific override of GeronimoWorkManager which takes responsibility 
for 
+ * creating and shutting down its own thread pool. 
+ * @author Jerry Shea
+ */
+public class JencksWorkManager extends GeronimoWorkManager {
+
+       private JencksWorkManager(Executor threadPool, 
GeronimoTransactionManager transactionManager) {
+               super(threadPool, threadPool, threadPool, transactionManager);
+       }
+
+       /**
+        * Public constructor
+        * @param threadPoolSize size of thread pool to create
+        * @param transactionManager
+        */
+       public JencksWorkManager(int threadPoolSize, GeronimoTransactionManager 
transactionManager) {
+               this(GeronimoDefaults.createThreadPool(threadPoolSize), 
transactionManager);
+       }
+
+       /**
+        * Override base class implementation to shut down our thread pool 
+        */
+    public void doStop() throws Exception {
+       ((ExecutorService)this.getScheduledWorkExecutorPool()).shutdown();
+    }
+}
Index: src/main/java/org/jencks/JencksWorkManager.java
===================================================================
--- src/main/java/org/jencks/JencksWorkManager.java     (revision 0)
+++ src/main/java/org/jencks/JencksWorkManager.java     (revision 0)
@@ -0,0 +1,39 @@
+package org.jencks;
+
+import java.util.concurrent.ExecutorService;
+
+import org.apache.geronimo.connector.work.GeronimoWorkManager;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.jencks.factory.GeronimoDefaults;
+
+/**
+ * Jencks-specific override of GeronimoWorkManager which creates and shuts 
down its own
+ * thread pool. This ensures that no threads will be left running after an 
orderly
+ * shutdown of an instance of this class.
+ * @author Jerry Shea
+ */
+public class JencksWorkManager extends GeronimoWorkManager {
+
+       private ExecutorService threadPool;
+
+       private JencksWorkManager(ExecutorService threadPool, 
GeronimoTransactionManager transactionManager) {
+               super(threadPool, threadPool, threadPool, transactionManager);
+               this.threadPool = threadPool;
+       }
+
+       /**
+        * Public constructor
+        * @param threadPoolSize size of thread pool to create
+        * @param transactionManager
+        */
+       public JencksWorkManager(int threadPoolSize, GeronimoTransactionManager 
transactionManager) {
+               this((ExecutorService) 
GeronimoDefaults.createThreadPool(threadPoolSize), transactionManager);
+       }
+
+       /**
+        * Override base class implementation to shut down our thread pool 
+        */
+    public void doStop() throws Exception {
+       threadPool.shutdown();
+    }
+}
Index: src/main/java/org/jencks/factory/GeronimoDefaults.java
===================================================================
--- src/main/java/org/jencks/factory/GeronimoDefaults.java      (revision 176)
+++ src/main/java/org/jencks/factory/GeronimoDefaults.java      (working copy)
@@ -28,12 +28,12 @@
 import 
org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
 import 
org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
 import 
org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions;
-import org.apache.geronimo.connector.work.GeronimoWorkManager;
 import org.apache.geronimo.transaction.log.UnrecoverableLog;
 import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
 import org.apache.geronimo.transaction.manager.TransactionLog;
 import org.apache.geronimo.transaction.manager.XidFactory;
 import org.apache.geronimo.transaction.manager.XidFactoryImpl;
+import org.jencks.JencksWorkManager;
 import org.springframework.beans.FatalBeanException;
 
 /**
@@ -78,8 +78,7 @@
     }
 
     public static WorkManager createWorkManager(GeronimoTransactionManager 
transactionManager, int threadPoolSize) {
-        Executor threadPool = createThreadPool(threadPoolSize);
-        WorkManager geronimoWorkManager = new GeronimoWorkManager(threadPool, 
threadPool, threadPool, transactionManager);
+        WorkManager geronimoWorkManager = new 
JencksWorkManager(threadPoolSize, transactionManager);
         return geronimoWorkManager;
     }
 
Index: D:/Development/jencks/src/main/java/org/jencks/JencksWorkManager.java
===================================================================
--- D:/Development/jencks/src/main/java/org/jencks/JencksWorkManager.java       
(revision 0)
+++ D:/Development/jencks/src/main/java/org/jencks/JencksWorkManager.java       
(revision 0)
@@ -0,0 +1,36 @@
+package org.jencks;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+
+import org.apache.geronimo.connector.work.GeronimoWorkManager;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
+import org.jencks.factory.GeronimoDefaults;
+
+/**
+ * Jencks-specific override of GeronimoWorkManager which takes responsibility 
for 
+ * creating and shutting down its own thread pool. 
+ * @author Jerry Shea
+ */
+public class JencksWorkManager extends GeronimoWorkManager {
+
+       private JencksWorkManager(Executor threadPool, 
GeronimoTransactionManager transactionManager) {
+               super(threadPool, threadPool, threadPool, transactionManager);
+       }
+
+       /**
+        * Public constructor
+        * @param threadPoolSize size of thread pool to create
+        * @param transactionManager
+        */
+       public JencksWorkManager(int threadPoolSize, GeronimoTransactionManager 
transactionManager) {
+               this(GeronimoDefaults.createThreadPool(threadPoolSize), 
transactionManager);
+       }
+
+       /**
+        * Override base class implementation to shut down our thread pool 
+        */
+    public void doStop() throws Exception {
+       ((ExecutorService)this.getScheduledWorkExecutorPool()).shutdown();
+    }
+}
Index: 
D:/Development/jencks/src/main/java/org/jencks/factory/GeronimoDefaults.java
===================================================================
--- 
D:/Development/jencks/src/main/java/org/jencks/factory/GeronimoDefaults.java    
    (revision 176)
+++ 
D:/Development/jencks/src/main/java/org/jencks/factory/GeronimoDefaults.java    
    (working copy)
@@ -28,12 +28,12 @@
 import 
org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
 import 
org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
 import 
org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions;
-import org.apache.geronimo.connector.work.GeronimoWorkManager;
 import org.apache.geronimo.transaction.log.UnrecoverableLog;
 import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
 import org.apache.geronimo.transaction.manager.TransactionLog;
 import org.apache.geronimo.transaction.manager.XidFactory;
 import org.apache.geronimo.transaction.manager.XidFactoryImpl;
+import org.jencks.JencksWorkManager;
 import org.springframework.beans.FatalBeanException;
 
 /**
@@ -67,10 +67,6 @@
         }
     }
 
-    public static Executor createThreadPool() {
-        return createThreadPool(DEFAULT_THREAD_POOL_SIZE);
-    }
-
     public static Executor createThreadPool(int threadPoolSize) {
         if (threadPoolSize <= 0) threadPoolSize = DEFAULT_THREAD_POOL_SIZE;
         Executor pooledExecutor = Executors.newFixedThreadPool(threadPoolSize);
@@ -78,8 +74,7 @@
     }
 
     public static WorkManager createWorkManager(GeronimoTransactionManager 
transactionManager, int threadPoolSize) {
-        Executor threadPool = createThreadPool(threadPoolSize);
-        WorkManager geronimoWorkManager = new GeronimoWorkManager(threadPool, 
threadPool, threadPool, transactionManager);
+        WorkManager geronimoWorkManager = new 
JencksWorkManager(threadPoolSize, transactionManager);
         return geronimoWorkManager;
     }
 
Index: 
D:/Development/jencks/src/main/java/org/jencks/factory/WorkManagerFactoryBean.java
===================================================================
--- 
D:/Development/jencks/src/main/java/org/jencks/factory/WorkManagerFactoryBean.java
  (revision 176)
+++ 
D:/Development/jencks/src/main/java/org/jencks/factory/WorkManagerFactoryBean.java
  (working copy)
@@ -19,6 +19,7 @@
 
 import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
 import org.apache.geronimo.connector.work.GeronimoWorkManager;
+import org.jencks.JencksWorkManager;
 import org.springframework.beans.FatalBeanException;
 import org.springframework.beans.factory.FactoryBean;
 import org.springframework.beans.factory.InitializingBean;
@@ -42,7 +43,13 @@
 
     public Object getObject() throws Exception {
         if (workManager == null) {
-            workManager = new GeronimoWorkManager(threadPool, threadPool, 
threadPool, transactionManager);
+            if (threadPool == null) {
+               // JencksWorkManager will create and destroy the thread pool
+                workManager = new JencksWorkManager(threadPoolSize, 
transactionManager);
+            }
+            else {
+               workManager = new GeronimoWorkManager(threadPool, threadPool, 
threadPool, transactionManager);
+            }
             workManager.doStart();
         }
         return workManager;
@@ -68,11 +75,6 @@
         if (transactionManager == null) {
             throw new FatalBeanException("Geronimo transaction manager was not 
set");
         }
-
-        // create a default thread pool if one was not specified
-        if (threadPool == null) {
-            threadPool = 
GeronimoDefaults.createThreadPool(getThreadPoolSize());
-        }
     }
 
     public GeronimoTransactionManager getTransactionManager() {
---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to