public void terminate() { loop = false; if (task != null) { task.terminate(); task = null; } if (orb != null) { orb.shutdown(true); orb = null; } }
/** entry point from the command line */ public static void main(String args[]) throws Exception { final org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null); final org.jacorb.orb.ORB jorb = (org.jacorb.orb.ORB) orb; final Logger logger = jorb.getConfiguration().getLogger("jacorb.print_ior"); boolean urlForm = false; boolean corbalocForm = false; String iorString = null; String file = null; if (args.length < 2 || args.length > 3) { usage(); } for (int i = 0; i < args.length; i++) { if ("-u".equals(args[i])) { urlForm = true; } else if ("-c".equals(args[i])) { corbalocForm = true; } else if ("-i".equals(args[i])) { iorString = args[i + 1]; ++i; } else if ("-f".equals(args[i])) { file = args[i + 1]; ++i; } else { usage(); } } if (logger.isDebugEnabled()) { logger.debug( "Under " + System.getProperty("os.name") + " the encoding name is " + System.getProperty("file.encoding") + " and the canonical encoding name is " + (new java.io.OutputStreamWriter(new ByteArrayOutputStream())).getEncoding()); } PrintWriter out = new PrintWriter(System.out, true); try { if (file != null) { final LineNumberReader in = new LineNumberReader(new BufferedReader(new FileReader(file))); try { String line = null; while ((line = in.readLine()) != null) { iorString = line; } } finally { in.close(); } } if (iorString.startsWith("IOR:")) { final ParsedIOR pior = new ParsedIOR(jorb, iorString); if (urlForm) { out.println(CorbaLoc.parseKey(pior.get_object_key())); } else if (corbalocForm) { out.println(printCorbalocIOR(orb, iorString)); } else { printIOR(jorb, pior, out); } } else { out.println("Sorry, we only unparse IORs in the standard IOR URL scheme"); } } catch (Exception e) { e.printStackTrace(); } finally { out.flush(); } orb.shutdown(true); }