import Demo.*; public class Publisher extends Ice.Application { public void usage() { 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")); if(manager == null) { System.err.println("invalid proxy"); return 1; } String topicName = "time"; boolean datagram = false; boolean twoway = false; boolean oneway = false; int optsSet = 0; // // 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(); //Ice.Context context; //context["_fwd"] = "o"; //Ice.ObjectPrx publisher = topic.getPublisher().ice_newContext(context); publisher = publisher.ice_oneway(); ClockPrx clock = ClockPrxHelper.uncheckedCast(publisher); int count=0; System.out.println("publishing tick events. Press ^C to terminate the application."); try { Structure demo = new Structure(); for(int cc=0;cc<400;cc++) demo.name += "ssssssssssssss"; int len=demo.name.length(); while(true) { count++; demo.index = count; String sCount=Integer.valueOf(count).toString(); clock.tick2(demo); System.out.println(sCount+",size="+len); try { Thread.currentThread().sleep(100); } catch(java.lang.InterruptedException e) { } } } catch(Ice.CommunicatorDestroyedException ex) { // Ignore } return 0; } public static void main(String[] args) { Publisher app = new Publisher(); int status = app.main("Publisher", args, "config.pub"); System.exit(status); } }