1 26 27 package org.objectweb.openccm.ir3; 28 29 import org.omg.CORBA.DefinitionKind ; 31 import org.omg.CORBA.ExtAttributeDescription; 32 33 34 42 43 public class ComponentDef_impl 44 extends ExtInterfaceDef_impl 45 implements org.omg.CORBA.ComponentIR.ComponentDefOperations 46 { 47 53 54 protected InterfaceDef_ref[] supported_interfaces_; 55 56 57 protected ComponentDef_ref base_component_; 58 59 63 protected boolean as_interface_; 64 65 66 protected org.omg.CORBA.ExtLocalInterfaceDef ccm_main_executor_itf_; 67 68 69 protected org.omg.CORBA.ExtLocalInterfaceDef ccm_monolithic_executor_itf_; 70 71 72 protected org.omg.CORBA.ExtLocalInterfaceDef ccm_context_itf_; 73 74 80 83 public 84 ComponentDef_impl(IFR ifr, 85 Container_impl container) 86 { 87 super(ifr, container, false); 89 90 setServant(new org.omg.CORBA.ComponentIR.ComponentDefPOATie(this)); 92 93 supported_interfaces_ = null; 95 base_component_ = new ComponentDef_ref(this); 96 as_interface_ = false; 97 ccm_main_executor_itf_ = null; 98 ccm_monolithic_executor_itf_ = null; 99 ccm_context_itf_ = null; 100 } 101 102 108 111 protected InterfaceDef_ref[] 112 getBaseInterfaces() 113 { 114 if (!getIFR().getRepository().isIDL2Repository()) 115 return new InterfaceDef_ref[0]; 116 else 117 return base_interfaces_; 118 } 119 120 123 protected void 124 addContained(Contained_impl contained) 125 { 126 if (!checkDefinitionKind(contained.def_kind())) 128 throw exceptionInvalidContainer(); 129 130 if (!mapping_started_) 131 contained_elements_.add(contained); 132 133 if (mapping_started_) 134 contained_with_mappings_.add(contained); 135 136 if (contained.def_kind() == org.omg.CORBA.DefinitionKind.dk_Attribute) 137 contained_with_mappings_.add(contained); 138 } 139 140 144 public ExtAttributeDescription[] 145 getLocalExtAttrDescriptionSeq() 146 { 147 java.util.List selection = new java.util.ArrayList (); 148 149 selectContained(selection, DefinitionKind.dk_Attribute, true); 150 151 ExtAttributeDescription[] result = 152 new ExtAttributeDescription[selection.size()]; 153 154 for(int i=0; i<selection.size(); i++) 155 { 156 result[i] = ((ExtAttributeDef_impl)selection.get(i)) 157 .getExtAttributeDescription(); 158 } 159 160 return result; 161 } 162 163 166 protected org.omg.CORBA.ComponentIR.ProvidesDescription[] 167 getProvidesDescriptionSeq() 168 { 169 java.util.List selection = new java.util.ArrayList (); 170 171 selectContained(selection, org.omg.CORBA.DefinitionKind.dk_Provides, true); 172 173 org.omg.CORBA.ComponentIR.ProvidesDescription[] result = 174 new org.omg.CORBA.ComponentIR.ProvidesDescription[selection.size()]; 175 176 for(int i=0; i<selection.size(); i++) 177 result[i] = ((ProvidesDef_impl)selection.get(i)) 178 .describe_provides(); 179 180 return result; 181 } 182 183 186 protected org.omg.CORBA.ComponentIR.UsesDescription[] 187 getUsesDescriptionSeq() 188 { 189 java.util.List selection = new java.util.ArrayList (); 190 191 selectContained(selection, org.omg.CORBA.DefinitionKind.dk_Uses, true); 192 193 org.omg.CORBA.ComponentIR.UsesDescription[] result = 194 new org.omg.CORBA.ComponentIR.UsesDescription[selection.size()]; 195 196 for(int i=0; i<selection.size(); i++) 197 result[i] = ((UsesDef_impl)selection.get(i)) 198 .describe_uses(); 199 200 return result; 201 } 202 203 207 protected org.omg.CORBA.ComponentIR.EventPortDescription[] 208 getEventPortDescriptionSeq(org.omg.CORBA.DefinitionKind kind) 209 { 210 java.util.List selection = new java.util.ArrayList (); 211 212 selectContained(selection, kind, true); 213 214 org.omg.CORBA.ComponentIR.EventPortDescription[] result = 215 new org.omg.CORBA.ComponentIR.EventPortDescription[selection.size()]; 216 217 for(int i=0; i<selection.size(); i++) 218 result[i] = ((EventPortDef_impl)selection.get(i)) 219 .describe_event_port(); 220 221 return result; 222 } 223 224 228 protected org.omg.CORBA.ComponentIR.EventPortDescription[] 229 getEmitsDescriptionSeq() 230 { 231 return getEventPortDescriptionSeq(org.omg.CORBA.DefinitionKind.dk_Emits); 232 } 233 234 238 protected org.omg.CORBA.ComponentIR.EventPortDescription[] 239 getPublishesDescriptionSeq() 240 { 241 return getEventPortDescriptionSeq(org.omg.CORBA.DefinitionKind.dk_Publishes); 242 } 243 244 248 protected org.omg.CORBA.ComponentIR.EventPortDescription[] 249 getConsumesDescriptionSeq() 250 { 251 return getEventPortDescriptionSeq(org.omg.CORBA.DefinitionKind.dk_Consumes); 252 } 253 254 260 263 public org.omg.CORBA.ComponentIR.ComponentDef 264 asComponentDef() 265 { 266 return org.omg.CORBA.ComponentIR.ComponentDefHelper.narrow(asObject()); 267 } 268 269 275 278 public void 279 setDescriptionValue(org.omg.CORBA.Any any) 280 { 281 org.omg.CORBA.ComponentIR.ComponentDescription description = 283 new org.omg.CORBA.ComponentIR.ComponentDescription(); 284 description.name = name(); 285 description.id = id(); 286 description.defined_in = getContainerID(); 287 description.version = version(); 288 description.base_component = base_component_.getId(); 289 description.supported_interfaces = InterfaceDef_ref. 290 computeRepositoryIdSeq(supported_interfaces_); 291 description.provided_interfaces = getProvidesDescriptionSeq(); 292 description.used_interfaces = getUsesDescriptionSeq(); 293 description.emits_events = getEmitsDescriptionSeq(); 294 description.publishes_events = getPublishesDescriptionSeq(); 295 description.consumes_events = getConsumesDescriptionSeq(); 296 description.attributes = getLocalExtAttrDescriptionSeq(); 297 description.type = type(); 299 300 org.omg.CORBA.ComponentIR.ComponentDescriptionHelper.insert(any, description); 302 } 303 304 310 313 public boolean 314 checkDefinitionKind(org.omg.CORBA.DefinitionKind dk) 315 { 316 if ((as_interface_) || (getIFR().getRepository().isIDL2Repository())) 317 return super.checkDefinitionKind(dk); 320 321 return (dk == org.omg.CORBA.DefinitionKind.dk_Attribute) 322 || (dk == org.omg.CORBA.DefinitionKind.dk_Provides) 323 || (dk == org.omg.CORBA.DefinitionKind.dk_Uses) 324 || (dk == org.omg.CORBA.DefinitionKind.dk_Emits) 325 || (dk == org.omg.CORBA.DefinitionKind.dk_Publishes) 326 || (dk == org.omg.CORBA.DefinitionKind.dk_Consumes); 327 } 328 329 332 public void 333 checkName(String name, 334 boolean exclude_inherited, 335 boolean in_inherited) 336 { 337 super.checkName(name, exclude_inherited, in_inherited); 339 340 if(!exclude_inherited) 341 { 342 } 344 } 345 346 352 355 protected void 356 cutDependencies() 357 { 358 if(ccm_context_itf_ != null) 360 { 361 try 362 { 363 ccm_context_itf_.destroy(); 364 } 365 catch(org.omg.CORBA.OBJECT_NOT_EXIST exc) 366 { 367 } 369 ccm_context_itf_ = null; 370 } 371 372 if(ccm_monolithic_executor_itf_ != null) 373 { 374 try 375 { 376 ccm_monolithic_executor_itf_.destroy(); 377 } 378 catch(org.omg.CORBA.OBJECT_NOT_EXIST exc) 379 { 380 } 382 ccm_monolithic_executor_itf_ = null; 383 } 384 385 if(ccm_main_executor_itf_ != null) 386 { 387 try 388 { 389 ccm_main_executor_itf_.destroy(); 390 } 391 catch(org.omg.CORBA.OBJECT_NOT_EXIST exc) 392 { 393 } 395 ccm_main_executor_itf_ = null; 396 } 397 398 InterfaceDef_ref.cutDependencies(supported_interfaces_); 400 supported_interfaces_ = null; 401 402 base_component_.cutDependency(); 404 base_component_ = null; 405 406 while(contained_elements_.size() != 0) 408 { 409 ((Contained_impl) contained_elements_.get(contained_elements_.size() -1)).destroy(); 410 } 411 412 super.cutDependencies(); 414 } 415 416 422 425 public org.omg.CORBA.DefinitionKind 426 def_kind() 427 { 428 if (getIFR().getRepository().isIDL2Repository()) 429 return org.omg.CORBA.DefinitionKind.dk_Interface; 430 431 return org.omg.CORBA.DefinitionKind.dk_Component; 432 } 433 434 440 443 public org.omg.CORBA.TypeCode 444 type() 445 { 446 448 453 return getIFR().getTCF().create_interface_tc(id(), name()); 454 } 455 456 462 465 public void 466 move(org.omg.CORBA.Container new_container, 467 String new_name, 468 String new_version) 469 { 470 super.move(new_container, new_name, new_version); 472 473 if (!getIFR().getRepository().enable_mappings_) 475 return ; 476 477 org.omg.CORBA.LocalInterfaceDef litf = null; 478 String cont_base_id = getBaseContainerID(); 479 480 container_.mapping_started_ = true; 481 482 java.lang.String name = "CCM_"+name()+"_Executor"; 484 java.lang.String id = cont_base_id + name + ':' + new_version; 485 litf = org.omg.CORBA.LocalInterfaceDefHelper.narrow( 486 getIFR().getRepository().lookup_mapped_id(id)); 487 litf.move(new_container, name, new_version); 488 489 name = "CCM_"+name(); 491 id = cont_base_id + name + ':' + new_version; 492 litf = org.omg.CORBA.LocalInterfaceDefHelper.narrow( 493 getIFR().getRepository().lookup_mapped_id(id)); 494 litf.move(new_container, name, new_version); 495 496 name = "CCM_"+name()+"_Context"; 498 id = cont_base_id + name + ':' + new_version; 499 litf = org.omg.CORBA.LocalInterfaceDefHelper.narrow( 500 getIFR().getRepository().lookup_mapped_id(id)); 501 litf.move(new_container, name, new_version); 502 503 container_.mapping_started_ = false; 504 505 whenMoved(); 507 } 508 509 515 518 public org.omg.CORBA.Contained 519 lookup(String search_name) 520 { 521 org.omg.CORBA.Contained contained = super.lookup(search_name); 523 524 if (contained == null) 525 { 526 } 528 529 return contained; 530 } 531 532 535 public org.omg.CORBA.Contained [] 536 contents(org.omg.CORBA.DefinitionKind limit_type, 537 boolean exclude_inherited) 538 { 539 org.omg.CORBA.Contained [] result = super.contents(limit_type, exclude_inherited); 541 542 if(!exclude_inherited && (base_component() != null)) 543 { 544 org.omg.CORBA.Contained [] result2 = base_component().contents(limit_type, exclude_inherited); 545 org.omg.CORBA.Contained [] result3 = result; 546 result = new org.omg.CORBA.Contained [result3.length + result2.length]; 547 System.arraycopy(result2, 0, result, 0, result2.length); 548 System.arraycopy(result3, 0, result, result2.length, result3.length); 549 } 550 551 return result; 552 } 553 554 557 public org.omg.CORBA.Contained [] 558 lookup_name(String search_name, 559 int levels_to_search, 560 org.omg.CORBA.DefinitionKind limit_type, 561 boolean exclude_inherited) 562 { 563 org.omg.CORBA.Contained [] result = 565 super.lookup_name(search_name, levels_to_search, 566 limit_type, exclude_inherited); 567 568 if(!exclude_inherited) 569 { 570 } 572 573 return result; 574 } 575 576 582 585 public org.omg.CORBA.InterfaceDef [] 586 supported_interfaces() 587 { 588 return InterfaceDef_ref.computeInterfaceDefSeq(supported_interfaces_); 589 } 590 591 594 public void 595 supported_interfaces(org.omg.CORBA.InterfaceDef [] val) 596 { 597 InterfaceDef_impl[] itfs = new InterfaceDef_impl[val.length]; 598 for (int i=0; i<val.length; i++) 599 itfs[i] = castToLocal(val[i]); 600 601 603 InterfaceDef_ref[] refs = new InterfaceDef_ref[val.length]; 604 for (int i=0; i<val.length; i++) 605 refs[i] = new InterfaceDef_ref( this, itfs[i] ); 606 607 InterfaceDef_ref.cutDependencies(supported_interfaces_); 609 610 supported_interfaces_ = refs; 611 } 612 613 616 public org.omg.CORBA.ComponentIR.ComponentDef 617 base_component() 618 { 619 return base_component_.asComponentDef(); 621 } 622 623 632 public void 633 base_component(org.omg.CORBA.ComponentIR.ComponentDef val) 634 { 635 if (val == null) 636 base_component_.setDependency( null ); 637 else 638 { 639 base_component_.setDependency(castToLocal(val)); 642 } 643 } 644 645 648 public org.omg.CORBA.ComponentIR.ProvidesDef 649 create_provides(String id, 650 String name, 651 String version, 652 org.omg.CORBA.InterfaceDef interface_type) 653 { 654 ProvidesDef_impl pr = new ProvidesDef_impl(getIFR(), this); 655 656 try 657 { 658 addContained(pr, id, name, version); 659 pr.interface_type(interface_type); 660 } 661 catch(org.omg.CORBA.SystemException exc) 662 { 663 pr.destroy(); 664 throw exc; 665 } 666 667 as_interface_ = true; 668 pr.whenCreated(); 669 as_interface_ = false; 670 return pr.asProvidesDef(); 671 } 672 673 676 public org.omg.CORBA.ComponentIR.UsesDef 677 create_uses(String id, 678 String name, 679 String version, 680 org.omg.CORBA.InterfaceDef interface_type, 681 boolean is_multiple) 682 { 683 UsesDef_impl uses = new UsesDef_impl(getIFR(), this); 684 685 try 686 { 687 addContained(uses, id, name, version); 688 uses.interface_type(interface_type); 689 uses.is_multiple(is_multiple); 690 } 691 catch(org.omg.CORBA.SystemException exc) 692 { 693 uses.destroy(); 694 throw exc; 695 } 696 697 as_interface_ = true; 698 uses.whenCreated(); 699 as_interface_ = false; 700 return uses.asUsesDef(); 701 } 702 703 706 public org.omg.CORBA.ComponentIR.EmitsDef 707 create_emits(String id, 708 String name, 709 String version, 710 org.omg.CORBA.ComponentIR.EventDef value) 711 { 712 EmitsDef_impl e = new EmitsDef_impl(getIFR(), this); 713 714 try 715 { 716 addContained(e, id, name, version); 717 e.event(value); 718 } 719 catch(org.omg.CORBA.SystemException exc) 720 { 721 e.destroy(); 722 throw exc; 723 } 724 725 as_interface_ = true; 726 e.whenCreated(); 727 as_interface_ = false; 728 return e.asEmitsDef(); 729 } 730 731 734 public org.omg.CORBA.ComponentIR.PublishesDef 735 create_publishes(String id, 736 String name, 737 String version, 738 org.omg.CORBA.ComponentIR.EventDef value) 739 { 740 PublishesDef_impl p = new PublishesDef_impl(getIFR(), this); 741 742 try 743 { 744 addContained(p, id, name, version); 745 p.event(value); 746 } 747 catch(org.omg.CORBA.SystemException exc) 748 { 749 p.destroy(); 750 throw exc; 751 } 752 753 as_interface_ = true; 754 p.whenCreated(); 755 as_interface_ = false; 756 return p.asPublishesDef(); 757 } 758 759 762 public org.omg.CORBA.ComponentIR.ConsumesDef 763 create_consumes(String id, 764 String name, 765 String version, 766 org.omg.CORBA.ComponentIR.EventDef value) 767 { 768 ConsumesDef_impl c = new ConsumesDef_impl(getIFR(), this); 769 770 try 771 { 772 addContained(c, id, name, version); 773 c.event(value); 774 } 775 catch(org.omg.CORBA.SystemException exc) 776 { 777 c.destroy(); 778 throw exc; 779 } 780 781 as_interface_ = true; 782 c.whenCreated(); 783 as_interface_ = false; 784 return c.asConsumesDef(); 785 } 786 787 793 796 protected void 797 whenCreated() 798 { 799 if (!getIFR().getRepository().enable_mappings_) 801 return ; 802 803 805 String cont_base_id = getBaseContainerID(); 818 String name = "CCM_"+name()+"_Executor"; 819 String version = version(); 820 String id = cont_base_id + name + ':' + version; 821 container_.mapping_started_ = true; 822 org.omg.CORBA.ExtLocalInterfaceDef litf = 823 container_.create_ext_local_interface(id, name, version, new org.omg.CORBA.InterfaceDef [0]); 824 825 ccm_main_executor_itf_ = litf; 827 828 container_.mapping_started_ = false; 829 830 name = "CCM_"+name(); 841 id = cont_base_id + name + ':' + version; 842 843 container_.mapping_started_ = true; 844 org.omg.CORBA.ExtLocalInterfaceDef litf2 = 845 container_.create_ext_local_interface(id, name, version, new org.omg.CORBA.InterfaceDef [0]); 846 847 ccm_monolithic_executor_itf_ = litf2; 849 850 container_.mapping_started_ = false; 851 852 name = "CCM_"+name()+"_Context"; 863 id = cont_base_id + name + ':' + version; 864 container_.mapping_started_ = true; 865 ccm_context_itf_ = container_.create_ext_local_interface(id, name, version, 867 new org.omg.CORBA.InterfaceDef [0]); 868 container_.mapping_started_ = false; 869 } 870 871 874 protected void 875 whenMoved() 876 { 877 if (!getIFR().getRepository().enable_mappings_) 879 return ; 880 881 883 org.omg.CORBA.InterfaceDef [] itfs = 891 new org.omg.CORBA.InterfaceDef [1+supported_interfaces_.length]; 892 if (base_component_.getImpl()==null) 893 { 894 itfs[0] = org.omg.CORBA.InterfaceDefHelper.narrow( 895 getIFR().getRepository().lookup("::Components::CCMObject")); 896 } 897 else 898 { 899 itfs[0] = base_component_.asComponentDef(); 900 } 901 for (int i=0;i<supported_interfaces_.length;i++) 905 { 906 itfs[1+i] = supported_interfaces_[i].asInterfaceDef(); 907 } 908 909 base_interfaces(itfs); 910 911 container_.mapping_started_ = true; 913 getIFR().getRepository().addRID(id(), this); 914 container_.mapping_started_ = false; 915 916 929 String cont_base_id = getBaseContainerID(); 931 String name = "CCM_"+name()+"_Executor"; 932 String version = version(); 933 String id = cont_base_id + name + ':' + version; 934 org.omg.CORBA.ExtLocalInterfaceDef litf = org.omg.CORBA.ExtLocalInterfaceDefHelper.narrow(getIFR().getRepository().lookup_mapped_id(id)); 935 936 org.omg.CORBA.InterfaceDef [] bases = new org.omg.CORBA.InterfaceDef [supported_interfaces_.length+1]; 938 if (base_component_.getImpl()==null) 939 { 940 bases[0] = org.omg.CORBA.InterfaceDefHelper.narrow( 941 getIFR().getRepository().lookup("::Components::EnterpriseComponent")); 942 } 943 else 944 { 945 String base_cont_base_id = base_component_.getImpl().getBaseContainerID(); 946 String base_component_exe_id = base_cont_base_id + "CCM_" + 947 base_component_.getImpl().name() + "_Executor:" + 948 base_component_.getImpl().version(); 949 bases[0] = org.omg.CORBA.InterfaceDefHelper.narrow( 950 getIFR().getRepository().lookup_mapped_id(base_component_exe_id)); 951 } 952 953 for (int i=0;i<supported_interfaces_.length;i++) 954 { 955 bases[1+i] = supported_interfaces_[i].asInterfaceDef(); 956 } 957 958 container_.mapping_started_ = true; 959 litf.base_interfaces(bases); 960 container_.mapping_started_ = false; 961 962 963 bases = new org.omg.CORBA.InterfaceDef [1]; 974 bases[0] = litf; 975 name = "CCM_"+name(); 976 id = cont_base_id + name + ':' + version; 977 org.omg.CORBA.ExtLocalInterfaceDef litf2 = org.omg.CORBA.ExtLocalInterfaceDefHelper.narrow(getIFR().getRepository().lookup_mapped_id(id)); 978 979 container_.mapping_started_ = true; 980 litf2.base_interfaces(bases); 981 container_.mapping_started_ = false; 982 983 if (base_component_.getImpl()!=null) 985 { 986 String base_cont_base_id = base_component_.getImpl().getBaseContainerID(); 987 String base_component_exe_id = base_cont_base_id + "CCM_" + 988 base_component_.getImpl().name() + ':' + 989 base_component_.getImpl().version(); 990 org.omg.CORBA.LocalInterfaceDef base_monolithic = 991 org.omg.CORBA.LocalInterfaceDefHelper.narrow( 992 getIFR().getRepository().lookup_mapped_id(base_component_exe_id)); 993 994 org.omg.CORBA.Contained [] contents = 995 base_monolithic.contents(org.omg.CORBA.DefinitionKind.dk_Operation, 996 true); 997 998 org.omg.CORBA.OperationDef op = null; 999 String op_base_id = cont_base_id + name + '/'; 1000 1001 1002 for (int i=0;i<contents.length;i++) 1003 { 1004 1005 op = org.omg.CORBA.OperationDefHelper.narrow(contents[i]); 1006 litf2.create_operation(op_base_id+op.name()+':'+op.version(), 1007 op.name(), 1008 op.version(), 1009 op.result_def(), 1010 op.mode(), 1011 op.params(), 1012 op.exceptions(), 1013 op.contexts()); 1014 } 1015 } 1016 1017 1018 1019 name = "CCM_"+name()+"_Context"; 1030 id = cont_base_id + name + ':' + version; 1031 org.omg.CORBA.ExtLocalInterfaceDef litf3 = org.omg.CORBA.ExtLocalInterfaceDefHelper.narrow(getIFR().getRepository().lookup_mapped_id(id)); 1032 1033 bases = new org.omg.CORBA.InterfaceDef [1]; 1034 if (base_component_.getImpl()==null) 1035 { 1036 bases[0] = org.omg.CORBA.InterfaceDefHelper.narrow( 1037 getIFR().getRepository().lookup("::Components::CCMContext")); 1038 } 1039 else 1040 { 1041 String base_cont_base_id = base_component_.getImpl().getBaseContainerID(); 1042 String base_component_exe_id = base_cont_base_id + "CCM_" + 1043 base_component().name() + "_Context:" + 1044 base_component().version(); 1045 bases[0] = org.omg.CORBA.InterfaceDefHelper.narrow( 1046 getIFR().getRepository().lookup_mapped_id(base_component_exe_id)); 1047 } 1048 1049 container_.mapping_started_ = true; 1050 litf3.base_interfaces(bases); 1051 container_.mapping_started_ = false; 1052 } 1053} 1054 | Popular Tags |