1
2
3
4
5
6
7
8
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
75
76
77
78
79
80
81
82
83
84