View Javadoc

1   /*$Id: AbstractResultsListener.java,v 1.2 2004/07/26 12:07:38 nw Exp $
2    * Created on 19-Jul-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.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          // we only care about results..
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  $Log: AbstractResultsListener.java,v $
65  Revision 1.2  2004/07/26 12:07:38  nw
66  renamed indirect package to protocol,
67  renamed classes and methods within protocol package
68  javadocs
69  
70  Revision 1.1  2004/07/20 02:03:08  nw
71  added abstract listener classes
72   
73  */