View Javadoc

1   /*$Id: AbstractInProcessDispatcher.java,v 1.2 2005/03/13 07:13:39 clq2 Exp $
2    * Created on 11-Mar-2005
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.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          //start it running.
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  $Log: AbstractInProcessDispatcher.java,v $
66  Revision 1.2  2005/03/13 07:13:39  clq2
67  merging jes-nww-686 common-nww-686 workflow-nww-996 scripting-nww-995 cea-nww-994
68  
69  Revision 1.1.2.1  2005/03/11 14:04:03  nw
70  added new kinds of dispatcher.
71   
72  */