1 package org.jacorb.ir; 2 3 22 23 import java.lang.reflect.*; 24 import java.io.*; 25 import java.util.*; 26 27 import org.omg.CORBA.IDLType ; 28 import org.omg.CORBA.INTF_REPOS ; 29 import org.omg.CORBA.ORB ; 30 import org.omg.CORBA.TypeCode ; 31 import org.omg.CORBA.InterfaceDefPackage.FullInterfaceDescription; 32 import org.omg.CORBA.ContainerPackage.*; 33 import org.omg.CORBA.OperationDescription ; 34 import org.omg.CORBA.AttributeDescription ; 35 import org.omg.CORBA.ConstantDescription ; 36 import org.omg.PortableServer.POA ; 37 38 import org.apache.avalon.framework.logger.Logger; 39 40 46 47 public class InterfaceDef 48 extends org.jacorb.ir.Contained 49 implements org.omg.CORBA.InterfaceDefOperations , ContainerType 50 { 51 protected static char fileSeparator = 52 System.getProperty("file.separator").charAt(0); 53 54 Class theClass; 55 private Class helperClass; 56 private Class signatureClass; 57 58 private org.omg.CORBA.TypeCode typeCode; 59 private OperationDef[] op_defs; 60 private org.omg.CORBA.OperationDescription [] operations; 61 62 private boolean is_abstract = false; 64 65 private AttributeDef[] att_defs; 66 private org.omg.CORBA.AttributeDescription [] attributes; 67 68 private ConstantDef[] constant_defs; 69 private org.omg.CORBA.ConstantDescription [] constants; 70 71 private org.omg.CORBA.InterfaceDef [] base_interfaces; 72 private String [] base_names; 73 private FullInterfaceDescription fullDescription; 74 75 private Hashtable containedLocals = new Hashtable(); 76 77 78 private Hashtable contained = new Hashtable(); 79 80 81 private org.omg.CORBA.Contained myContainer; 82 private org.omg.CORBA.InterfaceDef myReference; 83 84 private File my_dir; 85 private Hashtable op = new Hashtable(); 86 private Hashtable att = new Hashtable(); 87 private Hashtable my_const = new Hashtable(); 88 private org.omg.CORBA.Contained [] classes; 89 private String path; 90 private String [] class_names; 91 private int size = 0; 92 private boolean defined = false; 93 private boolean loaded = false; 94 95 private Class containedClass = null; 96 private Class containerClass = null; 97 98 private ClassLoader loader; 99 private POA poa; 100 private Logger logger; 101 102 105 106 InterfaceDef( Class c, 107 Class helperClass, 108 String path, 109 org.omg.CORBA.Container def_in, 110 org.omg.CORBA.Repository ir, 111 ClassLoader loader, 112 POA poa, 113 Logger logger) 114 throws INTF_REPOS 115 { 116 this.loader = loader; 117 this.poa = poa; 118 this.logger = logger; 119 120 if (ir == null) 121 { 122 throw new INTF_REPOS ("IR null!"); 123 } 124 125 if (def_in == null) 126 { 127 throw new INTF_REPOS ("Defined_in null!"); 128 } 129 130 def_kind = org.omg.CORBA.DefinitionKind.dk_Interface; 131 containing_repository = ir; 132 defined_in = def_in; 133 if( def_in.equals(ir) ) 134 myContainer = null; 135 else 136 myContainer = org.omg.CORBA.ContainedHelper.narrow( defined_in ); 137 138 this.path = path; 139 140 theClass = c; 141 String classId = c.getName(); 142 this.helperClass = helperClass; 143 144 Hashtable irInfo= null; 145 Class irHelperClass = null; 146 try 147 { 148 irHelperClass = 149 this.loader.loadClass( theClass.getName() + "IRHelper"); 150 irInfo = (Hashtable)irHelperClass.getDeclaredField("irInfo").get(null); 151 } 152 catch( ClassNotFoundException e ) 153 { 154 logger.error("No IR helper class for interface " + 155 theClass.getName(), e); 156 } 157 catch( Exception e ) 158 { 159 logger.error("Caught Exception", e); 160 } 161 162 if (irInfo == null) 163 { 164 throw new INTF_REPOS ("IR Info null!"); 165 } 166 167 try 168 { 169 containedClass = this.loader.loadClass("org.omg.CORBA.Contained"); 170 signatureClass = this.loader.loadClass(classId + "Operations"); 171 172 id( (String )helperClass.getDeclaredMethod("id", (Class []) null).invoke( null, (Object []) null ) ); 173 version( id().substring( id().lastIndexOf(':'))); 174 typeCode = TypeCodeUtil.getTypeCode( c, null, this.logger ); 175 176 full_name = classId.replace('.', '/'); 177 if( classId.indexOf('.') > 0 ) 178 { 179 name = classId.substring( classId.lastIndexOf('.')+1); 180 181 if (defined_in == null) 182 { 183 throw new INTF_REPOS ("InterfaceDef " + name + " path " + path + 184 " has no defined_in repository"); 185 } 186 187 if( containedClass.isAssignableFrom( defined_in.getClass() )) 188 absolute_name = 189 ( myContainer != null ? myContainer.absolute_name() : "Global" ) 190 + "::" + name; 191 else 192 absolute_name = "::" + name; 193 } 194 else 195 { 196 name = classId; 197 defined_in = containing_repository; 198 absolute_name = "::" + name; 199 } 200 201 if (this.logger.isDebugEnabled()) 202 { 203 this.logger.debug("InterfaceDef: " + absolute_name + 204 " path: " + path); 205 } 206 207 208 File f = 209 new File( path + fileSeparator + 210 classId.replace('.', fileSeparator) + "Package" ); 211 212 if( f.exists() && f.isDirectory() ) 213 my_dir = f; 214 215 216 } 217 catch ( Exception e ) 218 { 219 this.logger.error("Caught exception",e); 220 throw new INTF_REPOS ( ErrorMsg.IR_Not_Implemented, 221 org.omg.CORBA.CompletionStatus.COMPLETED_NO); 222 } 223 } 224 225 226 227 public void loadContents() 228 { 229 if (this.logger.isDebugEnabled()) 230 { 231 this.logger.debug("Interface " +name+ " loading... "); 232 } 233 234 if (getReference() == null) 236 { 237 throw new INTF_REPOS ("getReference returns null"); 238 } 239 240 myReference = 241 org.omg.CORBA.InterfaceDefHelper.narrow( getReference()); 242 243 if (myReference == null) 244 { 245 throw new INTF_REPOS ("narrow failed for " + getReference ()); 246 } 247 248 249 250 String [] classes = null; 251 252 if( my_dir != null ) 253 { 254 classes = my_dir.list( new IRFilenameFilter(".class") ); 255 256 if( classes != null) 258 { 259 for( int j = 0; j< classes.length; j++ ) 260 { 261 try 262 { 263 if (this.logger.isDebugEnabled()) 264 { 265 this.logger.debug( 266 "Interface " +name+ " tries " + 267 full_name.replace('.', fileSeparator) + 268 "Package" + fileSeparator + 269 classes[j].substring( 0, classes[j].indexOf(".class")) ); 270 } 271 272 ClassLoader loader = getClass().getClassLoader(); 273 if( loader == null ) 274 { 275 loader = this.loader; 276 } 277 278 Class cl = 279 loader.loadClass( 280 ( full_name.replace('.', fileSeparator) + 281 "Package" + fileSeparator + 282 classes[j].substring( 0, classes[j].indexOf(".class")) 283 ).replace( fileSeparator, '/') ); 284 285 Contained containedObject = 286 Contained.createContained( cl, 287 path, 288 myReference, 289 containing_repository, 290 this.logger, 291 this.loader, 292 this.poa); 293 if( containedObject == null ) 294 continue; 295 296 org.omg.CORBA.Contained containedRef = 297 Contained.createContainedReference(containedObject, 298 this.logger, 299 this.poa); 300 301 302 containedRef.move( myReference, 303 containedRef.name(), 304 containedRef.version() ); 305 306 if (this.logger.isDebugEnabled()) 307 { 308 this.logger.debug("Interface " + full_name + 309 " loads "+ containedRef.name()); 310 } 311 312 contained.put( containedRef.name() , containedRef ); 313 containedLocals.put( containedRef.name(), containedObject ); 314 315 if( containedObject instanceof ContainerType ) 316 ((ContainerType)containedObject).loadContents(); 317 318 } 319 catch ( Exception e ) 320 { 321 this.logger.error("Caught exception",e); 322 } 323 } 324 } 325 } 326 327 loaded = true; 328 329 if (this.logger.isDebugEnabled()) 330 { 331 this.logger.debug("Interface " + name + " loaded"); 332 } 333 } 334 335 void define() 336 { 337 if ( ! loaded) 338 { 339 throw new INTF_REPOS ("Interface " + name + " not loaded!"); 340 } 341 342 if (this.logger.isDebugEnabled()) 343 { 344 this.logger.debug("Interface " + name + " defining... ]"); 345 this.logger.debug("Interface " +name+ " loads attributes/ops"); 346 } 347 348 Vector ops = new Vector(); 349 Vector atts = new Vector(); 350 Hashtable irInfo= null; 351 352 Class irHelperClass = null; 353 try 354 { 355 irHelperClass = 356 this.loader.loadClass( theClass.getName() + "IRHelper"); 357 irInfo = (Hashtable)irHelperClass.getDeclaredField("irInfo").get(null); 358 } 359 catch( ClassNotFoundException e ) 360 { 361 this.logger.error("!! No IR helper class for interface " + 362 theClass.getName(), e); 363 } 364 catch( Exception e ) 365 { 366 logger.error("Caught exception", e); 367 } 368 369 Method methods[] = signatureClass.getDeclaredMethods(); 370 371 for( int i = 0; i < methods.length; i++ ) 372 { 373 Object value = irInfo.get(methods[i].getName()); 374 if( value == null || !((String )value).startsWith("attribute")) 375 { 376 ops.addElement( 377 new OperationDef( methods[i], 378 theClass, 379 irHelperClass, 380 myReference, 381 this.logger, 382 this.loader, 383 this.poa)); 384 } 385 else 386 { 387 if( ((String )value).startsWith("attribute") ) 388 { 389 String attrDescr = (String )value; 390 391 if( methods[i].getReturnType() == Void .class ) 392 continue; 393 394 int idx = attrDescr.indexOf('-'); 395 String attrTypeName = 396 attrDescr.substring( attrDescr.indexOf(";")+1); 397 398 atts.addElement( 399 new AttributeDef( methods[i], 400 attrTypeName, 401 ( idx > 0 ? 402 org.omg.CORBA.AttributeMode.ATTR_NORMAL : 403 org.omg.CORBA.AttributeMode.ATTR_READONLY ), 404 myReference, 405 containing_repository, 406 this.logger, 407 this.loader, 408 this.poa)); 409 } 410 } 411 } 412 413 if (this.logger.isDebugEnabled()) 414 { 415 this.logger.debug("Interface " +name+ " defines ops"); 416 } 417 418 op_defs = new OperationDef[ ops.size() ]; 419 ops.copyInto( op_defs ); 420 for( int i = 0; i < op_defs.length; i++ ) 421 { 422 op_defs[i].move( myReference , op_defs[i].name(), version ); 423 containedLocals.put( op_defs[i].name(), op_defs[i] ); 424 425 try 426 { 427 org.omg.CORBA.OperationDef operationRef = 428 org.omg.CORBA.OperationDefHelper.narrow( 429 this.poa.servant_to_reference( 430 new org.omg.CORBA.OperationDefPOATie( op_defs[i] ))); 431 contained.put( op_defs[i].name(), operationRef ) ; 432 op_defs[i].setReference(operationRef); 433 } 434 catch( Exception e ) 435 { 436 this.logger.error("Caught exception",e); 437 } 438 } 439 440 if (this.logger.isDebugEnabled()) 441 { 442 this.logger.debug("Interface " +name+ " defines attributes"); 443 } 444 445 att_defs = new AttributeDef[ atts.size() ]; 446 atts.copyInto( att_defs ); 447 448 for( int i = 0; i < att_defs.length; i++ ) 449 { 450 att_defs[i].move( myReference , att_defs[i].name(), version ); 451 containedLocals.put( att_defs[i].name(), att_defs[i] ); 452 try 453 { 454 org.omg.CORBA.AttributeDef attribute = 455 org.omg.CORBA.AttributeDefHelper.narrow( 456 this.poa.servant_to_reference( 457 new org.omg.CORBA.AttributeDefPOATie( att_defs[i] ))); 458 contained.put( att_defs[i].name(), attribute ); 459 att_defs[i].setReference( attribute ); 460 } 461 catch( Exception e ) 462 { 463 this.logger.error("Caught exception",e); 464 } 465 } 466 467 468 if (this.logger.isDebugEnabled()) 469 { 470 this.logger.debug("Interface " + name + " defines constants"); 471 } 472 473 Field[] fields = theClass.getDeclaredFields(); 474 constant_defs = new ConstantDef[ fields.length ]; 475 for( int i = 0; i < constant_defs.length; i++ ) 476 { 477 constant_defs[i] = new ConstantDef( fields[i], 478 myReference, 479 containing_repository, 480 this.logger, 481 this.poa); 482 constant_defs[i].move( myReference , constant_defs[i].name(), version ); 483 containedLocals.put( constant_defs[i].name(), constant_defs[i] ); 484 try 485 { 486 org.omg.CORBA.ConstantDef constRef = 487 org.omg.CORBA.ConstantDefHelper.narrow( 488 this.poa.servant_to_reference( 489 new org.omg.CORBA.ConstantDefPOATie( constant_defs[i] ))); 490 491 contained.put( constant_defs[i].name(), constRef ) ; 492 constant_defs[i].setReference(constRef); 493 } 494 catch( Exception e ) 495 { 496 this.logger.error("Caught exception",e); 497 } 498 } 499 500 for( Enumeration e = containedLocals.elements(); 501 e.hasMoreElements(); 502 ((IRObject)e.nextElement()).define()) 503 ; 504 505 506 507 Class class_interfaces [] = theClass.getInterfaces(); 508 Hashtable si = new Hashtable(); 509 510 Class objectClass = null; 511 try 512 { 513 objectClass = this.loader.loadClass( "org.omg.CORBA.Object"); 514 } 515 catch( ClassNotFoundException cnfe ) 516 {} 517 518 for( int i = 0; i < class_interfaces.length; i++ ) 519 { 520 if( objectClass.isAssignableFrom( class_interfaces[i] ) && 521 !class_interfaces[i].getName().equals("org.omg.CORBA.Object") ) 522 { 523 si.put( class_interfaces[i], ""); 524 } 525 } 526 527 Enumeration e = si.keys(); 528 base_names = new String [ si.size() ]; 529 int i = 0; 530 Vector v = new Vector(); 531 while( e.hasMoreElements() ) 532 { 533 try 534 { 535 Class baseClass = (Class )e.nextElement(); 536 base_names[i] = baseClass.getName(); 537 Class helperClass = 538 this.loader.loadClass( base_names[i] + "Helper"); 539 String baseId = 540 (String )helperClass.getDeclaredMethod( "id", (Class []) null).invoke(null, (Object []) null); 541 org.omg.CORBA.InterfaceDef base_interface = 542 org.omg.CORBA.InterfaceDefHelper.narrow( 543 containing_repository.lookup_id( baseId )); 544 if( base_interface == null ) 545 { 546 this.logger.error("Base interface def " + 547 baseId + " is null!!!"); 548 } 549 else 550 { 551 v.addElement( base_interface ); 552 } 553 554 i++; 555 } 556 catch( Exception exc ) 557 { 558 exc.printStackTrace(); 559 } 560 } 561 base_interfaces = new org.omg.CORBA.InterfaceDef [ v.size() ]; 562 v.copyInto( base_interfaces ); 563 564 defined = true; 565 if (this.logger.isDebugEnabled()) 566 { 567 this.logger.debug("Interface " + name + " defined ]"); 568 } 569 } 570 571 572 public boolean is_abstract() 573 { 574 return false; 575 } 576 577 public void is_abstract(boolean arg) 578 { 579 } 580 581 586 587 public org.omg.CORBA.InterfaceDef [] base_interfaces() 588 { 589 return base_interfaces; 590 } 591 592 public FullInterfaceDescription describe_interface() 593 { 594 if ( ! defined) 595 { 596 throw new INTF_REPOS ("InterfaceDef " + name + " not defined."); 597 } 598 599 if( fullDescription == null ) 600 { 601 String def_in = "IDL:Global:1.0"; 602 if( defined_in instanceof org.omg.CORBA.Contained ) 603 def_in = ((org.omg.CORBA.Contained )defined_in).id(); 604 605 607 608 FullInterfaceDescription [] baseDescriptions = 609 new FullInterfaceDescription[ base_interfaces().length ]; 610 611 for( int b = 0; b < base_interfaces.length; b++ ) 612 { 613 baseDescriptions[b] = base_interfaces[b].describe_interface(); 614 } 615 616 617 618 Hashtable ops = new Hashtable(); 619 620 for( int c = 0; c < op_defs.length; c++ ) 621 { 622 OperationDescription operation = op_defs[c].describe_operation(); 623 ops.put( operation.name, operation ); 624 } 625 626 629 630 for( int baseOps = 0; baseOps < baseDescriptions.length; baseOps++ ) 631 { 632 for( int bbaseOps = 0; 633 bbaseOps < baseDescriptions[baseOps].operations.length; 634 bbaseOps++ ) 635 { 636 OperationDescription base_op = 637 baseDescriptions[baseOps].operations[bbaseOps]; 638 639 if( !ops.containsKey( base_op.name )) 640 ops.put( base_op.name, base_op ); 641 } 642 } 643 644 operations = new OperationDescription [ ops.size() ]; 645 646 int opsCount = 0; 647 for( Enumeration e = ops.elements(); e.hasMoreElements(); opsCount++ ) 648 { 649 operations[ opsCount ] = (OperationDescription )e.nextElement(); 650 } 651 ops.clear(); 652 653 654 Hashtable atts = new Hashtable(); 655 656 for( int a = 0; a < att_defs.length; a++ ) 657 { 658 AttributeDescription att = att_defs[a].describe_attribute(); 659 atts.put( att.name, att ); 660 } 661 662 663 664 for( int baseAtts = 0; baseAtts < baseDescriptions.length; baseAtts++ ) 665 { 666 for( int bbaseAtts = 0; 667 bbaseAtts < baseDescriptions[ baseAtts ].attributes.length; 668 bbaseAtts++ ) 669 { 670 AttributeDescription base_att = 671 baseDescriptions[ baseAtts ].attributes[ bbaseAtts ]; 672 673 if( !atts.containsKey( base_att.name )) 674 atts.put( base_att.name, base_att ); 675 } 676 } 677 678 attributes = new AttributeDescription [ atts.size() ]; 679 680 int attsCount = 0; 681 for( Enumeration e = atts.elements(); e.hasMoreElements(); attsCount++ ) 682 { 683 attributes[ attsCount ] = (AttributeDescription )e.nextElement(); 684 } 685 atts.clear(); 686 687 688 689 constants = new org.omg.CORBA.ConstantDescription [ constant_defs.length ]; 690 for( int b = 0; b < constant_defs.length; b++ ) 691 { 692 constants[b] = constant_defs[b].describe_constant(); 693 } 694 695 if (operations == null) 696 { 697 throw new INTF_REPOS ("operations null!"); 698 } 699 if (attributes == null) 700 { 701 throw new INTF_REPOS ("attributes null!"); 702 } 703 704 fullDescription = 705 new FullInterfaceDescription( name, 706 id, 707 def_in, 708 version, 709 operations, 710 attributes, 711 base_names, 712 typeCode, 713 is_abstract ); 714 } 715 return fullDescription; 716 } 717 718 719 public boolean is_a( String interface_id ) 720 { 721 if (this.logger.isDebugEnabled()) 722 { 723 this.logger.debug("Is interface " + id() + " a " + 724 interface_id + "?"); 725 } 726 727 if( id().equals( interface_id )) 728 return true; 729 730 org.omg.CORBA.InterfaceDef [] bases = base_interfaces(); 731 for( int i = 0; i < bases.length; i++ ) 732 { 733 if( bases[i].is_a( interface_id )) 734 return true; 735 if( bases[i].id().equals("IDL:omg.org/CORBA/Object:1.0")) 736 continue; 737 } 738 if (this.logger.isDebugEnabled()) 739 { 740 this.logger.debug( "Interface " + id() + " is not a " + 741 interface_id ); 742 } 743 return false; 744 } 745 746 749 public void base_interfaces( org.omg.CORBA.InterfaceDef [] a ) 750 { 751 throw new INTF_REPOS (ErrorMsg.IR_Not_Implemented, 752 org.omg.CORBA.CompletionStatus.COMPLETED_NO); 753 } 754 755 public org.omg.CORBA.AttributeDef create_attribute( String id, 756 String name, 757 String version, 758 IDLType type, 759 org.omg.CORBA.AttributeMode mode 760 ) 761 { 762 throw new INTF_REPOS ( ErrorMsg.IR_Not_Implemented, 763 org.omg.CORBA.CompletionStatus.COMPLETED_NO); 764 } 765 766 public org.omg.CORBA.OperationDef create_operation( String id, 767 String name, 768 String version, 769 org.omg.CORBA.IDLType result, 770 org.omg.CORBA.OperationMode mode, 771 org.omg.CORBA.ParameterDescription [] params, 772 org.omg.CORBA.ExceptionDef [] exceptions, 773 String [] contexts 774 ) 775 { 776 throw new INTF_REPOS ( ErrorMsg.IR_Not_Implemented, 777 org.omg.CORBA.CompletionStatus.COMPLETED_NO); 778 } 779 780 781 783 public org.omg.CORBA.Contained lookup( String scopedname ) 784 { 785 if (this.logger.isDebugEnabled()) 786 { 787 this.logger.debug("Interface " + this.name + 788 " lookup " + scopedname); 789 } 790 791 String top_level_name; 792 String rest_of_name; 793 String name; 794 795 if( scopedname.startsWith("::") ) 796 { 797 name = scopedname.substring(2); 798 } 799 else 800 name = scopedname; 801 802 if( name.indexOf("::") > 0 ) 803 { 804 top_level_name = name.substring( 0, name.indexOf("::") ); 805 rest_of_name = name.substring( name.indexOf("::") + 2); 806 } 807 else 808 { 809 top_level_name = name; 810 rest_of_name = null; 811 } 812 813 try 814 { 815 org.omg.CORBA.Contained top = 816 (org.omg.CORBA.Contained )contained.get( top_level_name ); 817 818 if( top == null ) 819 { 820 if (this.logger.isDebugEnabled()) 821 { 822 this.logger.debug("Interface " + this.name + 823 " top " + top_level_name + 824 " not found"); 825 } 826 return null; 827 } 828 829 if( rest_of_name == null ) 830 { 831 return top; 832 } 833 else 834 { 835 if( top instanceof org.omg.CORBA.Container ) 836 { 837 return ((org.omg.CORBA.Container )top).lookup( rest_of_name ); 838 } 839 else 840 { 841 if (this.logger.isDebugEnabled()) 842 { 843 this.logger.debug("Interface " + this.name + 844 " " + scopedname + " not found "); 845 } 846 return null; 847 } 848 } 849 } 850 catch( Exception e ) 851 { 852 this.logger.error("Caught exception",e); 853 return null; 854 } 855 856 } 857 858 public org.omg.CORBA.Contained [] contents(org.omg.CORBA.DefinitionKind limit_type, 859 boolean exclude_inherited) 860 { 861 if ( ! defined) 862 { 863 throw new INTF_REPOS ("InterfaceDef " + name + " not defined."); 864 } 865 866 Hashtable limited = new Hashtable(); 867 868 870 for( Enumeration e = contained.elements(); e.hasMoreElements(); ) 871 { 872 org.omg.CORBA.Contained c = (org.omg.CORBA.Contained )e.nextElement(); 873 if( limit_type.value() == org.omg.CORBA.DefinitionKind._dk_all || 874 limit_type.value() == c.def_kind().value() ) 875 { 876 limited.put( c, "" ); 877 } 878 } 879 880 org.omg.CORBA.Contained [] c = 881 new org.omg.CORBA.Contained [limited.size()]; 882 883 int i; 884 Enumeration e; 885 for( e = limited.keys(), i=0 ; e.hasMoreElements(); i++ ) 886 c[i] = (org.omg.CORBA.Contained )e.nextElement(); 887 return c; 888 889 } 890 891 public org.omg.CORBA.Contained [] lookup_name(String search_name, 892 int levels_to_search, 893 org.omg.CORBA.DefinitionKind limit_type, 894 boolean exclude_inherited) 895 { 896 if( levels_to_search == 0 ) 897 return null; 898 899 org.omg.CORBA.Contained [] c = contents( limit_type, exclude_inherited ); 900 Hashtable found = new Hashtable(); 901 902 for( int i = 0; i < c.length; i++) 903 if( c[i].name().equals( search_name ) ) 904 found.put( c[i], "" ); 905 906 if( levels_to_search > 1 || levels_to_search < 0 ) 907 { 908 for( int i = 0; i < c.length; i++) 910 { 911 if( c[i] instanceof org.omg.CORBA.Container ) 912 { 913 org.omg.CORBA.Contained [] tmp_seq = 914 ((org.omg.CORBA.Container )c[i]).lookup_name( search_name, 915 levels_to_search-1, 916 limit_type, 917 exclude_inherited); 918 if( tmp_seq != null ) 919 for( int j = 0; j < tmp_seq.length; j++) 920 found.put( tmp_seq[j], "" ); 921 } 922 } 923 } 924 925 926 org.omg.CORBA.Contained [] result = new org.omg.CORBA.Contained [ found.size() ]; 927 int idx = 0; 928 929 for( Enumeration e = found.keys(); e.hasMoreElements(); ) 930 result[ idx++] = (org.omg.CORBA.Contained )e.nextElement(); 931 932 return result; 933 } 934 935 936 public Description[] describe_contents(org.omg.CORBA.DefinitionKind limit_type, 937 boolean exclude_inherited, 938 int max_returned_objs) 939 { 940 return null; 941 } 942 943 944 946 public org.omg.CORBA.ModuleDef create_module( String id, 947 String name, 948 String version) 949 { 950 return null; 951 } 952 953 public org.omg.CORBA.ConstantDef create_constant( String id, 954 String name, 955 String version, 956 IDLType type, org.omg.CORBA.Any value) 957 { 958 return null; 959 } 960 961 public org.omg.CORBA.StructDef create_struct( String id, 962 String name, 963 String version, 964 org.omg.CORBA.StructMember [] members) 965 { 966 return null; 967 } 968 969 public org.omg.CORBA.UnionDef create_union( String id, 970 String name, 971 String version, 972 org.omg.CORBA.IDLType discriminator_type, 973 org.omg.CORBA.UnionMember [] members) 974 { 975 return null; 976 } 977 978 public org.omg.CORBA.EnumDef create_enum( String id, 979 String name, 980 String version, 981 String [] members) 982 { 983 return null; 984 } 985 986 public org.omg.CORBA.AliasDef create_alias( String id, 987 String name, 988 String version, 989 org.omg.CORBA.IDLType original_type) 990 { 991 return null; 992 } 993 994 995 998 999 public org.omg.CORBA.ExceptionDef create_exception(String id, 1000 String name , 1001 String version, 1002 org.omg.CORBA.StructMember [] member ) 1003 { 1004 return null; 1005 } 1006 1007 1010 1011 public org.omg.CORBA.InterfaceDef create_interface( String id, 1012 String name, 1013 String version, 1014 org.omg.CORBA.InterfaceDef [] base_interfaces, 1015 boolean is_abstract ) 1016 { 1017 return null; 1018 } 1019 1020 1023 1024 public org.omg.CORBA.ValueBoxDef create_value_box(String id, 1025 String name, 1026 String version, 1027 org.omg.CORBA.IDLType type) 1028 { 1029 return null; 1030 } 1031 1032 1033 1036 1037 public org.omg.CORBA.ValueDef create_value(String id, 1038 String name, 1039 String version, 1040 boolean is_custom, 1041 boolean is_abstract, 1042 org.omg.CORBA.ValueDef base_value, 1043 boolean is_truncatable, 1044 org.omg.CORBA.ValueDef [] abstract_base_values, 1045 org.omg.CORBA.InterfaceDef [] supported_interfaces, 1046 org.omg.CORBA.Initializer [] initializers) 1047 { 1048 return null; 1049 } 1050 1051 1052 1055 1056 public org.omg.CORBA.NativeDef create_native(String id, 1057 String name, 1058 String version) 1059 { 1060 return null; 1061 } 1062 1063 1065 public org.omg.CORBA.ContainedPackage.Description describe() 1066 { 1067 if ( ! defined) 1068 { 1069 throw new INTF_REPOS ("InterfaceDef " + name + " not defined."); 1070 } 1071 1072 org.omg.CORBA.Any a = orb.create_any(); 1073 1074 String def_in = null; 1075 1076 if( myContainer == null ) 1077 def_in = "Global"; 1078 else 1079 def_in = myContainer.id(); 1080 1081 org.omg.CORBA.InterfaceDescriptionHelper.insert( a, 1082 new org.omg.CORBA.InterfaceDescription ( name, 1083 id, 1084 def_in, 1085 version, 1086 base_names, 1087 false ) 1088 ); 1089 return new org.omg.CORBA.ContainedPackage.Description( 1090 org.omg.CORBA.DefinitionKind.dk_Interface, a); 1091 } 1092 1093 1095 public void destroy() 1096 { 1097 containedLocals.clear(); 1098 contained.clear(); 1099 } 1100 1101 1103 public org.omg.CORBA.TypeCode type() 1104 { 1105 return typeCode; 1106 } 1107} 1108 | Popular Tags |