View Javadoc

1   /*$Id: JesDelegateFactory.java,v 1.7 2004/03/15 01:30:30 nw Exp $
2    * Created on 06-Feb-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.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  $Log: JesDelegateFactory.java,v $
98  Revision 1.7  2004/03/15 01:30:30  nw
99  jazzed up javadoc
100 
101 Revision 1.6  2004/03/10 12:15:32  nw
102 fixed goof
103 
104 Revision 1.5  2004/03/10 12:13:37  nw
105 added default delegate factory methods
106 
107 Revision 1.4  2004/03/05 16:16:23  nw
108 worked now object model through jes.
109 implemented basic scheduling policy
110 removed internal facade
111 
112 Revision 1.3  2004/02/27 00:46:03  nw
113 merged branch nww-itn05-bz#91
114 
115 Revision 1.2.2.2  2004/02/17 12:25:38  nw
116 improved javadocs for classes
117 
118 Revision 1.2.2.1  2004/02/11 16:09:10  nw
119 refactored delegates (again)
120 
121 Revision 1.2  2004/02/09 11:41:44  nw
122 merged in branch nww-it05-bz#85
123 
124 Revision 1.1.2.1  2004/02/06 18:11:21  nw
125 reworked the delegate classes
126 - introduced wrapper class and interfaces, plus separate impl
127 package with abstract base class. moved delegate classes into the correct
128 packages, deprecated old methods / classes. fitted in castor object model
129  
130 */