1
2
3
4
5
6
7
8
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97