1 package org.sapia.soto.ubik.example; 2 3 import org.sapia.soto.ConfigurationException; 4 import org.sapia.soto.Service; 5 6 7 11 public class UbikClient implements Service, Runnable { 12 private UbikService _svc; 13 14 17 public UbikClient() { 18 super(); 19 } 20 21 public void setUbikService(UbikService svc) { 22 _svc = svc; 23 } 24 25 28 public void dispose() { 29 } 30 31 34 public void init() throws Exception { 35 } 36 37 40 public void start() throws Exception { 41 if (_svc == null) { 42 throw new ConfigurationException( 43 "This instance was not initialized with a UbikService instance"); 44 } 45 46 Thread t = new Thread (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 e) { 59 e.printStackTrace(); 60 } 61 } 62 } 63 | Popular Tags |