1 28 29 30 package org.objectweb.corba.runtime; 31 32 37 public class FileRegistrationSchemeImpl 38 extends org.omg.CORBA.LocalObject 39 implements FileRegistrationScheme 40 { 41 static final private String _class_name = "FileRegistrationSchemeImpl"; 43 static final private String _scheme_id = FileRegistrationScheme.SCHEME_ID; 44 45 protected 47 FileRegistrationSchemeImpl() 48 { 49 } 50 51 55 static public RegistrationScheme 56 create_scheme() 57 { 58 return new FileRegistrationSchemeImpl(); 59 } 60 61 65 final public String 66 scheme_id() 67 { 68 return _scheme_id; 69 } 70 71 75 final public void 76 write_ior(String name, org.omg.CORBA.Object ref, ORBService orbs) 77 { 78 String iorfile = name; 80 81 String sref = orbs.object_to_string(ref); 83 84 java.io.FileOutputStream out = null; 86 try { 87 out = new java.io.FileOutputStream (iorfile); 88 out.write(sref.getBytes()); 89 out.close(); 90 } catch(Exception ex) { 91 final String opname = "write_ior"; 93 final String msg = "IGNORE (file: "+iorfile+")"; 94 TheLogger.debug(_class_name, opname, msg, ex); 95 } 96 } 97 98 final public org.omg.CORBA.Object 99 read_ior(String name, ORBService orbs) 100 { 101 String iorfile = name; 103 104 java.io.BufferedReader in = null; 106 StringBuffer res = new StringBuffer (); 107 try { 108 in = new java.io.BufferedReader (new java.io.FileReader (iorfile)); 109 while(in.ready()) { 110 res.append(in.readLine()); 111 } 112 113 in.close(); 114 } catch(Exception ex) { 115 final String opname = "read_ior"; 116 final String msg = "FAILED (file: "+iorfile+")"; 117 TheLogger.error(_class_name, opname, msg, ex); 118 } 119 120 return orbs.string_to_object(res.toString()); 122 } 123 } 124 | Popular Tags |