KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > magnet > test > DummyServer


1 package org.sapia.magnet.test;
2
3 import org.sapia.corus.interop.Param;
4 import org.sapia.corus.interop.Status;
5 import org.sapia.corus.interop.Context;
6 import org.sapia.corus.interop.client.InteropClient;
7 import org.sapia.corus.interop.client.ShutdownListener;
8 import org.sapia.corus.interop.client.StatusRequestListener;
9
10
11 /**
12  * Class documentation
13  *
14  * @author <a HREF="mailto:jc@sapia-oss.org">Jean-Cedric Desrochers</a>
15  * <dl>
16  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">
17  * Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
18  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
19  * <a HREF="http://www.sapia-oss.org/license.html" target="sapia-license">license page</a>
20  * at the Sapia OSS web site</dd></dt>
21  * </dl>
22  */

23 public class DummyServer implements ShutdownListener, StatusRequestListener {
24
25   private boolean _isShutdown = false;
26   
27   public DummyServer() {
28     InteropClient.getInstance().addShutdownListener(this);
29     InteropClient.getInstance().addStatusRequestListener(this);
30   }
31   
32   public boolean isShutdown() {
33     return _isShutdown;
34   }
35   
36   /**
37    * @see org.sapia.corus.interop.client.ShutdownListener#onShutdown()
38    */

39   public void onShutdown() {
40     _isShutdown = true;
41     System.out.println("Shutting down the dummy server...");
42   }
43
44   /**
45    * @see org.sapia.corus.interop.client.StatusRequestListener#onStatus(org.sapia.corus.interop.Status)
46    */

47   public void onStatus(Status status) {
48     Param anParam = new Param("isShutdown", (_isShutdown? "true": "false"));
49     Context aContext = new Context("DummyServer");
50     aContext.addParam(anParam);
51     status.addContext(aContext);
52   }
53   
54 }
Popular Tags