diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-02-01 17:09:49 +0000 |
commit | abada90e3f84dc703b8ddc9efcbed8a946fadead (patch) | |
tree | 2c6f9dccd510ea97cb927a7bd635422efaae547a /java/demo/IceStorm/clock/Publisher.java | |
parent | removing trace message (diff) | |
download | ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.bz2 ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.tar.xz ice-abada90e3f84dc703b8ddc9efcbed8a946fadead.zip |
Expanded tabs into spaces
Diffstat (limited to 'java/demo/IceStorm/clock/Publisher.java')
-rw-r--r-- | java/demo/IceStorm/clock/Publisher.java | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/java/demo/IceStorm/clock/Publisher.java b/java/demo/IceStorm/clock/Publisher.java index 8e4a85e2666..780d89101ad 100644 --- a/java/demo/IceStorm/clock/Publisher.java +++ b/java/demo/IceStorm/clock/Publisher.java @@ -14,14 +14,14 @@ public class Publisher extends Ice.Application public void usage() { - System.out.println("Usage: " + appName() + " [--datagram|--twoway|--oneway] [topic]"); + System.out.println("Usage: " + appName() + " [--datagram|--twoway|--oneway] [topic]"); } public int run(String[] args) { IceStorm.TopicManagerPrx manager = IceStorm.TopicManagerPrxHelper.checkedCast( - communicator().propertyToProxy("IceStorm.TopicManager.Proxy")); + communicator().propertyToProxy("IceStorm.TopicManager.Proxy")); if(manager == null) { System.err.println("invalid proxy"); @@ -29,107 +29,107 @@ public class Publisher extends Ice.Application } String topicName = "time"; - boolean datagram = false; - boolean twoway = false; - boolean oneway = false; - int optsSet = 0; - for(int i = 0; i < args.length; ++i) - { - if(args[i].equals("--datagram")) - { - datagram = true; - ++optsSet; - } - else if(args[i].equals("--twoway")) - { - twoway = true; - ++optsSet; - } - else if(args[i].equals("--oneway")) - { - oneway = true; - ++optsSet; - } - else if(args[i].startsWith("--")) - { - usage(); - return 1; - } - else - { - topicName = args[i]; - break; - } - } + boolean datagram = false; + boolean twoway = false; + boolean oneway = false; + int optsSet = 0; + for(int i = 0; i < args.length; ++i) + { + if(args[i].equals("--datagram")) + { + datagram = true; + ++optsSet; + } + else if(args[i].equals("--twoway")) + { + twoway = true; + ++optsSet; + } + else if(args[i].equals("--oneway")) + { + oneway = true; + ++optsSet; + } + else if(args[i].startsWith("--")) + { + usage(); + return 1; + } + else + { + topicName = args[i]; + break; + } + } - if(optsSet > 1) - { - usage(); - return 1; - } + if(optsSet > 1) + { + usage(); + return 1; + } - // - // Retrieve the topic. - // - IceStorm.TopicPrx topic; - try - { - topic = manager.retrieve(topicName); - } - catch(IceStorm.NoSuchTopic e) - { - try - { - topic = manager.create(topicName); - } - catch(IceStorm.TopicExists ex) - { - System.err.println(appName() + ": temporary failure, try again."); - return 1; - } - } + // + // Retrieve the topic. + // + IceStorm.TopicPrx topic; + try + { + topic = manager.retrieve(topicName); + } + catch(IceStorm.NoSuchTopic e) + { + try + { + topic = manager.create(topicName); + } + catch(IceStorm.TopicExists ex) + { + System.err.println(appName() + ": temporary failure, try again."); + return 1; + } + } - // - // Get the topic's publisher object, and create a Clock proxy with - // the mode specified as an argument of this application. - // - Ice.ObjectPrx publisher = topic.getPublisher(); - if(datagram) - { - publisher = publisher.ice_datagram(); - } - else if(twoway) - { - // Do nothing. - } - else // if(oneway) - { - publisher = publisher.ice_oneway(); - } - ClockPrx clock = ClockPrxHelper.uncheckedCast(publisher); + // + // Get the topic's publisher object, and create a Clock proxy with + // the mode specified as an argument of this application. + // + Ice.ObjectPrx publisher = topic.getPublisher(); + if(datagram) + { + publisher = publisher.ice_datagram(); + } + else if(twoway) + { + // Do nothing. + } + else // if(oneway) + { + publisher = publisher.ice_oneway(); + } + ClockPrx clock = ClockPrxHelper.uncheckedCast(publisher); System.out.println("publishing tick events. Press ^C to terminate the application."); - try - { - java.text.SimpleDateFormat date = new java.text.SimpleDateFormat("MM/dd/yy HH:mm:ss:SSS"); - while(true) - { - + try + { + java.text.SimpleDateFormat date = new java.text.SimpleDateFormat("MM/dd/yy HH:mm:ss:SSS"); + while(true) + { + clock.tick(date.format(new java.util.Date())); - try - { - Thread.currentThread().sleep(1000); - } - catch(java.lang.InterruptedException e) - { - } - } - } - catch(Ice.CommunicatorDestroyedException ex) - { - // Ignore - } + try + { + Thread.currentThread().sleep(1000); + } + catch(java.lang.InterruptedException e) + { + } + } + } + catch(Ice.CommunicatorDestroyedException ex) + { + // Ignore + } return 0; } |