View Javadoc

1   /*$Id: ThreadPoolExecutionController.java,v 1.3 2004/09/22 10:52:50 pah Exp $
2    * Created on 14-Sep-2004
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid 
7    * Software License version 1.2, a copy of which has been included 
8    * with this distribution in the LICENSE.txt file.  
9    *
10  **/
11  package org.astrogrid.applications.manager;
12  
13  import org.astrogrid.applications.description.ApplicationDescriptionLibrary;
14  import org.astrogrid.applications.manager.persist.ExecutionHistory;
15  import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
16  
17  import junit.framework.Test;
18  
19  /*** implementation of {@link org.astrogrid.applications.manager.ExecutionController} that manages a pool of workr threads.
20   * @author Noel Winstanley nw@jb.man.ac.uk 14-Sep-2004
21   *
22   */
23  public class ThreadPoolExecutionController extends DefaultExecutionController {
24  
25  
26      /*** Construct a new ThreadPoolExecutionController
27       * @param library
28       * @param executionHistory
29       */
30      public ThreadPoolExecutionController(ApplicationDescriptionLibrary library, ExecutionHistory executionHistory, PooledExecutor executor) {
31          super(library, executionHistory);
32          this.executor = executor;
33      }
34      protected final PooledExecutor executor;
35  
36  
37      protected boolean startRunnable(Runnable r) {
38          try {
39              executor.execute(r);
40              return true;
41          } catch (InterruptedException e) {
42              logger.debug("InterruptedException",e);
43              return false;
44          }
45      }
46  
47       
48      /***
49       * @see org.astrogrid.component.descriptor.ComponentDescriptor#getName()
50       */
51      public String getName() {
52          return "Thread Pool Execution Controller";
53      }
54  
55      /***
56       * @see org.astrogrid.component.descriptor.ComponentDescriptor#getDescription()
57       */
58      public String getDescription() {
59          return "Thread pool info " + executor.getClass().getName() + "\n" + executor.toString();
60      }
61  
62      /***
63       * @see org.astrogrid.component.descriptor.ComponentDescriptor#getInstallationTest()
64       */
65      public Test getInstallationTest() {
66          return null;
67      }
68  
69  
70  }
71  
72  
73  /* 
74  $Log: ThreadPoolExecutionController.java,v $
75  Revision 1.3  2004/09/22 10:52:50  pah
76  getting rid of some unused imports
77  
78  Revision 1.2  2004/09/17 01:21:49  nw
79  implemented execution controller that uses a threadpool
80  
81  Revision 1.1.2.1  2004/09/14 13:45:22  nw
82  implemented thread pooling
83   
84  */