1 22 package org.jboss.iiop.rmi.ir; 23 24 import org.omg.CORBA.InterfaceDefOperations ; 25 import org.omg.CORBA.InterfaceDefPOATie; 26 import org.omg.CORBA.InterfaceDefHelper; 27 import org.omg.CORBA.Any ; 28 import org.omg.CORBA.TypeCode ; 29 import org.omg.CORBA.IRObject ; 30 import org.omg.CORBA.Contained ; 31 import org.omg.CORBA.ContainedPackage.Description; 32 import org.omg.CORBA.DefinitionKind ; 33 import org.omg.CORBA.IDLType ; 34 import org.omg.CORBA.StructMember ; 35 import org.omg.CORBA.UnionMember ; 36 import org.omg.CORBA.InterfaceDef ; 37 import org.omg.CORBA.ConstantDef ; 38 import org.omg.CORBA.EnumDef ; 39 import org.omg.CORBA.ValueDef ; 40 import org.omg.CORBA.ValueBoxDef ; 41 import org.omg.CORBA.Initializer ; 42 import org.omg.CORBA.StructDef ; 43 import org.omg.CORBA.UnionDef ; 44 import org.omg.CORBA.ModuleDef ; 45 import org.omg.CORBA.AliasDef ; 46 import org.omg.CORBA.NativeDef ; 47 import org.omg.CORBA.OperationDef ; 48 import org.omg.CORBA.OperationMode ; 49 import org.omg.CORBA.ParameterDescription ; 50 import org.omg.CORBA.AttributeDef ; 51 import org.omg.CORBA.AttributeMode ; 52 import org.omg.CORBA.ExceptionDef ; 53 import org.omg.CORBA.OperationDescription ; 54 import org.omg.CORBA.AttributeDescription ; 55 import org.omg.CORBA.InterfaceDescription ; 56 import org.omg.CORBA.InterfaceDescriptionHelper; 57 import org.omg.CORBA.BAD_INV_ORDER ; 58 import org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription; 59 60 66 class InterfaceDefImpl 67 extends ContainedImpl 68 implements InterfaceDefOperations , LocalContainer 69 { 70 72 74 76 private static final org.jboss.logging.Logger logger = 77 org.jboss.logging.Logger.getLogger(InterfaceDefImpl.class); 78 79 81 InterfaceDefImpl(String id, String name, String version, 82 LocalContainer defined_in, String [] base_interfaces, 83 RepositoryImpl repository) 84 { 85 super(id, name, version, defined_in, 86 DefinitionKind.dk_Interface, repository); 87 88 this.base_interfaces = base_interfaces; 89 this.delegate = new ContainerImplDelegate(this); 90 } 91 92 94 96 public LocalContained _lookup(String search_name) 97 { 98 return delegate._lookup(search_name); 99 } 100 101 public LocalContained[] _contents(DefinitionKind limit_type, 102 boolean exclude_inherited) 103 { 104 return delegate._contents(limit_type, exclude_inherited); 105 } 106 107 public LocalContained[] _lookup_name(String search_name, 108 int levels_to_search, 109 DefinitionKind limit_type, 110 boolean exclude_inherited) 111 { 112 return delegate._lookup_name(search_name, levels_to_search, limit_type, 113 exclude_inherited); 114 } 115 116 public void add(String name, LocalContained contained) 117 throws IRConstructionException 118 { 119 delegate.add(name, contained); 120 } 121 122 124 public IRObject getReference() 125 { 126 if (ref == null) { 127 ref = org.omg.CORBA.InterfaceDefHelper.narrow( 128 servantToReference(new InterfaceDefPOATie(this)) ); 129 } 130 return ref; 131 } 132 133 public void allDone() 134 throws IRConstructionException 135 { 136 getReference(); 137 delegate.allDone(); 138 } 139 140 public void shutdown() 141 { 142 delegate.shutdown(); 143 super.shutdown(); 144 } 145 146 148 public Contained lookup(String search_name) 149 { 150 logger.debug("InterfaceDefImpl.lookup(\"" + search_name + 151 "\") entered."); 152 Contained res = delegate.lookup(search_name); 153 logger.debug("InterfaceDefImpl.lookup(\"" + search_name + 154 "\") returning " + ((res == null) ? "null" : "non-null") ); 155 return res; 156 } 158 159 public Contained [] contents(DefinitionKind limit_type, 160 boolean exclude_inherited) 161 { 162 logger.debug("InterfaceDefImpl.contents() entered."); 163 Contained [] res = delegate.contents(limit_type, exclude_inherited); 164 logger.debug("InterfaceDefImpl.contents() " + res.length + 165 " contained to return."); 166 for (int i = 0; i < res.length; ++i) 167 logger.debug(" InterfaceDefImpl.contents() [" + i + "]: " + 168 res[i].id()); 169 return res; 170 } 172 173 public Contained [] lookup_name(String search_name, int levels_to_search, 174 DefinitionKind limit_type, 175 boolean exclude_inherited) 176 { 177 return delegate.lookup_name(search_name, levels_to_search, limit_type, 178 exclude_inherited); 179 } 180 181 public org.omg.CORBA.ContainerPackage.Description[] 182 describe_contents(DefinitionKind limit_type, 183 boolean exclude_inherited, 184 int max_returned_objs) 185 { 186 return delegate.describe_contents(limit_type, exclude_inherited, 187 max_returned_objs); 188 } 189 190 public ModuleDef create_module(String id, String name, String version) 191 { 192 return delegate.create_module(id, name, version); 193 } 194 195 public ConstantDef create_constant(String id, String name, String version, 196 IDLType type, Any value) 197 { 198 return delegate.create_constant(id, name, version, type, value); 199 } 200 201 public StructDef create_struct(String id, String name, String version, 202 StructMember [] members) 203 { 204 return delegate.create_struct(id, name, version, members); 205 } 206 207 public UnionDef create_union(String id, String name, String version, 208 IDLType discriminator_type, 209 UnionMember [] members) 210 { 211 return delegate.create_union(id, name, version, discriminator_type, 212 members); 213 } 214 215 public EnumDef create_enum(String id, String name, String version, 216 String [] members) 217 { 218 return delegate.create_enum(id, name, version, members); 219 } 220 221 public AliasDef create_alias(String id, String name, String version, 222 IDLType original_type) 223 { 224 return delegate.create_alias(id, name, version, original_type); 225 } 226 227 public InterfaceDef create_interface(String id, String name, String version, 228 InterfaceDef [] base_interfaces, 229 boolean is_abstract) 230 { 231 return delegate.create_interface(id, name, version, 232 base_interfaces, is_abstract); 233 } 234 235 public ValueDef create_value(String id, String name, String version, 236 boolean is_custom, boolean is_abstract, 237 ValueDef base_value, boolean is_truncatable, 238 ValueDef [] abstract_base_values, 239 InterfaceDef [] supported_interfaces, 240 Initializer [] initializers) 241 { 242 return delegate.create_value(id, name, version, is_custom, is_abstract, 243 base_value, is_truncatable, 244 abstract_base_values, supported_interfaces, 245 initializers); 246 } 247 248 public ValueBoxDef create_value_box(String id, String name, String version, 249 IDLType original_type_def) 250 { 251 return delegate.create_value_box(id, name, version, original_type_def); 252 } 253 254 public ExceptionDef create_exception(String id, String name, String version, 255 StructMember [] members) 256 { 257 return delegate.create_exception(id, name, version, members); 258 } 259 260 public NativeDef create_native(String id, String name, String version) 261 { 262 return delegate.create_native(id, name, version); 263 } 264 265 266 268 public InterfaceDef [] base_interfaces() 269 { 270 if (base_interfaces_ref == null) { 271 base_interfaces_ref = new InterfaceDef [base_interfaces.length]; 272 for (int i = 0; i < base_interfaces_ref.length; ++i) { 273 logger.debug("InterfaceDefImpl.base_interfaces(): " + 274 "looking up \"" + base_interfaces[i] + "\"."); 275 Contained c = repository.lookup_id(base_interfaces[i]); 276 logger.debug("InterfaceDefImpl.base_interfaces(): " + 277 "Got: " + ((c==null)? "null" : c.id())); 278 base_interfaces_ref[i] = InterfaceDefHelper.narrow(c); 279 logger.debug("InterfaceDefImpl.base_interfaces(): " + 280 "ref: " + ((c==null)? "null" : "not null")); 281 } 282 } 283 284 return base_interfaces_ref; 285 } 286 287 public void base_interfaces(org.omg.CORBA.InterfaceDef [] arg) 288 { 289 throw new BAD_INV_ORDER ("Cannot change RMI/IIOP mapping."); 290 } 291 292 public boolean is_abstract() 293 { 294 return false; 295 } 296 297 public void is_abstract(boolean arg) 298 { 299 throw new BAD_INV_ORDER ("Cannot change RMI/IIOP mapping."); 300 } 301 302 public boolean is_a(java.lang.String interface_id) 303 { 304 return false; 306 } 307 308 public FullInterfaceDescription describe_interface() 309 { 310 if (fullInterfaceDescription != null) 311 return fullInterfaceDescription; 312 313 315 OperationDescription [] operations = new OperationDescription [0]; 317 AttributeDescription [] attributes = new AttributeDescription [0]; 318 319 String defined_in_id = "IDL:Global:1.0"; 320 if (defined_in instanceof org.omg.CORBA.ContainedOperations ) 321 defined_in_id = ((org.omg.CORBA.ContainedOperations )defined_in).id(); 322 323 fullInterfaceDescription = new FullInterfaceDescription(name, id, 324 defined_in_id, 325 version, 326 operations, 327 attributes, 328 base_interfaces, 329 type(), 330 is_abstract); 331 332 return fullInterfaceDescription; 333 } 334 335 public AttributeDef create_attribute(String id, String name, 336 String version, IDLType type, 337 AttributeMode mode) 338 { 339 throw new BAD_INV_ORDER ("Cannot change RMI/IIOP mapping."); 340 } 341 342 public OperationDef create_operation(String id, String name, String version, 343 IDLType result, OperationMode mode, 344 ParameterDescription [] params, 345 ExceptionDef [] exceptions, 346 String [] contexts) 347 { 348 throw new BAD_INV_ORDER ("Cannot change RMI/IIOP mapping."); 349 } 350 351 352 354 public TypeCode type() 355 { 356 if (typeCode == null) 357 typeCode = getORB().create_interface_tc(id, name); 358 359 return typeCode; 360 } 361 362 364 public Description describe() 365 { 366 String defined_in_id = "IR"; 367 368 if (defined_in instanceof org.omg.CORBA.ContainedOperations ) 369 defined_in_id = ((org.omg.CORBA.ContainedOperations )defined_in).id(); 370 371 org.omg.CORBA.InterfaceDescription md = 372 new InterfaceDescription (name, id, defined_in_id, version, 373 base_interfaces, false); 374 375 Any any = getORB().create_any(); 376 377 InterfaceDescriptionHelper.insert(any, md); 378 379 return new Description(DefinitionKind.dk_Interface, any); 380 } 381 382 384 386 388 391 protected InterfaceDef ref = null; 392 393 396 protected TypeCode typeCode; 397 398 400 403 private ContainerImplDelegate delegate; 404 405 408 private boolean is_abstract; 409 410 413 private String [] base_interfaces; 414 415 418 private InterfaceDef [] base_interfaces_ref; 419 420 423 private FullInterfaceDescription fullInterfaceDescription; 424 425 } 427 | Popular Tags |