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 import org.astrogrid.applications.beans.v1.cea.castor.MessageType;
16
17 import org.apache.commons.logging.Log;
18 import org.apache.commons.logging.LogFactory;
19
20 import java.util.Observable;
21 import java.util.Observer;
22
23 /*** An abstract base class for things that want to listen to the progress of an application execution.
24 * @author Noel Winstanley nw@jb.man.ac.uk 19-Jul-2004
25 *
26 */
27 public abstract class AbstractProgressListener implements Observer {
28 /***
29 * Commons Logger for this class
30 */
31 private static final Log logger = LogFactory.getLog(AbstractProgressListener.class);
32
33 /*** Construct a new AbstractProgressListener
34 *
35 */
36 public AbstractProgressListener() {
37 super();
38 }
39 /***
40 * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
41 */
42 public final void update(Observable o, Object arg) {
43 Application app = (Application)o;
44 if (arg instanceof Status) {
45 reportStatusChange(app,(Status)arg);
46 } else if (arg instanceof MessageType) {
47 reportMessage(app,(MessageType)arg);
48
49 } else {
50 logger.warn("Unknown object in update notification " + arg.getClass().getName() + " " + arg.toString());
51 }
52 }
53 /*** subclasses to implement this.
54 * called when the listener encounters a message from the application.
55 * @param app the applicaitoni emitting the mesage
56 * @param type the message the application emitted - usually an informative message
57 */
58 protected abstract void reportMessage(Application app, MessageType type);
59 /*** subclasses to implement this.
60 * called when the listener encounters a status change to the application
61 * @param app the application who's state has changed.
62 * @param status the new status of the application.
63 */
64 protected abstract void reportStatusChange(Application app, Status status);
65
66 }
67
68
69
70
71
72
73
74
75
76
77
78
79