KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > HomeDef_impl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Philippe Merle.
23 Contributor(s): Mathieu Vadet, Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ir3;
28
29 /**
30  * Implementation of the CORBA::ComponentIR::HomeDef interface.
31  *
32  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
33  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
34  *
35  * @version 0.5
36  */

37
38 public class HomeDef_impl
39      extends ExtInterfaceDef_impl
40   implements org.omg.CORBA.ComponentIR.HomeDefOperations
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     /** The supported interfaces. */
49     protected InterfaceDef_ref[] supported_interfaces_;
50
51     /** The base home. */
52     protected HomeDef_ref base_home_;
53     
54     /** The managed component. */
55     protected ComponentDef_ref managed_component_;
56
57     /** The primary key. */
58     protected ValueDef_ref primary_key_;
59
60     /** Reference to the IDL implicit home interface. */
61     protected org.omg.CORBA.ExtInterfaceDef implicit_itf_;
62
63     /** Reference to the IDL explicit home interface. */
64     protected org.omg.CORBA.ExtInterfaceDef explicit_itf_;
65
66     /** Reference to the IDL local implicit home executor interface. */
67     protected org.omg.CORBA.ExtLocalInterfaceDef ccm_implicit_executor_itf_;
68
69     /** Reference to the IDL local explicit home executor interface. */
70     protected org.omg.CORBA.ExtLocalInterfaceDef ccm_explicit_executor_itf_;
71
72     /** Reference to the IDL local home executor interface. */
73     protected org.omg.CORBA.ExtLocalInterfaceDef ccm_executor_itf_;
74
75     // ==================================================================
76
//
77
// Constructor.
78
//
79
// ==================================================================
80

81     /** Default constructor. */
82     public
83     HomeDef_impl(IFR ifr,
84                  Container_impl container)
85     {
86         // Calls the InterfaceDef_impl constructor.
87
super(ifr, container, false);
88
89         // Sets the tie servant object.
90
setServant(new org.omg.CORBA.ComponentIR.HomeDefPOATie(this));
91
92         // Inits internal state.
93
supported_interfaces_ = null;
94         base_home_ = new HomeDef_ref(this);
95         managed_component_ = new ComponentDef_ref(this);
96         primary_key_ = new ValueDef_ref(this);
97         implicit_itf_ = null;
98         explicit_itf_ = null;
99         ccm_implicit_executor_itf_ = null;
100         ccm_explicit_executor_itf_ = null;
101         ccm_executor_itf_ = null;
102     }
103
104     // ==================================================================
105
//
106
// Internal methods.
107
//
108
// ==================================================================
109

110     /**
111      * Adds a contained object to the container.
112      */

113     protected void
114     addContained(Contained_impl contained)
115     {
116         // check if the kind of this contained object is accepted.
117
if (!checkDefinitionKind(contained.def_kind()))
118             throw exceptionInvalidContainer();
119
120         if (!mapping_started_)
121             contained_elements_.add(contained);
122
123         if ((contained.def_kind().value()==org.omg.CORBA.DefinitionKind._dk_Finder) ||
124             (contained.def_kind().value()==org.omg.CORBA.DefinitionKind._dk_Factory))
125             contained_with_mappings_.add(contained);
126     }
127
128     /**
129      * Obtains the list of base interfaces.
130      */

131     protected InterfaceDef_ref[]
132     getBaseInterfaces()
133     {
134         if (!getIFR().getRepository().isIDL2Repository())
135             return new InterfaceDef_ref[0];
136         else
137             return base_interfaces_;
138     }
139
140     // ==================================================================
141
//
142
// Public methods.
143
//
144
// ==================================================================
145

146     /**
147      * Obtains its CORBA::ComponentIR::HomeDef object reference.
148      */

149     public org.omg.CORBA.ComponentIR.HomeDef
150     asHomeDef()
151     {
152         return org.omg.CORBA.ComponentIR.HomeDefHelper.narrow(asObject());
153     }
154
155     /**
156      * Obtains the CORBA::ValueDescription of the primary key.
157      */

158     public org.omg.CORBA.ValueDescription JavaDoc
159     getPrimaryKeyDescription()
160     {
161 //
162
// Correction of the Bug #300849
163
// Contributor: Philippe Merle - INRIA
164
//
165
// If a home has no primary key then a NullPointerException is thrown
166
// when calling the CORBA::Contained::describe operation on
167
// the OpenCCM Interface Repository object reflecting this home.
168
//
169
// Thanks to Vincent Seignole from THALES for pointing this bug out.
170
//
171
// OLD CODE
172
//
173
// return primary_key_.getImpl().getValueDescription();
174
//
175
// NEW CODE
176
//
177

178         // Declares the ValueDescription to return.
179
org.omg.CORBA.ValueDescription JavaDoc result = null;
180
181         // If a primary key is associated to the home
182
if(primary_key_.getImpl() != null)
183         {
184             // Then returns the ValueDescription of the primary key.
185
result = primary_key_.getImpl().getValueDescription();
186         }
187         else
188         {
189             // Else returns an empty ValueDescription, i.e.
190
// zero-length strings and sequences, booleans at false.
191
result = new org.omg.CORBA.ValueDescription JavaDoc();
192             result.name = "";
193             result.id = "";
194             result.is_abstract = false;
195             result.is_custom = false;
196             result.defined_in = "";
197             result.version = "";
198             result.supported_interfaces = new String JavaDoc[0];
199             result.abstract_base_values = new String JavaDoc[0];
200             result.is_truncatable = false;
201             result.base_value = "";
202         }
203
204         // Returns the computed ValueDescription.
205
return result;
206
207 //
208
// END CODE
209
//
210
}
211
212     // Added Bug #300152
213
/**
214      * Compute its CORBA::ExtAttrDescriptionSeq.
215      */

216     public org.omg.CORBA.ExtAttributeDescription[]
217     getLocalExtAttrDescriptionSeq()
218     {
219         java.util.List JavaDoc selection = new java.util.ArrayList JavaDoc();
220
221         selectContained(selection, org.omg.CORBA.DefinitionKind.dk_Attribute, true);
222
223         org.omg.CORBA.ExtAttributeDescription[] result =
224                   new org.omg.CORBA.ExtAttributeDescription[selection.size()];
225
226         for(int i=0; i<selection.size(); i++)
227         {
228             result[i] = ((ExtAttributeDef_impl)selection.get(i))
229                         .getExtAttributeDescription();
230         }
231
232         return result;
233     }
234     
235     /**
236      * Obtains the CORBA::OperationDescription of a specific DefinitionKind.
237      */

238     public org.omg.CORBA.OperationDescription JavaDoc[]
239     getOpDescriptionSeq(org.omg.CORBA.DefinitionKind JavaDoc kind)
240     {
241         java.util.List JavaDoc selection = new java.util.ArrayList JavaDoc();
242
243         selectContained(selection, kind, true);
244
245         org.omg.CORBA.OperationDescription JavaDoc[] result =
246             new org.omg.CORBA.OperationDescription JavaDoc[selection.size()];
247
248         for(int i=0; i<selection.size(); i++)
249             result[i] = ((OperationDef_impl)selection.get(i))
250                         .getOperationDescription();
251
252         return result;
253     }
254
255     /**
256      * Obtains the CORBA::OperationDescription of the factories.
257      */

258     public org.omg.CORBA.OperationDescription JavaDoc[]
259     getFactoryDescriptionSeq()
260     {
261         return getOpDescriptionSeq(org.omg.CORBA.DefinitionKind.dk_Factory);
262     }
263
264     /**
265      * Obtains the CORBA::OperationDescription of the finders.
266      */

267     public org.omg.CORBA.OperationDescription JavaDoc[]
268     getFinderDescriptionSeq()
269     {
270         return getOpDescriptionSeq(org.omg.CORBA.DefinitionKind.dk_Finder);
271     }
272
273     // ==================================================================
274
//
275
// For Contained_impl class.
276
//
277
// ==================================================================
278

279     /**
280      * Sets the value field of the CORBA::Contained::Description struct.
281      */

282     public void
283     setDescriptionValue(org.omg.CORBA.Any JavaDoc any)
284     {
285         // create the CORBA::HomeDescription.
286
org.omg.CORBA.ComponentIR.HomeDescription description =
287             new org.omg.CORBA.ComponentIR.HomeDescription();
288         description.name = name();
289         description.id = id();
290         description.defined_in = getContainerID();
291         description.version = version();
292         description.base_home = base_home_.getId();
293         description.managed_component = managed_component_.getId();
294         description.primary_key = getPrimaryKeyDescription();
295         description.factories = getFactoryDescriptionSeq();
296         description.finders = getFinderDescriptionSeq();
297         description.operations = getOpDescriptionSeq(org.omg.CORBA.DefinitionKind.dk_Operation);
298         description.attributes = getLocalExtAttrDescriptionSeq();
299         // description.is_basic = is_basic();
300
description.type = type();
301
302         // insert it into the any.
303
org.omg.CORBA.ComponentIR.HomeDescriptionHelper.insert(any, description);
304     }
305
306     // ==================================================================
307
//
308
// For Container_impl class.
309
//
310
// ==================================================================
311

312     /**
313      * Checks if this kind of objects is accepted by the container.
314      */

315     public boolean
316     checkDefinitionKind(org.omg.CORBA.DefinitionKind JavaDoc dk)
317     {
318         return super.checkDefinitionKind(dk)
319             || (dk == org.omg.CORBA.DefinitionKind.dk_Factory)
320             || (dk == org.omg.CORBA.DefinitionKind.dk_Finder);
321     }
322
323     /**
324      * Checks a new name according to already contained names.
325      */

326     public void
327     checkName(String JavaDoc name,
328               boolean exclude_inherited,
329               boolean in_inherited)
330     {
331         // calls the InterfaceDef_impl::checkName operation.
332
super.checkName(name, exclude_inherited, in_inherited);
333
334         if(!exclude_inherited)
335         {
336             // TODO;
337
}
338     }
339
340     // ==================================================================
341
//
342
// Internal methods for managing dependencies.
343
//
344
// ==================================================================
345

346     /**
347      * Cuts dependencies to other objects.
348      */

349     protected void
350     cutDependencies()
351     {
352         // Destroys equivalent local interfaces.
353
if(ccm_executor_itf_ != null)
354         {
355             try
356             {
357                 ccm_executor_itf_.destroy();
358             }
359             catch(org.omg.CORBA.OBJECT_NOT_EXIST JavaDoc exc)
360             {
361                 // Thrown because this interface was previously destroyed.
362
}
363             ccm_executor_itf_ = null;
364         }
365
366         if(ccm_implicit_executor_itf_ != null)
367         {
368             try
369             {
370                 ccm_implicit_executor_itf_.destroy();
371             }
372             catch(org.omg.CORBA.OBJECT_NOT_EXIST JavaDoc exc)
373             {
374                 // Thrown because this interface was previously destroyed.
375
}
376             ccm_implicit_executor_itf_ = null;
377         }
378
379         if(ccm_explicit_executor_itf_ != null)
380         {
381             try
382             {
383                 ccm_explicit_executor_itf_.destroy();
384             }
385             catch(org.omg.CORBA.OBJECT_NOT_EXIST JavaDoc exc)
386             {
387                 // Thrown because this interface was previously destroyed.
388
}
389             ccm_explicit_executor_itf_ = null;
390         }
391
392         // cut the dependency to the base home.
393
base_home_.cutDependency();
394         base_home_ = null;
395
396         // cut the dependency to the managed component.
397
managed_component_.cutDependency();
398         managed_component_ = null;
399
400         // cut the dependency to the primary key.
401
primary_key_.cutDependency();
402         primary_key_ = null;
403
404         // Destroys all the contained objects.
405
while(contained_elements_.size() != 0)
406         {
407             ((Contained_impl) contained_elements_.get(contained_elements_.size() -1)).destroy();
408         }
409
410         // Calls the InterfaceDef_impl::cutDependencies operation.
411
super.cutDependencies();
412
413         // Destroys the equivalent implicit interface.
414
if(implicit_itf_ != null)
415         {
416             try
417             {
418                 implicit_itf_.destroy();
419             }
420             catch(org.omg.CORBA.OBJECT_NOT_EXIST JavaDoc exc)
421             {
422                 // Thrown because this interface was previously destroyed.
423
}
424             implicit_itf_ = null;
425         }
426
427         // Destroys the equivalent explicit interface.
428
if(explicit_itf_ != null)
429         {
430             try
431             {
432                 explicit_itf_.destroy();
433             }
434             catch(org.omg.CORBA.OBJECT_NOT_EXIST JavaDoc exc)
435             {
436                 // Thrown because this interface was previously destroyed.
437
}
438             explicit_itf_ = null;
439         }
440     }
441
442     // ==================================================================
443
//
444
// For CORBA::IRObject interface.
445
//
446
// ==================================================================
447

448     /**
449      * IDL:omg.org/CORBA/IRObject/def_kind:1.0
450      */

451     public org.omg.CORBA.DefinitionKind JavaDoc
452     def_kind()
453     {
454         if (getIFR().getRepository().isIDL2Repository())
455             return org.omg.CORBA.DefinitionKind.dk_Interface;
456
457         return org.omg.CORBA.DefinitionKind.dk_Home;
458     }
459
460     // ==================================================================
461
//
462
// For CORBA::IDLType interface.
463
//
464
// ==================================================================
465

466     /**
467      * IDL:omg.org/CORBA/IDLType/type:1.0
468      */

469     public org.omg.CORBA.TypeCode JavaDoc
470     type()
471     {
472         // delegate to the TypeCodeFactory.
473

474         //
475
// TODO: need to change ORBacus
476
//
477
// return getIFR().getTCF().create_home_tc(id(), name());
478

479         return getIFR().getTCF().create_interface_tc(id(), name());
480     }
481
482     // ==================================================================
483
//
484
// For CORBA::Contained interface.
485
//
486
// ==================================================================
487

488     /**
489      * IDL:omg.org/CORBA/Contained/move:1.0
490      */

491     public void
492     move(org.omg.CORBA.Container JavaDoc new_container,
493          String JavaDoc new_name,
494          String JavaDoc new_version)
495     {
496         // move the home first
497
super.move(new_container, new_name, new_version);
498
499         // do nothing if mappings are not enabled.
500
if (!getIFR().getRepository().enable_mappings_)
501             return ;
502                       
503         org.omg.CORBA.LocalInterfaceDef litf = null;
504         String JavaDoc cont_base_id = getBaseContainerID();
505
506         container_.mapping_started_ = true;
507  
508         // move the local explicit home
509
java.lang.String JavaDoc name = "CCM_"+name()+"Explicit";
510         java.lang.String JavaDoc id = cont_base_id + name + ':' + new_version;
511         litf = org.omg.CORBA.LocalInterfaceDefHelper.narrow(
512             getIFR().getRepository().lookup_mapped_id(id));
513         litf.move(new_container, name, new_version);
514
515         // move the local implicit home
516
name = "CCM_"+name()+"Implicit";
517         id = cont_base_id + name + ':' + new_version;
518         litf = org.omg.CORBA.LocalInterfaceDefHelper.narrow(
519             getIFR().getRepository().lookup_mapped_id(id));
520         litf.move(new_container, name, new_version);
521
522         // move the local home
523
name = "CCM_"+name();
524         id = cont_base_id + name + ':' + new_version;
525         litf = org.omg.CORBA.LocalInterfaceDefHelper.narrow(
526             getIFR().getRepository().lookup_mapped_id(id));
527         litf.move(new_container, name, new_version);
528
529         container_.mapping_started_ = false;
530     }
531
532     // ==================================================================
533
//
534
// For CORBA::Container interface.
535
//
536
// ==================================================================
537

538     /**
539      * IDL:omg.org/CORBA/Container/lookup:1.0
540      */

541     public org.omg.CORBA.Contained JavaDoc
542     lookup(String JavaDoc search_name)
543     {
544         // calls the InterfaceDef_impl::lookup operation.
545
org.omg.CORBA.Contained JavaDoc contained = super.lookup(search_name);
546
547         if (contained == null)
548         {
549             // TODO
550
}
551
552         return contained;
553     }
554
555     /**
556      * IDL:omg.org/CORBA/Container/contents:1.0
557      */

558     public org.omg.CORBA.Contained JavaDoc[]
559     contents(org.omg.CORBA.DefinitionKind JavaDoc limit_type,
560              boolean exclude_inherited)
561     {
562         // calls the InterfaceDef_impl::contents operation.
563
org.omg.CORBA.Contained JavaDoc[] result = super.contents(limit_type, exclude_inherited);
564
565         if(!exclude_inherited && (base_home() != null))
566         {
567             org.omg.CORBA.Contained JavaDoc[] result2 = base_home().contents(limit_type, exclude_inherited);
568             org.omg.CORBA.Contained JavaDoc[] result3 = result;
569             result = new org.omg.CORBA.Contained JavaDoc[result3.length + result2.length];
570             System.arraycopy(result2, 0, result, 0, result2.length);
571             System.arraycopy(result3, 0, result, result2.length, result3.length);
572         }
573  
574         return result;
575     }
576
577     /**
578      * IDL:omg.org/CORBA/Container/lookup_name:1.0
579      */

580     public org.omg.CORBA.Contained JavaDoc[]
581     lookup_name(String JavaDoc search_name,
582                 int levels_to_search,
583                 org.omg.CORBA.DefinitionKind JavaDoc limit_type,
584                 boolean exclude_inherited)
585     {
586         // calls the InterfaceDef_impl::contents operation.
587
org.omg.CORBA.Contained JavaDoc[] result =
588             super.lookup_name(search_name, levels_to_search,
589                               limit_type, exclude_inherited);
590
591         if(!exclude_inherited)
592         {
593             // TODO
594
}
595  
596         return result;
597     }
598
599     // ==================================================================
600
//
601
// For CORBA::ExtInterfaceDef interface.
602
//
603
// ==================================================================
604

605     // ==================================================================
606
//
607
// For CORBA::ComponentIR::HomeDef interface.
608
//
609
// ==================================================================
610

611     /**
612      * IDL:omg.org/CORBA/ComponentIR/HomeDef/base_home:1.0
613      */

614     public org.omg.CORBA.ComponentIR.HomeDef
615     base_home()
616     {
617         // delegate to the HomeDef reference.
618
return base_home_.asHomeDef();
619     }
620
621     /**
622      * IDL:omg.org/CORBA/ComponentIR/HomeDef/base_home:1.0
623      */

624     public void
625     base_home(org.omg.CORBA.ComponentIR.HomeDef val)
626     {
627         if(val == null)
628             base_home_.setDependency(null);
629         else
630         {
631             // try to cast val to a local object
632
// and delegate to the HomeDef reference.
633
base_home_.setDependency(castToLocal(val));
634         }
635     }
636
637     /**
638      * IDL:omg.org/CORBA/ComponentIR/HomeDef/managed_component:1.0
639      */

640     public org.omg.CORBA.ComponentIR.ComponentDef
641     managed_component()
642     {
643         // delegate to the ComponentDef reference.
644
return managed_component_.asComponentDef();
645     }
646
647     /**
648      * IDL:omg.org/CORBA/ComponentIR/HomeDef/managed_component:1.0
649      */

650     public void
651     managed_component(org.omg.CORBA.ComponentIR.ComponentDef val)
652     {
653         // try to cast val to a local object
654
// and delegate to the ComponentDef reference.
655
managed_component_.setDependency(castToLocal(val));
656     }
657
658     /**
659      * IDL:omg.org/CORBA/ComponentIR/HomeDef/primary_key:1.0
660      */

661     public org.omg.CORBA.ValueDef JavaDoc
662     primary_key()
663     {
664         // delegate to the ValueDef reference.
665
return primary_key_.asValueDef();
666     }
667
668     /**
669      * IDL:omg.org/CORBA/ComponentIR/HomeDef/primary_key:1.0
670      */

671     public void
672     primary_key(org.omg.CORBA.ValueDef JavaDoc val)
673     {
674         // TODO: check CCM specification!
675
if (val == null)
676             primary_key_.setDependency(null);
677         else
678         {
679             // try to cast val to a local object
680
// and delegate to the ValueDef reference.
681
primary_key_.setDependency( castToLocal(val) );
682         }
683     }
684
685     /**
686      * IDL:omg.org/CORBA/ComponentIR/ComponentDef/supported_interfaces:1.0
687      */

688     public org.omg.CORBA.InterfaceDef JavaDoc[]
689     supported_interfaces()
690     {
691         return InterfaceDef_ref.computeInterfaceDefSeq(supported_interfaces_);
692     }
693
694     /**
695      * IDL:omg.org/CORBA/ComponentIR/ComponentDef/supported_interfaces:1.0
696      */

697     public void
698     supported_interfaces(org.omg.CORBA.InterfaceDef JavaDoc[] val)
699     {
700         InterfaceDef_impl[] itfs = new InterfaceDef_impl[val.length];
701         for (int i=0; i<val.length; i++)
702             itfs[i] = castToLocal(val[i]);
703
704         // TODO: check inheritance
705

706         InterfaceDef_ref[] refs = new InterfaceDef_ref[val.length];
707         for (int i=0; i<val.length; i++)
708             refs[i] = new InterfaceDef_ref( this, itfs[i] );
709
710         // cut the previous dependency to base interfaces.
711
InterfaceDef_ref.cutDependencies(supported_interfaces_);
712
713         supported_interfaces_ = refs;
714     }
715
716     /**
717      * IDL:omg.org/CORBA/HomeDef/is_basic:1.0
718      */

719 /**
720  * not in the spec
721  *
722     public boolean
723     is_basic()
724     {
725         // TODO: implement
726         return false;
727     }
728  */

729
730
731     /**
732      * IDL:omg.org/CORBA/ComponentIR/HomeDef/create_factory:1.0
733      */

734     public org.omg.CORBA.ComponentIR.FactoryDef
735     create_factory(String JavaDoc id,
736                    String JavaDoc name,
737                    String JavaDoc version,
738                    org.omg.CORBA.ParameterDescription JavaDoc[] params,
739                    org.omg.CORBA.ExceptionDef JavaDoc[] exceptions)
740     {
741         FactoryDef_impl f = new FactoryDef_impl(getIFR(), this);
742         try
743         {
744             addContained(f, id, name, version);
745             f.params(params);
746             f.exceptions(exceptions);
747         }
748         catch(org.omg.CORBA.SystemException JavaDoc exc)
749         {
750             f.destroy();
751             throw exc;
752         }
753
754         f.whenCreated();
755         return f.asFactoryDef();
756     }
757
758     /**
759      * IDL:omg.org/CORBA/ComponentIR/HomeDef/create_finder:1.0
760      */

761     public org.omg.CORBA.ComponentIR.FinderDef
762     create_finder(String JavaDoc id,
763                   String JavaDoc name,
764                   String JavaDoc version,
765                   org.omg.CORBA.ParameterDescription JavaDoc[] params,
766                   org.omg.CORBA.ExceptionDef JavaDoc[] exceptions)
767     {
768         FinderDef_impl f = new FinderDef_impl(getIFR(), this);
769
770         try
771         {
772             addContained(f, id, name, version);
773             f.params(params);
774             f.exceptions(exceptions);
775         }
776         catch(org.omg.CORBA.SystemException JavaDoc exc)
777         {
778             f.destroy();
779             throw exc;
780         }
781
782         f.whenCreated();
783         return f.asFinderDef();
784     }
785
786     // ==================================================================
787
//
788
// For IDL2 mapping.
789
//
790
// ==================================================================
791

792     /**
793      * TODO
794      */

795     protected void
796     whenCreated()
797     {
798         // do nothing if mappings are not enabled.
799
if (!getIFR().getRepository().enable_mappings_)
800             return ;
801
802         // else create the mapping according to the CCM spec
803

804         //
805
// IDL2 mapping
806
//
807
//
808
// creation of the explicit interface
809
//
810
String JavaDoc cont_base_id = getBaseContainerID();
811         String JavaDoc name = name() + "Explicit";
812         String JavaDoc version = version();
813         String JavaDoc id = cont_base_id + name + ':' + version;
814         org.omg.CORBA.InterfaceDef JavaDoc[] supported = supported_interfaces();
815         org.omg.CORBA.InterfaceDef JavaDoc[] bases = new org.omg.CORBA.InterfaceDef JavaDoc[1+supported.length];
816         //
817
// add inheritance for supported interfaces
818
//
819
for (int i=0;i<supported.length;i++)
820             bases[1+i] = supported[i];
821
822         //
823
// add inheritance for ::Components::CCMHome or the base home explicit interface
824
//
825
if (base_home_.getImpl()==null)
826         {
827             bases[0] = org.omg.CORBA.InterfaceDefHelper.narrow(
828                 getIFR().getRepository().lookup("::Components::CCMHome"));
829         }
830         else
831         {
832             bases[0] = base_home_.getImpl().base_interfaces_[0].asInterfaceDef();
833         }
834
835         container_.mapping_started_ = true;
836         explicit_itf_ = container_.create_ext_interface(id, name, version, bases);
837         container_.mapping_started_ = false;
838
839         //
840
// creation of the implicit interface
841
//
842
name = name() + "Implicit";
843         String JavaDoc implicit_base_id = cont_base_id + name;
844         id = implicit_base_id + ':' + version;
845         //
846
// add inheritance for ::Components::KeylessCCMHome or null
847
//
848
if (primary_key_.getImpl()==null)
849         {
850             bases = new org.omg.CORBA.InterfaceDef JavaDoc[1];
851             bases[0] = org.omg.CORBA.InterfaceDefHelper.narrow(
852                 getIFR().getRepository().lookup("::Components::KeylessCCMHome"));
853         }
854         else
855         {
856             bases = new org.omg.CORBA.InterfaceDef JavaDoc[0];
857         }
858
859         container_.mapping_started_ = true;
860         implicit_itf_ = container_.create_ext_interface(id, name, version, bases);
861         container_.mapping_started_ = false;
862
863         if (primary_key_.getImpl()==null)
864         {
865             //
866
// <component_type> create()
867
// raises(::Components::CreateFailure);
868
//
869
name = "create";
870             version = implicit_itf_.version();
871             id = implicit_base_id + '/' + name + ':' + version;
872             org.omg.CORBA.ExceptionDef JavaDoc[] excs = new org.omg.CORBA.ExceptionDef JavaDoc[1];
873             excs[0] = org.omg.CORBA.ExceptionDefHelper.narrow(
874                 getIFR().getRepository().lookup("::Components::CreateFailure"));
875             implicit_itf_.create_operation(id, name, version,
876                                       managed_component_.asComponentDef(),
877                                       org.omg.CORBA.OperationMode.OP_NORMAL,
878                                       new org.omg.CORBA.ParameterDescription JavaDoc[0],
879                                       excs,
880                                       new java.lang.String JavaDoc[0]);
881         }
882         else
883         {
884             //
885
// <component_type> create(in <key_type> key)
886
// raises(::Components::DuplicateKeyValue,
887
// ::Components::InvalidKey,
888
// ::Components::CreateFailure);
889
//
890
name = "create";
891             version = implicit_itf_.version();
892             id = implicit_base_id + '/' + name + ':' + version;
893             org.omg.CORBA.IDLType JavaDoc key = primary_key_.asValueDef();
894             org.omg.CORBA.IDLType JavaDoc component = managed_component_.asComponentDef();
895             org.omg.CORBA.ParameterDescription JavaDoc[] params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
896             params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
897             params[0].name = "key";
898             params[0].type_def = key;
899             params[0].type = params[0].type_def.type();
900             params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
901             org.omg.CORBA.ExceptionDef JavaDoc[] excs = new org.omg.CORBA.ExceptionDef JavaDoc[3];
902             excs[0] = org.omg.CORBA.ExceptionDefHelper.narrow(
903                 getIFR().getRepository().lookup("::Components::DuplicateKeyValue"));
904             excs[1] = org.omg.CORBA.ExceptionDefHelper.narrow(
905                 getIFR().getRepository().lookup("::Components::InvalidKey"));
906             excs[2] = org.omg.CORBA.ExceptionDefHelper.narrow(
907                 getIFR().getRepository().lookup("::Components::CreateFailure"));
908
909             implicit_itf_.create_operation(id, name, version,
910                                       component,
911                                       org.omg.CORBA.OperationMode.OP_NORMAL,
912                                       params,
913                                       excs,
914                                       new java.lang.String JavaDoc[0]);
915
916             //
917
// <component_type> find_by_primary_key(in <key_type> key)
918
// raises(::Components::UnknownKeyValue,
919
// ::Components::InvalidKey,
920
// ::Components::FinderFailure);
921
//
922
name = "find_by_primary_key";
923             id = implicit_base_id + '/' + name + ':' + version;
924             params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
925             params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
926             params[0].name = "key";
927             params[0].type_def = key;
928             params[0].type = params[0].type_def.type();
929             params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
930             excs = new org.omg.CORBA.ExceptionDef JavaDoc[3];
931             excs[0] = org.omg.CORBA.ExceptionDefHelper.narrow(
932                 getIFR().getRepository().lookup("::Components::UnknownKeyValue"));
933             excs[1] = org.omg.CORBA.ExceptionDefHelper.narrow(
934                 getIFR().getRepository().lookup("::Components::InvalidKey"));
935             excs[2] = org.omg.CORBA.ExceptionDefHelper.narrow(
936                 getIFR().getRepository().lookup("::Components::FinderFailure"));
937
938             implicit_itf_.create_operation(id, name, version,
939                                       component,
940                                       org.omg.CORBA.OperationMode.OP_NORMAL,
941                                       params,
942                                       excs,
943                                       new java.lang.String JavaDoc[0]);
944
945             //
946
// void remove(in <key_type> key)
947
// raises(::Components::UnknownKeyValue,
948
// ::Components::InvalidKey,
949
// ::Components::RemoveFailure);
950
//
951
name = "remove";
952             id = implicit_base_id + '/' + name + ':' + version;
953             params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
954             params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
955             params[0].name = "key";
956             params[0].type_def = key;
957             params[0].type = params[0].type_def.type();
958             params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
959             excs = new org.omg.CORBA.ExceptionDef JavaDoc[3];
960             excs[0] = org.omg.CORBA.ExceptionDefHelper.narrow(
961                 getIFR().getRepository().lookup("::Components::UnknownKeyValue"));
962             excs[1] = org.omg.CORBA.ExceptionDefHelper.narrow(
963                 getIFR().getRepository().lookup("::Components::InvalidKey"));
964             excs[2] = org.omg.CORBA.ExceptionDefHelper.narrow(
965                 getIFR().getRepository().lookup("::Components::RemoveFailure"));
966
967             implicit_itf_.create_operation(id, name, version,
968                                       getIFR().getRepository().get_primitive(
969                                          org.omg.CORBA.PrimitiveKind.pk_void),
970                                       org.omg.CORBA.OperationMode.OP_NORMAL,
971                                       params,
972                                       excs,
973                                       new java.lang.String JavaDoc[0]);
974
975             //
976
// <key_type> get_primary_key(in <component_type> comp);
977
//
978
name = "get_primary_key";
979             id = implicit_base_id + '/' + name + ':' + version;
980             params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
981             params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
982             params[0].name = "comp";
983             params[0].type_def = component;
984             params[0].type = params[0].type_def.type();
985             params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
986
987             implicit_itf_.create_operation(id, name, version,
988                                       key,
989                                       org.omg.CORBA.OperationMode.OP_NORMAL,
990                                       params,
991                                       new org.omg.CORBA.ExceptionDef JavaDoc[0],
992                                       new java.lang.String JavaDoc[0]);
993         }
994
995         //
996
// Set explicit and implicit as base interfaces
997
//
998
bases = new org.omg.CORBA.InterfaceDef JavaDoc[2];
999         bases[0] = explicit_itf_;
1000        bases[1] = implicit_itf_;
1001        base_interfaces(bases);
1002
1003        // REQUIRED TO ADD IT ALSO IN TABLE OF MAPPED ELEMENTS
1004
container_.mapping_started_ = true;
1005        getIFR().getRepository().addRID(id(), this);
1006        container_.mapping_started_ = false;
1007
1008        //
1009
// CIDL mapping
1010
//
1011
// Home Explicit Executor Interface
1012
//
1013
// local interface CCM_<home_name>Explicit :
1014
// ( ::Components::HomeExecutorBase | CCM_<base_home_name>Explicit )
1015
// [ <supported_interfaces> ]
1016
// {
1017
// <attributes>
1018
// <operations>
1019
// <finders>
1020
// <factories>
1021
// };
1022
//
1023
cont_base_id = getBaseContainerID();
1024        name = "CCM_"+name()+"Explicit";
1025        version = version();
1026        id = cont_base_id + name + ':' + version;
1027        bases = new org.omg.CORBA.InterfaceDef JavaDoc[supported_interfaces_.length+1];
1028        if (base_home_.getImpl()==null)
1029        {
1030            bases[0] = org.omg.CORBA.InterfaceDefHelper.narrow(
1031                getIFR().getRepository().lookup("::Components::HomeExecutorBase"));
1032        }
1033        else
1034        {
1035            String JavaDoc base_cont_base_id = base_home_.getImpl().getBaseContainerID();
1036            String JavaDoc base_home_exe_id = base_cont_base_id + "CCM_" +
1037                                      base_home_.getImpl().name() + "Explicit:" +
1038                                      base_home_.getImpl().version();
1039
1040            bases[0] = org.omg.CORBA.InterfaceDefHelper.narrow(
1041                getIFR().getRepository().lookup_mapped_id(base_home_exe_id));
1042        }
1043
1044        for (int i=0;i<supported_interfaces_.length;i++)
1045        {
1046            bases[1+i] = supported_interfaces_[i].asInterfaceDef();
1047        }
1048
1049        container_.mapping_started_ = true;
1050        ccm_explicit_executor_itf_ =
1051            container_.create_ext_local_interface(id, name, version, bases);
1052        container_.mapping_started_ = false;
1053
1054        //
1055
// Home Implicit Executor Interface
1056
//
1057
// local interface CCM_<home_name>Implicit
1058
// {
1059
// };
1060
//
1061
name = "CCM_"+name()+"Implicit";
1062        id = cont_base_id + name + ':' + version;
1063        container_.mapping_started_ = true;
1064        ccm_implicit_executor_itf_ =
1065            container_.create_ext_local_interface(id, name, version,
1066                                                  new org.omg.CORBA.InterfaceDef JavaDoc[0]);
1067        container_.mapping_started_ = false;
1068        String JavaDoc implicit_exe_base_id = cont_base_id + name;
1069
1070        if (primary_key_.getImpl()==null)
1071        {
1072            //
1073
// Home Implicit Executor Interface without key
1074
//
1075
// ::Components::EnterpriseComponent create()
1076
// raises(::Components::CCMException);
1077
//
1078
name = "create";
1079            version = ccm_implicit_executor_itf_.version();
1080            id = implicit_exe_base_id + '/' + name + ':' + version;
1081            org.omg.CORBA.ExceptionDef JavaDoc[] excs = new org.omg.CORBA.ExceptionDef JavaDoc[1];
1082            excs[0] = org.omg.CORBA.ExceptionDefHelper.narrow(
1083                getIFR().getRepository().lookup("::Components::CCMException"));
1084            org.omg.CORBA.InterfaceDef JavaDoc enterprise_comp = org.omg.CORBA.InterfaceDefHelper.narrow(
1085                getIFR().getRepository().lookup("::Components::EnterpriseComponent"));
1086
1087            ccm_implicit_executor_itf_.create_operation(id, name, version,
1088                                          enterprise_comp,
1089                                          org.omg.CORBA.OperationMode.OP_NORMAL,
1090                                          new org.omg.CORBA.ParameterDescription JavaDoc[0],
1091                                          excs,
1092                                          new java.lang.String JavaDoc[0]);
1093        }
1094        else
1095        {
1096            org.omg.CORBA.ExceptionDef JavaDoc ccm_exception = org.omg.CORBA.ExceptionDefHelper.narrow(
1097                getIFR().getRepository().lookup("::Components::CCMException"));
1098            org.omg.CORBA.InterfaceDef JavaDoc enterprise_comp = org.omg.CORBA.InterfaceDefHelper.narrow(
1099                getIFR().getRepository().lookup("::Components::EnterpriseComponent"));
1100            org.omg.CORBA.IDLType JavaDoc key = primary_key_.asValueDef();
1101
1102            //
1103
// Home Implicit Executor Interface with key
1104
//
1105
// ::Components::EnterpriseComponent create(in <key_type> key)
1106
// raises(::Components::CCMException);
1107
//
1108
name = "create";
1109            version = ccm_implicit_executor_itf_.version();
1110            id = implicit_exe_base_id + '/' + name + ':' + version;
1111            org.omg.CORBA.ParameterDescription JavaDoc[] params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
1112            params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
1113            params[0].name = "key";
1114            params[0].type_def = key;
1115            params[0].type = params[0].type_def.type();
1116            params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
1117            org.omg.CORBA.ExceptionDef JavaDoc[] excs = new org.omg.CORBA.ExceptionDef JavaDoc[1];
1118            excs[0] = ccm_exception;
1119
1120            ccm_implicit_executor_itf_.create_operation(id, name, version,
1121                                          enterprise_comp,
1122                                          org.omg.CORBA.OperationMode.OP_NORMAL,
1123                                          params,
1124                                          excs,
1125                                          new java.lang.String JavaDoc[0]);
1126
1127            //
1128
// ::Components::EnterpriseComponent find_by_primary_key(in <key_type> key)
1129
// raises(::Components::CCMException);
1130
//
1131
name = "find_by_primary_key";
1132            id = implicit_exe_base_id + '/' + name + ':' + version;
1133            params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
1134            params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
1135            params[0].name = "key";
1136            params[0].type_def = key;
1137            params[0].type = params[0].type_def.type();
1138            params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
1139            excs = new org.omg.CORBA.ExceptionDef JavaDoc[1];
1140            excs[0] = ccm_exception;
1141
1142            ccm_implicit_executor_itf_.create_operation(id, name, version,
1143                                          enterprise_comp,
1144                                          org.omg.CORBA.OperationMode.OP_NORMAL,
1145                                          params,
1146                                          excs,
1147                                          new java.lang.String JavaDoc[0]);
1148
1149            //
1150
// void remove(in <key_type> key)
1151
// raises(::Components::CCMException);
1152
//
1153
name = "remove";
1154            id = implicit_exe_base_id + '/' + name + ':' + version;
1155            params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
1156            params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
1157            params[0].name = "key";
1158            params[0].type_def = key;
1159            params[0].type = params[0].type_def.type();
1160            params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
1161            excs = new org.omg.CORBA.ExceptionDef JavaDoc[1];
1162            excs[0] = ccm_exception;
1163
1164            ccm_implicit_executor_itf_.create_operation(id, name, version,
1165                                          getIFR().getRepository().get_primitive(
1166                                              org.omg.CORBA.PrimitiveKind.pk_void),
1167                                          org.omg.CORBA.OperationMode.OP_NORMAL,
1168                                          params,
1169                                          excs,
1170                                          new java.lang.String JavaDoc[0]);
1171        }
1172
1173        //
1174
// Home Main Executor Interface
1175
//
1176
// local interface CCM_<home_name> : CCM_<home_name>Explicit,
1177
// CCM_<home_name>Implicit
1178
// {
1179
// };
1180
//
1181
name = "CCM_" + name();
1182        id = cont_base_id + name + ':' + version;
1183        bases = new org.omg.CORBA.InterfaceDef JavaDoc[2];
1184        bases[0] = ccm_explicit_executor_itf_;
1185        bases[1] = ccm_implicit_executor_itf_;
1186
1187        container_.mapping_started_ = true;
1188        ccm_executor_itf_ = container_.create_ext_local_interface(id, name, version, bases);
1189        container_.mapping_started_ = false;
1190    }
1191}
1192
Popular Tags