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.applications.Status;
15
16 import org.apache.commons.logging.Log;
17 import org.apache.commons.logging.LogFactory;
18
19 import java.util.Observable;
20 import java.util.Observer;
21
22 /*** Abstract base class for things that want to be notified of the results of an application execution
23 * @author Noel Winstanley nw@jb.man.ac.uk 19-Jul-2004
24 *
25 */
26 public abstract class AbstractResultsListener implements Observer {
27 /***
28 * Commons Logger for this class
29 */
30 private static final Log logger = LogFactory.getLog(AbstractResultsListener.class);
31
32 /*** Construct a new AbstractResultsListener
33 *
34 */
35 public AbstractResultsListener() {
36 super();
37 }
38 /***
39 * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
40 */
41 public void update(Observable o, Object arg) {
42
43 if (! (arg instanceof Status)) {
44 return;
45 }
46 Status stat = (Status) arg;
47 logger.debug("Saw status " + stat.toString());
48 if (stat.equals(Status.COMPLETED)) {
49 logger.debug("Will notify that results are ready");
50 Application app = (Application)o;
51 notifyResultsAvailable(app);
52 }
53 }
54 /*** Subclasses to implement this.
55 * Called when the application wishes to notify listeners that execution has completed and results are available
56 * @param app the application that emitted the notificaiton
57 * @see Application#getResult()
58 */
59 protected abstract void notifyResultsAvailable(Application app);
60 }
61
62
63
64
65
66
67
68
69
70
71
72
73