View Javadoc

1   /*$Id: BasicJesComponentManager.java,v 1.8 2006/01/04 09:52:32 clq2 Exp $
2    * Created on 07-Mar-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.component;
12  
13  import org.astrogrid.component.ComponentManagerException;
14  import org.astrogrid.component.descriptor.ComponentDescriptor;
15  import org.astrogrid.component.descriptor.SimpleComponentDescriptor;
16  import org.astrogrid.config.SimpleConfig;
17  import org.astrogrid.jes.component.production.GroovyComponentManager;
18  import org.astrogrid.jes.delegate.v1.jobcontroller.JobController;
19  import org.astrogrid.jes.delegate.v1.jobmonitor.JobMonitor;
20  import org.astrogrid.jes.impl.workflow.AbstractJobFactoryImpl;
21  import org.astrogrid.jes.impl.workflow.CachingFileJobFactory;
22  import org.astrogrid.jes.impl.workflow.FileJobFactoryImpl;
23  import org.astrogrid.jes.jobscheduler.Dispatcher;
24  import org.astrogrid.jes.jobscheduler.JobScheduler;
25  import org.astrogrid.jes.jobscheduler.Locator;
26  import org.astrogrid.jes.jobscheduler.dispatcher.CeaApplicationDispatcher;
27  import org.astrogrid.jes.jobscheduler.dispatcher.CompositeDispatcher;
28  import org.astrogrid.jes.jobscheduler.dispatcher.ConeSearchDispatcher;
29  import org.astrogrid.jes.jobscheduler.dispatcher.SiapDispatcher;
30  import org.astrogrid.jes.jobscheduler.dispatcher.SsapDispatcher;
31  import org.astrogrid.jes.jobscheduler.dispatcher.inprocess.InProcessCeaComponentManager;
32  import org.astrogrid.jes.jobscheduler.impl.SchedulerTaskQueueDecorator;
33  import org.astrogrid.jes.jobscheduler.locator.XMLFileLocator;
34  import org.astrogrid.jes.resultlistener.JesResultsListener;
35  import org.astrogrid.jes.service.v1.cearesults.ResultsListener;
36  import org.astrogrid.jes.util.BaseDirectory;
37  import org.astrogrid.jes.util.TemporaryBuffer;
38  import org.astrogrid.jes.util.TemporaryBaseDirectory;
39  
40  import org.picocontainer.Parameter;
41  import org.picocontainer.defaults.ComponentParameter;
42  import org.picocontainer.defaults.ConstantParameter;
43  import org.picocontainer.defaults.ConstructorInjectionComponentAdapter;
44  
45  import java.net.URI;
46  import java.net.URL;
47  
48  /*** Basic stand-alone component set up - no need for external config file.
49   * <p>
50   * used for testing, etc.
51   * @author Noel Winstanley nw@jb.man.ac.uk 07-Mar-2004
52   *
53   */
54  public class BasicJesComponentManager extends EmptyJesComponentManager {
55      
56      /*** Construct a new BasicComponentManager
57       * 
58       */
59      public BasicJesComponentManager() throws ComponentManagerException{
60          super();
61          try {
62          defaultCallbackURL = new URI("http://localhost:8080/astrogrid-jes/services/JobMonitor");
63          defaultResultListenerURL = new URI("http://localhost:8080/astrogrid-jes/service/ResultListenerService");
64          pico.registerComponentInstance("jes-meta",JES_META);
65          pico.registerComponentImplementation(JobScheduler.class,SchedulerTaskQueueDecorator.class,
66          new Parameter[] {
67              new ComponentParameter(SCHEDULER_ENGINE)
68          }
69          );
70  
71           GroovyComponentManager.registerGroovyEngine(pico);     
72           // dispatchers.
73           pico.registerComponentImplementation(Dispatcher.class,CompositeDispatcher.class); // _the_ dispatcher.
74           pico.registerComponentImplementation(CeaApplicationDispatcher.class); // dispatch cea tools         
75           pico.registerComponentInstance(CeaApplicationDispatcher.Endpoints.class, 
76               new CeaApplicationDispatcher.Endpoints() {
77               public URI monitorEndpoint() {
78                   return defaultCallbackURL;
79               }
80  
81               public URI resultListenerEndpoint() {
82                   return defaultResultListenerURL;
83               }            
84           });
85          pico.registerComponentImplementation(ConeSearchDispatcher.class); // dispach cone searches.
86          pico.registerComponentImplementation(SiapDispatcher.class);
87          pico.registerComponentImplementation(SsapDispatcher.class);
88          // used for in-process cea dispatchers
89          // as a work-around for a bug (picos don't register themselves anymore, but claim they do), need to set up parameters for this component by hand.
90          pico.registerComponentImplementation(InProcessCeaComponentManager.class,InProcessCeaComponentManager.class,
91                  new Parameter[]{
92                      new ConstantParameter(pico)
93                      , new ConstantParameter(SimpleConfig.getSingleton())                    
94          }                    
95         );
96          
97    
98          pico.registerComponentImplementation(Locator.class,XMLFileLocator.class);
99          pico.registerComponentInstance(XMLFileLocator.ToolList.class,
100             new XMLFileLocator.ToolList() {
101 
102                 public URL getURL() {
103                     return this.getClass().getResource("/org/astrogrid/jes/jobscheduler/locator/tools.xml");
104                 }
105             });
106             
107     //    pico.registerComponentImplementation(AbstractJobFactoryImpl.class,InMemoryJobFactoryImpl.class); // could possibly get away with file here..
108     //    pico.registerComponentImplementation(NameGen.class,RandomNameGen.class);
109         pico.registerComponentImplementation(AbstractJobFactoryImpl.class,CachingFileJobFactory.class);
110         pico.registerComponentImplementation(JobMonitor.class,org.astrogrid.jes.jobmonitor.JobMonitor.class);
111         pico.registerComponentImplementation(ResultsListener.class,JesResultsListener.class);
112         pico.registerComponentImplementation(JobController.class,org.astrogrid.jes.jobcontroller.JobController.class);
113         pico.registerComponentImplementation(BaseDirectory.class,org.astrogrid.jes.util.TemporaryBaseDirectory.class);
114         // register factory for temp buffers- so each component that requires one is passed it.
115         pico.registerComponent(new ConstructorInjectionComponentAdapter(TemporaryBuffer.class,TemporaryBuffer.class));
116                
117         } catch (Exception e) {
118             log.fatal("Could not create component manager",e);
119             throw new ComponentManagerException(e);
120         }
121     }
122 
123     // will do something better here later.
124     protected final URI defaultCallbackURL; 
125     protected final URI defaultResultListenerURL;
126     /*** @todo add config tests for a basic system in here */
127     private static final ComponentDescriptor JES_META = new SimpleComponentDescriptor(
128         "Basic Job Execution System",
129         "job execution system - testing configuration"
130     );
131     
132     
133     
134 }
135 
136 
137 /* 
138 $Log: BasicJesComponentManager.java,v $
139 Revision 1.8  2006/01/04 09:52:32  clq2
140 jes-gtr-1462
141 
142 Revision 1.7.42.1  2005/12/09 23:11:55  gtr
143 I refactored the base-directory feature out of its inner class and interface in FileJobFactory and into org.aastrogrid.jes.util. This addresses part, but not all, of BZ1487.
144 
145 Revision 1.7  2005/04/25 12:13:54  clq2
146 jes-nww-776-again
147 
148 Revision 1.6.20.2  2005/04/11 16:31:14  nw
149 updated version of xstream.
150 added caching to job factory
151 
152 Revision 1.6.20.1  2005/04/11 13:57:58  nw
153 altered to use fileJobFactory instead of InMemoryJobFactory - more realistic
154 
155 Revision 1.6  2005/03/13 07:13:39  clq2
156 merging jes-nww-686 common-nww-686 workflow-nww-996 scripting-nww-995 cea-nww-994
157 
158 Revision 1.5.36.1  2005/03/11 14:01:41  nw
159 changes to work with pico1.1, and linked in the In-process
160 cea server
161 
162 Revision 1.5  2004/11/05 16:52:42  jdt
163 Merges from branch nww-itn07-scratchspace
164 
165 Revision 1.4.60.1  2004/11/05 15:25:22  nw
166 added temporary buffers into the component manager
167 
168 Revision 1.4  2004/08/03 16:31:25  nw
169 simplified interface to dispatcher and locator components.
170 removed redundant implementations.
171 
172 Revision 1.3  2004/07/30 15:42:34  nw
173 merged in branch nww-itn06-bz#441 (groovy scripting)
174 
175 Revision 1.2.20.3  2004/07/30 15:10:04  nw
176 removed policy-based implementation,
177 adjusted tests, etc to use groovy implementation
178 
179 Revision 1.2.20.2  2004/07/28 16:24:23  nw
180 finished groovy beans.
181 moved useful tests from old python package.
182 removed python implemntation
183 
184 Revision 1.2.20.1  2004/07/27 23:37:59  nw
185 refactoed framework.
186 experimented with betwixt - can't get it to work.
187 got XStream working in 5 mins.
188 about to remove betwixt code.
189 
190 Revision 1.2  2004/07/09 09:30:28  nw
191 merged in scripting workflow interpreter from branch
192 nww-x-workflow-extensions
193 
194 Revision 1.9  2004/07/01 21:15:00  nw
195 added results-listener interface to jes
196 
197 Revision 1.8  2004/07/01 11:19:05  nw
198 updated interface with cea - part of cea componentization
199 
200 Revision 1.7  2004/03/18 10:53:54  nw
201 upgraded to use join policy
202 
203 Revision 1.6  2004/03/15 23:45:07  nw
204 improved javadoc
205 
206 Revision 1.5  2004/03/15 01:30:06  nw
207 factored component descriptor out into separate package
208 
209 Revision 1.4  2004/03/15 00:30:19  nw
210 updaed to refer to moved classes
211 
212 Revision 1.3  2004/03/15 00:06:57  nw
213 removed SchedulerNotifier interface - replaced references to it by references to JobScheduler interface - identical
214 
215 Revision 1.2  2004/03/07 21:04:38  nw
216 merged in nww-itn05-pico - adds picocontainer
217 
218 Revision 1.1.2.1  2004/03/07 20:39:47  nw
219 reimplemented component-manager framework to use picocontainer
220  
221 */