import org.cipres.CipresIDL.api1.*; import org.omg.CORBA.*; import org.cipres.registry.*; import org.cipres.communication.*; import org.cipres.util.*; import org.omg.PortableServer.*; import java.util.*; import java.io.*; public class TreeImproveImpl extends TreeImprovePOA { Registry registry; public void setTaxa(int[] taxa) { } public void setMatrix(DataMatrix characters) throws BadArgException { } public void setTree(Tree treeParam) { } public Tree improveTree( org.omg.CosEventChannelAdmin.ProxyPushConsumer pushConsumer) { System.out.println("In improveTree"); TreeScore noScore = new TreeScore(); noScore.noScore(0.0); return new Tree("", noScore, new int[0], ""); } public Tree [] improveTreeReturnAll( org.omg.CosEventChannelAdmin.ProxyPushConsumer pushConsumer) { System.out.println("In improveTreeReturnAll"); return new Tree[0]; } public String getUIXml() { return ""; } public boolean execute(String command, StringHolder display) { return true; } public void remove() { System.out.println("In remove"); PoaUtil.destroy_object(Facilitator.getInstance().getORB()); } public TreeImproveImpl(Registry registry) throws Exception { System.out.println("In TreeImproveImpl ctor"); this.registry = registry; //getRefs(); } void getRefs() throws Exception { try { System.out.println("searching registry for TreeRefiners"); RegistryEntryInfo match = new RegistryEntryInfo( "*", TreeRefineHelper.id(), "*", "*"); RegistryEntryInfo found = registry.findFirst(match); System.out.println("TreeImproveImpl - calling registry to get treerefine service"); TreeRefine tr = TreeRefineHelper.narrow(registry.getObject(found)); System.out.println("Got my tree refiner, now I'm calling remove on it"); tr.remove(); } catch (Exception e) { e.printStackTrace(); throw e; } } public static void main(String args[]) { String port = "1075"; String rootPOAName = "cipres"; String ourPOAName = "testPOA"; String ourObjectName = "tisrv"; Facilitator facilitator = Facilitator.getInstance(); Properties props = new Properties(); try { props.setProperty("OAPort", port); props.setProperty("jacorb.implname", rootPOAName); // this maps cipres/testPOA/tisrv to tisrv /* props.setProperty("jacorb.orb.objectKeyMap." + ourObjectName, rootPOAName + "/" + ourPOAName + "/" + ourObjectName); */ facilitator.initialize(args, props); ORB orb = facilitator.getORB(); POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); POA poa = PoaUtil.create_basic_POA( rootPOA, rootPOA.the_POAManager(), ourPOAName, true, // multi-threaded true); // persistent Registry registry = facilitator.getRegistry(); TreeImproveImpl impl = new TreeImproveImpl(registry); org.omg.CORBA.Object obj = PoaUtil.activate_object(poa, impl, ourObjectName); TreeImprove ti = TreeImproveHelper.narrow(obj); String ior = orb.object_to_string(ti); // maps corbaloc::host:port/ourObjectName to ior - same // as setting jacorb.orb.objectKeymap property, this can be done after ORB_init has // been called. Must cast ORB since this is proprietary to jacorb ORB. ((org.jacorb.orb.ORB)orb).addObjectKey(ourObjectName, ior); rootPOA.the_POAManager().activate(); String iorfile; if ((iorfile = facilitator.getIORFilename()) != null) { System.out.println("Writing ior to " + iorfile); PrintWriter ps = new PrintWriter(new FileOutputStream(new File(iorfile))); ps.println(ior); ps.close(); } org.jacorb.orb.ParsedIOR pior = new org.jacorb.orb.ParsedIOR(ior, orb, null); org.jacorb.orb.util.PrintIOR prior = new org.jacorb.orb.util.PrintIOR(); prior.printIOR(pior, orb); System.out.println("You can access this treeimprover with 'corbaloc::host:port:" + "/" + ourObjectName); orb.run(); } catch (Throwable t) { System.err.println(t.getMessage()); t.printStackTrace(); } } };