View Javadoc

1   /*
2    * $Id: CommonExecutionConnectorServiceSoapBindingImpl.java,v 1.11 2004/11/27 13:20:03 pah Exp $
3    * 
4    * Created on 25-Mar-2004 by Paul Harrison (pah@jb.man.ac.uk)
5    *
6    * Copyright 2004 AstroGrid. All rights reserved.
7    *
8    * This software is published under the terms of the AstroGrid 
9    * Software License version 1.2, a copy of which has been included 
10   * with this distribution in the LICENSE.txt file.  
11   *
12   */ 
13  
14  package org.astrogrid.applications.service.v1.cea;
15  
16  import org.apache.commons.logging.Log;
17  import org.apache.commons.logging.LogFactory;
18  
19  import org.astrogrid.applications.component.CEAComponentManagerFactory;
20  import org.astrogrid.applications.manager.ExecutionController;
21  import org.astrogrid.applications.manager.QueryService;
22  import org.astrogrid.common.bean.Axis2Castor;
23  import org.astrogrid.common.bean.Castor2Axis;
24  import org.astrogrid.jes.types.v1.cea.axis.ExecutionSummaryType;
25  import org.astrogrid.jes.types.v1.cea.axis.JobIdentifierType;
26  import org.astrogrid.jes.types.v1.cea.axis.MessageType;
27  import org.astrogrid.jes.types.v1.cea.axis.ResultListType;
28  import org.astrogrid.workflow.beans.v1.Tool;
29  import org.astrogrid.workflow.beans.v1.axis._tool;
30  
31  import org.apache.axis.description.ServiceDesc;
32  import org.apache.axis.types.URI;
33  
34  import java.rmi.RemoteException;
35  
36  /***
37   * This is the main implementation of the CommonExecutionConnectorService. This is the class that should be referenced in the Axis wsdd file.
38   * Its main task is to convert between axis and castor object representations, and then delegate to the appropriate component in the componentManager 
39   * <p>
40   * Catches all exceptions, propagates them as {@link org.astrogrid.applications.service.v1.cea.CeaFault} messages back to the caller.
41   * @author Paul Harrison (pah@jb.man.ac.uk) 25-Mar-2004
42   * @author Noel Winstanley
43   * @version $Name:  $
44   * @since iteration5
45   */
46  public class CommonExecutionConnectorServiceSoapBindingImpl implements CommonExecutionConnector {
47      /***
48       * Logger for this class
49       */
50      private static final Log logger = LogFactory.getLog(CommonExecutionConnectorServiceSoapBindingImpl.class);
51  
52  
53        
54        protected  final ExecutionController cec;
55        protected final QueryService query;
56  
57     /***
58      * 
59      */
60     public CommonExecutionConnectorServiceSoapBindingImpl() {
61        try {
62            //TODO need to get this service description into pico
63           ServiceDesc servicedesc = org.apache.axis.MessageContext.getCurrentContext().getService().getServiceDescription();
64   
65           cec = CEAComponentManagerFactory.getInstance().getExecutionController();
66          
67           //nController(servicedesc);
68        }
69        catch (Throwable e) {         
70           logger.fatal("problem instatiating applicationController", e);
71           //we're stuffed - no point continuing.
72           throw new RuntimeException("Could not instantiate application controller",e);
73        }
74        try {
75            query = CEAComponentManagerFactory.getInstance().getQueryService();
76        } catch (Throwable e) {
77            logger.fatal("problem instantiating querier",e);
78            throw new RuntimeException("Could not instantiate query service",e);
79        }
80        
81     }
82  
83     /*** 
84      * @see org.astrogrid.applications.service.v1.cea.CommonExecutionConnector#execute(org.astrogrid.workflow.beans.v1.axis._tool, org.astrogrid.jes.types.v1.cea.axis.JobIdentifierType, java.lang.String)
85      */
86     public String init(_tool tool, JobIdentifierType jobstepID)
87        throws RemoteException, CeaFault {           
88           try {           
89               Tool ctool = Axis2Castor.convert(tool); 
90              return cec.init(ctool, jobstepID.toString());
91           }
92           catch (Exception e) {
93             logger.error("init(_tool tool = " + tool + ") - Throwable caught:", e);
94             throw CeaFault.makeFault(e);
95           }
96           catch(Throwable e) {
97              logger.error("init(_tool tool = " + tool + ") - Exception caught:", e);
98              throw CeaFault.makeFault(new Exception("an Throwable occurred in init-"+e.getMessage(), e));
99           }
100    }
101 
102    /***
103     * @see org.astrogrid.applications.service.v1.cea.CommonExecutionConnector#execute(java.lang.String)
104     */
105    public boolean execute(String arg0) throws RemoteException, CeaFault {
106        try {
107            return cec.execute(arg0);
108        } catch (Exception e) {
109         logger.error("execute("+ arg0 + ")", e);
110 
111            throw CeaFault.makeFault(e);
112        } catch (Throwable e) {
113         logger.error("execute("+ arg0 +")", e);
114            throw CeaFault.makeFault(new Exception("a throwable occurred in execute-"+e.getMessage(),e)); 
115        }
116    }
117 
118    /*** 
119     * @see org.astrogrid.applications.service.v1.cea.CommonExecutionConnector#abort(java.lang.String)
120     */
121    public boolean abort(String executionId) throws RemoteException, CeaFault {
122       try {
123             return cec.abort(executionId);
124       } catch (Exception e) {
125         logger.error("abort(" + executionId + ")", e);
126           throw CeaFault.makeFault(e);
127       } catch (Throwable t) {
128         logger.error("abort(" + executionId+")", t);
129           throw CeaFault.makeFault(new Exception("a throwable occurred in abort",t));
130    }
131    }
132 
133 
134    /*** 
135     * @see org.astrogrid.applications.service.v1.cea.CommonExecutionConnector#queryExecutionStatus(java.lang.String)
136     */
137    public MessageType queryExecutionStatus(String executionId)
138       throws RemoteException, CeaFault {
139          try {
140             org.astrogrid.applications.beans.v1.cea.castor.MessageType mess = query.queryExecutionStatus(executionId);
141             return  Castor2Axis.convert(mess);
142          }
143          catch (Exception e) {
144             logger.error("queryExecutionStatus(" + executionId+")", e);
145             throw CeaFault.makeFault(e);
146          }
147          catch(Throwable e)
148          {
149             logger.error("queryExecutionStatus(" + executionId+")", e);
150             throw CeaFault.makeFault(new Exception("an Throwable occurred in query status-"+e.getMessage(), e));
151          }
152    }
153      
154 /***
155  * @see org.astrogrid.applications.service.v1.cea.CommonExecutionConnector#registerResultsListener(java.lang.String, org.apache.axis.types.URI)
156  */
157 public boolean registerResultsListener(String arg0, URI arg1) throws RemoteException, CeaFault {
158     try {
159         return query.registerResultsListener(arg0,new java.net.URI(arg1.toString()));
160     } catch (Exception e) {
161         logger.error("registerResultsListener(" + arg0 + ", " + arg1+")", e);
162         throw CeaFault.makeFault(e);
163     } catch (Throwable e) {
164         logger.error("registerResultsListener(" + arg0 + ", " + arg1 +")", e);
165         throw CeaFault.makeFault(new Exception("a throwable occurred in registerResultsListener-"+e.getMessage(),e));
166     }
167 }
168 
169 /***
170  * @see org.astrogrid.applications.service.v1.cea.CommonExecutionConnector#registerProgressListener(java.lang.String, org.apache.axis.types.URI)
171  */
172 public boolean registerProgressListener(String arg0, URI arg1) throws RemoteException, CeaFault {
173     try {
174         return query.registerProgressListener(arg0,new java.net.URI(arg1.toString()));
175     } catch (Exception e) {
176         logger.error("registerProgressListener(" + arg0 + ", " + arg1+")", e);
177         throw CeaFault.makeFault(e);
178     } catch (Throwable e) {
179         logger.error("registerProgressListener(" + arg0 + ", " + arg1 +")", e);
180 
181         throw CeaFault.makeFault(new Exception("a throwable occurred in registerProgressListener-"+e.getMessage(),e));
182     }
183 }
184 
185 /***
186  * @see org.astrogrid.applications.service.v1.cea.CommonExecutionConnector#getExecutionSummary(java.lang.String)
187  */
188 public ExecutionSummaryType getExecutionSummary(String arg0) throws RemoteException, CeaFault {
189     try {
190         return Castor2Axis.convert(query.getSummary(arg0));
191     } catch (Exception e) {
192         logger.error("getExecutionSummary("+arg0+")", e);
193         throw CeaFault.makeFault(e);
194     } catch (Throwable e) {
195         logger.error("getExecutionSummary("+arg0+")", e);
196         throw CeaFault.makeFault(new Exception("a throwable occurred in getExecutionSummary-"+e.getMessage(),e));
197     }
198 }
199 /***
200  * @see org.astrogrid.applications.service.v1.cea.CommonExecutionConnector#getResults(java.lang.String)
201  */
202 public ResultListType getResults(String arg0) throws RemoteException, CeaFault {
203     try {
204         return Castor2Axis.convert(query.getResults(arg0));
205     } catch (Exception e) {
206         logger.error("getResults("+arg0+")", e);
207         throw CeaFault.makeFault(e);
208     } catch (Throwable e) {
209         logger.error("getResults("+arg0+")", e);
210 
211         throw CeaFault.makeFault(new Exception("a throwable occurred in getResults-"+e.getMessage(),e));
212     }
213 }
214    
215 /*** 
216   * @see org.astrogrid.applications.service.v1.cea.CommonExecutionConnector#returnRegistryEntry()
217   */
218  public String returnRegistryEntry() throws RemoteException, CeaFault
219  {
220      try {
221          return CEAComponentManagerFactory.getInstance().getMetadataService().returnRegistryEntry();
222      } catch (Exception e) {
223 		 logger.error("returnRegistryEntry()", e);
224          throw CeaFault.makeFault(e);       
225      } catch (Throwable e) {
226 		 logger.error("returnRegistryEntry()", e);
227          throw CeaFault.makeFault(new Exception("A throwable occured in return registry entry-"+e.getMessage(),e));
228      }
229   }
230 
231 
232 }