diff options
author | Matthew Newhook <matthew@zeroc.com> | 2008-02-29 15:51:11 +0800 |
---|---|---|
committer | Matthew Newhook <matthew@zeroc.com> | 2008-02-29 16:39:54 +0800 |
commit | fb4132881dde7c9b135d713a06a3b64db1f706db (patch) | |
tree | 8a037e9d4cae7ed15360ab0878d14b32ac3150a4 /java/demo/IceStorm/clock/Publisher.java | |
parent | fixing mode on php/config/Make.rules.mak (diff) | |
download | ice-fb4132881dde7c9b135d713a06a3b64db1f706db.tar.bz2 ice-fb4132881dde7c9b135d713a06a3b64db1f706db.tar.xz ice-fb4132881dde7c9b135d713a06a3b64db1f706db.zip |
Merge HA IceStorm branch.
- http://bugzilla/bugzilla/show_bug.cgi?id=2706
- http://bugzilla/bugzilla/show_bug.cgi?id=2705
Diffstat (limited to 'java/demo/IceStorm/clock/Publisher.java')
-rw-r--r-- | java/demo/IceStorm/clock/Publisher.java | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/java/demo/IceStorm/clock/Publisher.java b/java/demo/IceStorm/clock/Publisher.java index 6516475cbbb..5078748baf2 100644 --- a/java/demo/IceStorm/clock/Publisher.java +++ b/java/demo/IceStorm/clock/Publisher.java @@ -20,35 +20,24 @@ public class Publisher extends Ice.Application public int run(String[] args) { - IceStorm.TopicManagerPrx manager = IceStorm.TopicManagerPrxHelper.checkedCast( - communicator().propertyToProxy("IceStorm.TopicManager.Proxy")); - if(manager == null) - { - System.err.println("invalid proxy"); - return 1; - } - + String option = "None"; String topicName = "time"; - boolean datagram = false; - boolean twoway = false; - boolean oneway = false; - int optsSet = 0; - for(int i = 0; i < args.length; ++i) + int i; + + for(i = 0; i < args.length; ++i) { + String oldoption = option; if(args[i].equals("--datagram")) { - datagram = true; - ++optsSet; + option = "Datagram"; } else if(args[i].equals("--twoway")) { - twoway = true; - ++optsSet; + option = "Twoway"; } else if(args[i].equals("--oneway")) { - oneway = true; - ++optsSet; + option = "Oneway"; } else if(args[i].startsWith("--")) { @@ -57,17 +46,31 @@ public class Publisher extends Ice.Application } else { - topicName = args[i]; + topicName = args[i++]; break; } + + if(!oldoption.equals(option) && !oldoption.equals("None")) + { + usage(); + return 1; + } } - if(optsSet > 1) + if(i != args.length) { usage(); return 1; } + IceStorm.TopicManagerPrx manager = IceStorm.TopicManagerPrxHelper.checkedCast( + communicator().propertyToProxy("TopicManager.Proxy")); + if(manager == null) + { + System.err.println("invalid proxy"); + return 1; + } + // // Retrieve the topic. // @@ -94,11 +97,11 @@ public class Publisher extends Ice.Application // the mode specified as an argument of this application. // Ice.ObjectPrx publisher = topic.getPublisher(); - if(datagram) + if(option.equals("Datagram")) { publisher = publisher.ice_datagram(); } - else if(twoway) + else if(option.equals("Twoway")) { // Do nothing. } |