View Javadoc

1   /*$Id: RemoteResultsListener.java,v 1.5 2004/07/26 12:07:38 nw Exp $
2    * Created on 17-Jun-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.applications.manager.observer;
12  
13  import org.astrogrid.applications.Application;
14  import org.astrogrid.common.bean.Castor2Axis;
15  import org.astrogrid.jes.service.v1.cearesults.ResultsListener;
16  import org.astrogrid.jes.service.v1.cearesults.ResultsListenerService;
17  import org.astrogrid.jes.service.v1.cearesults.ResultsListenerServiceLocator;
18  import org.astrogrid.jes.types.v1.cea.axis.JobIdentifierType;
19  
20  import org.apache.commons.logging.Log;
21  import org.apache.commons.logging.LogFactory;
22  
23  import java.net.MalformedURLException;
24  import java.net.URI;
25  import java.rmi.RemoteException;
26  
27  import javax.xml.rpc.ServiceException;
28  
29  /*** ResultsListener that relays results of application execution back to remote service.
30   * @todo what happens when application ends in error? this listener never gets told that..
31   * @author Noel Winstanley nw@jb.man.ac.uk 17-Jun-2004
32   *
33   */
34  public class RemoteResultsListener extends AbstractResultsListener {
35      /***
36       * Commons Logger for this class
37       */
38      private static final Log logger = LogFactory.getLog(RemoteResultsListener.class);
39  
40      /*** Construct a new RemoteResultsListener
41       * @param endpoint the url of the results listener web service to relay messages to.
42       * @throws MalformedURLException if endpoint is not valid.
43       * @throws ServiceException if the service could not be connected to
44       * 
45       */
46      public RemoteResultsListener(URI endpoint) throws MalformedURLException, ServiceException {
47          super();
48          ResultsListenerService serviceLocator = new ResultsListenerServiceLocator(); 
49          delegate = serviceLocator.getResultListener(endpoint.toURL());
50          this.endpoint = endpoint;
51      }
52      protected final ResultsListener delegate;
53      protected final URI endpoint;
54  
55      /***pass on the results notification to the remote web service.
56       * 
57       * passes the results values too - to save an additional call<p>
58       * logs all communication failures. 
59       * 
60       * @see org.astrogrid.applications.manager.observer.AbstractResultsListener#notifyResultsAvailable(org.astrogrid.applications.Application)
61       */
62      protected void notifyResultsAvailable(Application app)  {
63             try {
64              delegate.putResults(new JobIdentifierType(app.getJobStepID()),Castor2Axis.convert( app.getResult()));
65          }
66          catch (RemoteException e) {
67              logger.warn("Could not notify remote listener at " + endpoint,e);
68          }
69          
70      }
71  }
72  
73  
74  /* 
75  $Log: RemoteResultsListener.java,v $
76  Revision 1.5  2004/07/26 12:07:38  nw
77  renamed indirect package to protocol,
78  renamed classes and methods within protocol package
79  javadocs
80  
81  Revision 1.4  2004/07/20 02:03:08  nw
82  added abstract listener classes
83  
84  Revision 1.3  2004/07/02 09:11:13  nw
85  improved logging
86  
87  Revision 1.2  2004/07/01 11:16:22  nw
88  merged in branch
89  nww-itn06-componentization
90  
91  Revision 1.1.2.2  2004/07/01 01:42:47  nw
92  final version, before merge
93  
94  Revision 1.1.2.1  2004/06/17 09:21:23  nw
95  finished all major functionality additions to core
96   
97  */