KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > soto > ubik > example > UbikClient


1 package org.sapia.soto.ubik.example;
2
3 import org.sapia.soto.ConfigurationException;
4 import org.sapia.soto.Service;
5
6
7 /**
8  * @author Yanick Duchesne
9  * 1-Oct-2003
10  */

11 public class UbikClient implements Service, Runnable JavaDoc {
12   private UbikService _svc;
13
14   /**
15    * Constructor for UbikClient.
16    */

17   public UbikClient() {
18     super();
19   }
20
21   public void setUbikService(UbikService svc) {
22     _svc = svc;
23   }
24
25   /**
26    * @see org.sapia.soto.Service#dispose()
27    */

28   public void dispose() {
29   }
30
31   /**
32    * @see org.sapia.soto.Service#init()
33    */

34   public void init() throws Exception JavaDoc {
35   }
36
37   /**
38    * @see org.sapia.soto.Service#start()
39    */

40   public void start() throws Exception JavaDoc {
41     if (_svc == null) {
42       throw new ConfigurationException(
43         "This instance was not initialized with a UbikService instance");
44     }
45
46     Thread JavaDoc t = new Thread JavaDoc(this);
47     t.setDaemon(true);
48     t.start();
49   }
50
51   public void run() {
52     try {
53       while (true) {
54         _svc.ping();
55         System.out.println("Ping successfull");
56         Thread.sleep(1500);
57       }
58     } catch (Throwable JavaDoc e) {
59       e.printStackTrace();
60     }
61   }
62 }
63
Popular Tags