1
2
3
4
5
6
7
8
9
10
11 package org.astrogrid.jes.jobscheduler.dispatcher;
12
13 import org.astrogrid.component.descriptor.ComponentDescriptor;
14 import org.astrogrid.jes.JesException;
15 import org.astrogrid.jes.jobscheduler.Dispatcher;
16 import org.astrogrid.workflow.beans.v1.Tool;
17 import org.astrogrid.workflow.beans.v1.Workflow;
18
19 import junit.framework.Test;
20
21 /*** A dispatcher that is a composite of a set og other dispatchers - and dispatches to the correct dispatcher accordingly!
22 * could either hard-code the composite, - but then would need to construct and initialize each item (not the container-based way).
23 * or make it so that it's populated by the picocontainer from whatever dispathers are in the container - would require new interfaces to let the composite determine when each dispatcher applies
24 * so will come with a compromise for now - composite has hard-coded rules, but lets pico create the (fixed set) of composite items.
25 * @todo later make it all assembled by picocontainer - i.e. not a fixed number of dispatchers, but arbitrary list, and selection of correct dispatcher done using
26 * some kind of strategy / chain pattern (is this the correct name?)
27 * @author Noel Winstanley nw@jb.man.ac.uk 07-Feb-2005
28 *
29 */
30 public class CompositeDispatcher implements Dispatcher, ComponentDescriptor {
31
32 /*** Construct a new CompositeDispatcher
33 *
34 */
35 public CompositeDispatcher(CeaApplicationDispatcher cea,ConeSearchDispatcher cone,SiapDispatcher siap,SsapDispatcher ssap) {
36 super();
37 this.cea = cea;
38 this.cone = cone;
39 this.siap = siap;
40 this.ssap = ssap;
41 }
42
43 protected final Dispatcher cea;
44 protected final Dispatcher cone;
45 protected final Dispatcher siap;
46 protected final Dispatcher ssap;
47
48 /***
49 * @see org.astrogrid.jes.jobscheduler.Dispatcher#dispatchStep(org.astrogrid.workflow.beans.v1.Workflow, org.astrogrid.workflow.beans.v1.Tool, java.lang.String)
50 * @todo at moment, all steps are dispatched by (external)cea dispatcher - implement more fully, so that other dispatchers are fired when needed -
51 * based on tool name, etc. - probalby needs some work on the locators, so that more info on the type of service to call is passed into here.
52 */
53 public void dispatchStep(Workflow wf, Tool tool, String id)
54 throws JesException {
55 cea.dispatchStep(wf,tool,id);
56 }
57
58 /***
59 * @see org.astrogrid.component.descriptor.ComponentDescriptor#getName()
60 */
61 public String getName() {
62 return "Composite Dispatcher";
63 }
64
65 /***
66 * @see org.astrogrid.component.descriptor.ComponentDescriptor#getDescription()
67 */
68 public String getDescription() {
69 return "Composite over a set of dispatcher implementations. determines which to use based on hard-coded rules";
70 }
71
72 /***
73 * @see org.astrogrid.component.descriptor.ComponentDescriptor#getInstallationTest()
74 */
75 public Test getInstallationTest() {
76 return null;
77 }
78
79 }
80
81
82
83
84
85
86
87
88
89
90