Ignore:
Timestamp:
09/17/11 15:19:05 (8 months ago)
Author:
delmitz
Branch:
default
Convert:
svn:7c3792e6-d75b-4784-96a6-b298f655ee64/trunk@2775
Message:

added NtpSyncService.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kraken-ntp/src/main/java/org/krakenapps/ntp/script/NtpScript.java

    r274 r341  
    2525import org.krakenapps.api.ScriptContext; 
    2626import org.krakenapps.api.ScriptUsage; 
    27 import org.krakenapps.ntp.NtpClient; 
     27import org.krakenapps.ntp.NtpSyncService; 
    2828 
    2929/** 
     
    3232public class NtpScript implements Script { 
    3333        private ScriptContext context; 
    34         private NtpClient ntpClient; 
     34        private NtpSyncService syncService; 
    3535 
    36         public NtpScript(NtpClient ntpClient) { 
    37                 this.ntpClient = ntpClient; 
     36        public NtpScript(NtpSyncService syncService) { 
     37                this.syncService = syncService; 
    3838        } 
    3939 
     
    4949                        try { 
    5050                                InetAddress server = InetAddress.getByName(args[0]); 
    51                                 ntpClient.setTimeServer(server); 
     51                                syncService.setTimeServer(server); 
    5252                        } catch (UnknownHostException e) { 
    5353                                context.println("unknown host"); 
     
    5555                } 
    5656 
    57                 context.println(ntpClient.getTimeServer()); 
     57                context.println(syncService.getTimeServer()); 
    5858        } 
    5959 
     
    6363                if (args.length > 0) { 
    6464                        Integer millisecond = Integer.parseInt(args[0]); 
    65                         ntpClient.setTimeout(millisecond); 
     65                        syncService.setTimeout(millisecond); 
    6666                } 
    6767 
    68                 context.println(ntpClient.getTimeout()); 
     68                context.println(syncService.getTimeout()); 
    6969        } 
    7070 
    7171        public void sync(String[] args) { 
    72                 Date result = ntpClient.sync(); 
     72                Date result = syncService.getNtpClient().sync(); 
    7373                if (result != null) 
    74                         context.printf("The time has been successfully synchronized with %s on %s\n", ntpClient.getTimeServer() 
     74                        context.printf("The time has been successfully synchronized with %s on %s\n", syncService.getTimeServer() 
    7575                                        .getHostName(), new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS 'UTC'").format(result)); 
    7676                else 
Note: See TracChangeset for help on using the changeset viewer.