1 28 29 30 package org.objectweb.corba.runtime; 31 32 37 public class INSRegistrationSchemeImpl 38 extends org.omg.CORBA.LocalObject 39 implements INSRegistrationScheme 40 { 41 static final private String _class_name = "INSRegistrationSchemeImpl"; 43 static final private String _scheme_id = INSRegistrationScheme.SCHEME_ID; 44 45 protected 47 INSRegistrationSchemeImpl() 48 { 49 } 50 51 55 static public RegistrationScheme 56 create_scheme() 57 { 58 return new INSRegistrationSchemeImpl(); 59 } 60 61 65 final public String 66 scheme_id() 67 { 68 return _scheme_id; 69 } 70 71 75 final public void 76 bind(String name, org.omg.CORBA.Object ref, ORBService orbs) 77 { 78 org.omg.CORBA.Object obj = orbs.resolve_initial_references("NameService"); 80 81 if (obj==null) { 83 final String opname = "bind"; 84 final String msg = "IGNORE (no NS)"; 85 TheLogger.debug(_class_name, opname, msg); 86 return ; 87 } 88 89 bind_in_ns(name, ref, obj); 90 } 91 92 final public void 93 bind_in_ns(String name, org.omg.CORBA.Object ref, org.omg.CORBA.Object obj) 94 { 95 final String opname = "bind_in_ns"; 96 97 org.omg.CosNaming.NamingContext ns = null; 98 try { 99 ns = org.omg.CosNaming.NamingContextHelper.narrow(obj); 100 } catch (org.omg.CORBA.BAD_PARAM ex) { 101 final String msg = "IGNORE (not a NS)"; 102 TheLogger.debug(_class_name, opname, msg, ex); 103 return ; 104 } 105 106 String insname = name; 108 109 org.omg.CosNaming.NameComponent [] ncomp = new org.omg.CosNaming.NameComponent [1]; 111 ncomp[0] = new org.omg.CosNaming.NameComponent (insname, ""); 112 try { 113 ns.rebind(ncomp, ref); 114 } catch (Exception ex) { 115 final String msg = "IGNORE (INS name: "+insname+")"; 116 TheLogger.debug(_class_name, opname, msg, ex); 117 return ; 118 } 119 } 120 121 final public void 122 unbind(String name, ORBService orbs) 123 { 124 org.omg.CORBA.Object obj = orbs.resolve_initial_references("NameService"); 126 127 if (obj==null) { 129 final String opname = "unbind"; 130 final String msg = "IGNORE (no NS)"; 131 TheLogger.debug(_class_name, opname, msg); 132 return ; 133 } 134 135 unbind_in_ns(name, obj); 136 } 137 138 final public void 139 unbind_in_ns(String name, org.omg.CORBA.Object obj) 140 { 141 final String opname = "unbind_in_ns"; 142 143 org.omg.CosNaming.NamingContext ns = null; 144 try { 145 ns = org.omg.CosNaming.NamingContextHelper.narrow(obj); 146 } catch (org.omg.CORBA.BAD_PARAM ex) { 147 final String msg = "IGNORE (not a NS)"; 149 TheLogger.debug(_class_name, opname, msg, ex); 150 return ; 151 } 152 153 String insname = name; 155 156 org.omg.CosNaming.NameComponent [] ncomp = new org.omg.CosNaming.NameComponent [1]; 158 ncomp[0] = new org.omg.CosNaming.NameComponent (insname, ""); 159 try { 160 ns.unbind(ncomp); 161 } catch (Exception ex) { 162 final String msg = "IGNORE (INS name: "+insname+")"; 164 TheLogger.debug(_class_name, opname, msg, ex); 165 return ; 166 } 167 } 168 169 public org.omg.CORBA.Object 170 lookup(String name, ORBService orbs) 171 { 172 org.omg.CORBA.Object obj = orbs.resolve_initial_references("NameService"); 174 175 if (obj==null) { 177 final String opname = "lookup"; 179 final String msg = "FAILED (no NS)"; 180 TheLogger.error(_class_name, opname, msg); 181 return null; 182 } 183 184 return lookup_in_ns(name, obj); 185 } 186 187 public org.omg.CORBA.Object 188 lookup_in_ns(String name, org.omg.CORBA.Object obj) 189 { 190 final String opname = "lookup_in_ns"; 191 192 org.omg.CosNaming.NamingContext ns = null; 193 try { 194 ns = org.omg.CosNaming.NamingContextHelper.narrow(obj); 195 } catch (org.omg.CORBA.BAD_PARAM ex) { 196 final String msg = "FAILED (not a NS)"; 197 TheLogger.error(_class_name, opname, msg, ex); 198 return null; 199 } 200 201 String insname = name; 203 204 org.omg.CosNaming.NameComponent [] ncomp = new org.omg.CosNaming.NameComponent [1]; 206 ncomp[0] = new org.omg.CosNaming.NameComponent (insname, ""); 207 org.omg.CORBA.Object res = null; 208 try { 209 res = ns.resolve(ncomp); 210 } catch (Exception ex) { 211 final String msg = "FAILED (INS name: "+insname+")"; 212 TheLogger.error(_class_name, opname, msg, ex); 213 return null; 214 } 215 216 return res; 217 } 218 } 219 | Popular Tags |