1 20 21 package org.jacorb.orb.util; 22 23 import org.apache.avalon.framework.logger.Logger; 24 25 import org.jacorb.orb.giop.CodeSet; 26 import org.jacorb.orb.ParsedIOR; 27 import org.jacorb.orb.*; 28 29 import org.omg.IOP.*; 30 import org.omg.GIOP.*; 31 import org.omg.IIOP.*; 32 import org.omg.SSLIOP.*; 33 import org.omg.CSIIOP.*; 34 import org.omg.CONV_FRAME.*; 35 36 import java.io.*; 37 38 43 44 public class FixIOR 45 { 46 public static void main (String args[]) 47 throws Exception 48 { 49 org.omg.CORBA.ORB orb; 50 String iorString; 51 String iorFile; 52 String host; 53 BufferedReader br; 54 BufferedWriter bw; 55 CDRInputStream is; 56 CDROutputStream os; 57 ParsedIOR pior; 58 IOR ior; 59 TaggedProfile[] profiles; 60 ProfileBody_1_0 body10; 61 ProfileBody_1_1 body11; 62 short port; 63 int iport; 64 65 66 if (args.length != 3) 67 { 68 System.err.println ("Usage: fixior host port ior_file"); 69 System.exit( 1 ); 70 } 71 host = args[0]; 72 73 75 iorFile = args[2]; 76 br = new BufferedReader (new FileReader (iorFile)); 77 iorString = br.readLine (); 78 br.close (); 79 80 if (! iorString.startsWith ("IOR:")) 81 { 82 System.err.println ("IOR must be in the standard IOR URL format"); 83 System.exit (1); 84 } 85 86 iport = Integer.parseInt (args[1]); 87 if (iport > 32767) 88 { 89 iport = iport - 65536; 90 } 91 port = (short) iport; 92 93 orb = org.omg.CORBA.ORB.init (args, null); 94 95 Logger logger = 96 ((org.jacorb.orb.ORB)orb).getConfiguration().getNamedLogger("jacorb.fixior"); 97 98 100 pior = new ParsedIOR(iorString, orb, logger); 101 ior = pior.getIOR (); 102 103 105 profiles = ior.profiles; 106 for (int i = 0; i < profiles.length; i++) 107 { 108 if (profiles[i].tag == TAG_INTERNET_IOP.value) 109 { 110 is = new CDRInputStream (orb, profiles[i].profile_data); 111 is.openEncapsulatedArray (); 112 body10 = ProfileBody_1_0Helper.read (is); 113 is.close (); 114 115 os = new CDROutputStream (); 116 os.beginEncapsulatedArray (); 117 118 if (body10.iiop_version.minor > 0) 119 { 120 is = new CDRInputStream (orb, profiles[i].profile_data); 121 is.openEncapsulatedArray (); 122 body11 = ProfileBody_1_1Helper.read (is); 123 is.close (); 124 125 body11.host = host; 126 body11.port = port; 127 128 ProfileBody_1_1Helper.write (os, body11); 129 } 130 else 131 { 132 body10.host = host; 133 body10.port = port; 134 135 ProfileBody_1_0Helper.write (os, body10); 136 } 137 profiles[i].profile_data = os.getBufferCopy (); 138 } 139 } 140 141 pior = new ParsedIOR (ior, (org.jacorb.orb.ORB)orb, logger); 142 143 145 bw = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (iorFile))); 146 bw.write (pior.getIORString ()); 147 bw.close (); 148 } 149 150 private FixIOR () 151 { 152 } 153 } 154 | Popular Tags |