1
2
3
4
5
6
7
8
9
10
11 package org.astrogrid.jes.jobscheduler.dispatcher;
12
13 import org.astrogrid.applications.CeaException;
14 import org.astrogrid.applications.component.CEAComponentManager;
15 import org.astrogrid.jes.JesException;
16 import org.astrogrid.jes.jobscheduler.Dispatcher;
17 import org.astrogrid.jes.jobscheduler.dispatcher.inprocess.InProcessQueryService;
18 import org.astrogrid.workflow.beans.v1.Tool;
19 import org.astrogrid.workflow.beans.v1.Workflow;
20
21 /*** Abstract class for all dispatchers that dispatch a step to a cea application in the in-process cea server.
22 * @author Noel Winstanley nw@jb.man.ac.uk 11-Mar-2005
23 *
24 */
25 public abstract class AbstractInProcessDispatcher implements Dispatcher {
26
27
28 public AbstractInProcessDispatcher(CEAComponentManager cea) {
29 super();
30 this.cea = cea;
31 }
32 protected final CEAComponentManager cea;
33
34 /*** Dispatching any internal application follows the same pattern - massage the tool parameters as needed,
35 * create the cea application call
36 * register in-process resylts and progress listeners,
37 * start the cea application running.
38 * @see org.astrogrid.jes.jobscheduler.Dispatcher#dispatchStep(org.astrogrid.workflow.beans.v1.Workflow, org.astrogrid.workflow.beans.v1.Tool, java.lang.String)
39 */
40 public void dispatchStep(Workflow wf, Tool tool, String id)
41 throws JesException {
42 try {
43 tool = transformTool(tool);
44 String ceaId = cea.getExecutionController().init(tool,id);
45 cea.getQueryService().registerProgressListener(ceaId,InProcessQueryService.INPROCESS_URI);
46 cea.getQueryService().registerResultsListener(ceaId,InProcessQueryService.INPROCESS_URI);
47
48 cea.getExecutionController().execute(ceaId);
49 } catch (CeaException e) {
50 throw new JesException("Could not dispatch job to inprocess cea service",e);
51 }
52 }
53
54 /*** extension point that externders can implement to massage structure of tool document before its submitted to
55 * the in-process cea.
56 * @param tool
57 */
58 protected abstract Tool transformTool(Tool tool) ;
59
60
61 }
62
63
64
65
66
67
68
69
70
71
72