1 package org.sapia.ubik.rmi.examples.time; 2 3 import java.io.BufferedReader ; 4 import java.io.IOException ; 5 import java.io.InputStreamReader ; 6 import org.sapia.ubik.rmi.server.Hub; 7 import org.sapia.ubik.rmi.server.Log; 8 9 10 13 public class CliTimeClient { 14 public static void main(String [] args) { 15 Log.setInfo(); 16 17 try { 18 BufferedReader reader = new BufferedReader (new InputStreamReader (System.in)); 19 int i = 0; 20 String prompt; 21 TimeClient aClient = new TimeClient(); 22 System.out.println("-- press enter --"); 23 System.out.println(); 24 while (true) { 25 System.out.print((++i) + ". >>"); 26 prompt = reader.readLine(); 27 if(prompt == null){ 28 break; 29 } 30 aClient.execute(); 31 Thread.sleep(1000); 32 } 33 } catch (InterruptedException ie) { 34 System.err.println("The endless time client is interrupted, exiting..."); 35 ie.printStackTrace(); 36 } catch (IOException e){ 37 System.err.println("System prompting input, exiting..."); 38 } catch (RuntimeException re) { 39 System.err.println("System error running the time client, exiting..."); 40 re.printStackTrace(); 41 } finally { 42 try { 43 Hub.shutdown(30000); 44 } catch (InterruptedException e) { 45 e.printStackTrace(); 46 } 47 } 48 } 49 } 50 | Popular Tags |