1
2
3
4
5
6
7
8
9
10
11 package org.astrogrid.jes.delegate;
12
13 import org.astrogrid.config.PropertyNotFoundException;
14 import org.astrogrid.config.SimpleConfig;
15 import org.astrogrid.jes.delegate.impl.JobControllerDelegate;
16 import org.astrogrid.jes.delegate.impl.JobMonitorDelegate;
17
18 import java.net.URL;
19
20 /*** Factory for JES delegates.
21 * <p>
22 * Delegates to JES web services - JobController and JobMonitor - can be created by either passing in a service endpoint explicitly, or by letting the factory
23 * try to locate an endpoint in the system configuration.
24 * @author Noel Winstanley nw@jb.man.ac.uk 06-Feb-2004
25 *
26 */
27 public class JesDelegateFactory {
28
29 /*** default key to search config for a controller endpoint */
30 public static final String JOB_CONTROLLER_ENDPOINT_KEY = "jes.job.controller.endpoint";
31 /*** default key to search config for a monitor endpoint */
32 public static final String JOB_MONITOR_ENDPOINT_KEY = "jes.job.monitor.endpoint";
33
34 /*** create a job controller delegate
35 *
36 * @param url endpoint
37 * @return a delegate
38 */
39 public static JobController createJobController(String url) {
40 return JobControllerDelegate.buildDelegate(url);
41 }
42 /*** create a job controller delegate
43 *
44 * @param url endpoint of service to connect to
45 * @param timeout timeout value to use for connection
46 * @return a delegate
47 */
48 public static JobController createJobController(String url, int timeout){
49 return JobControllerDelegate.buildDelegate(url,timeout);
50 }
51
52 /***
53 * create a job controller delegate, loading endpoint from Config
54 *
55 * @return a delegate
56 @throws PropertyNotFoundException if key {@link #JOB_CONTROLLER_ENDPOINT_KEY} is not found in default config
57 @see SimpleConfig
58 */
59 public static JobController createJobController() throws PropertyNotFoundException{
60 URL endpoint = SimpleConfig.getSingleton().getUrl(JOB_CONTROLLER_ENDPOINT_KEY);
61 return JobControllerDelegate.buildDelegate(endpoint.toString());
62 }
63
64 /*** create a job monitor delegate
65 *
66 * @param url endpoint of monitor service
67 * @return a delegate for this service
68 */
69 public static JobMonitor createJobMonitor(String url) {
70 return JobMonitorDelegate.buildDelegate(url);
71 }
72 /*** create a job monitor delegate
73 *
74 * @param url endpoint of monitor service
75 * @param timeout timeout value for the connection
76 * @return a delegate for this service
77 */
78 public static JobMonitor createJobMonitor(String url, int timeout) {
79 return JobMonitorDelegate.buildDelegate(url,timeout);
80 }
81
82 /*** create a job monitor delegate, loading endpoint from Config
83 *
84 * @return a delegate
85 * @throws PropertyNotFoundException if key {@link #JOB_MONITOR_ENDPOINT_KEY} is not found in default config
86 * @see SimpleConfig
87 */
88 public static JobMonitor createJobMonitor() throws PropertyNotFoundException {
89 URL endpoint = SimpleConfig.getSingleton().getUrl(JOB_MONITOR_ENDPOINT_KEY);
90 return JobMonitorDelegate.buildDelegate(endpoint.toString());
91 }
92
93 }
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130