KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > kilim > model > RtComponent


1 /**
2  * Copyright (C) 2002 Kelua SA
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  */

18
19 package org.objectweb.kilim.model;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24 import java.util.Stack JavaDoc;
25 import java.util.HashMap JavaDoc;
26
27 import org.objectweb.kilim.KilimConfiguration;
28 import org.objectweb.kilim.KilimException;
29 import org.objectweb.kilim.description.Instance;
30 import org.objectweb.kilim.description.KILIM;
31 import org.objectweb.kilim.description.NamedElement;
32 import org.objectweb.kilim.description.TemplateDescription;
33 import org.objectweb.kilim.description.Trigger;
34 import org.objectweb.kilim.model.instanciation.InstanciationMger;
35
36 /**
37  * @author horn
38  */

39 public class RtComponent extends RtComponentElement implements Component, RuntimeSource {
40
41     private boolean isInitialized;
42     private boolean isForkedComponent;
43     private ComponentFactory factory;
44     private TemplateDescription template;
45     private TemplateDescription containingTemplate;
46     private InstanciationMger instanciationMger;
47     
48     private List JavaDoc subComponents;
49     private List JavaDoc interfaces;
50     private List JavaDoc slots;
51     private List JavaDoc plugTos;
52     private List JavaDoc nAryListeners;
53     
54     //private List controllers;
55
private HashMap JavaDoc controllers;
56
57     /**
58      * The public constructor for RtComponents.
59      * @param aInstance : the template element corresponding to an instance
60      * @param aComponent : the containing component
61      * @param aFactory : the factoy used to create the component.
62      * @throws KilimException : generated when aInstance is null.
63      */

64     public RtComponent(Instance aInstance, Component aComponent, ComponentFactory aFactory) throws KilimException {
65         super(aInstance, aComponent);
66         if (aInstance == null) {
67             throw new KilimException("attempt to construct a component without instance description ");
68         }
69         if (aComponent != null) {
70             aComponent.addSubComponent(this);
71         }
72         factory = aFactory;
73         nbComponent++;
74     }
75     
76     /**
77      * @see org.objectweb.kilim.model.ContainerElement#isComponent()
78      */

79     public boolean isComponent() {
80         return true;
81     }
82     
83     /**
84      * @see org.objectweb.kilim.model.ContainerElement#isSlot()
85      */

86     public boolean isSlot() {
87         return false;
88     }
89     
90     /**
91      * @see org.objectweb.kilim.model.ComponentElement#getLocalName()
92      */

93     public String JavaDoc getLocalName() {
94         NamedElement elem = (NamedElement) getElementDescription();
95         return elem.getLocalName();
96     }
97     
98     /**
99      * @see org.objectweb.kilim.model.RuntimeSource#checkValue()
100      */

101     public boolean hasValue() throws KilimException {
102         return true;
103     }
104     
105     /**
106      * @see org.objectweb.kilim.model.RuntimeSource#checkValue(Stack)
107      */

108     public boolean checkValue(Stack JavaDoc exclude) throws KilimException {
109         return true;
110     }
111
112     /**
113      * adds a new interface in the component.
114      * @param aElement : the interface
115      * @throws KilimException : generated if aElement is null or if the local name of aElement clashes with the local name of another interface.
116      */

117     public void addInterface(ComponentInterface aElement) throws KilimException {
118         if (aElement == null) {
119             throw new KilimException("attempt to add a null interface to component " + getQualifiedName());
120         }
121         
122         if (!(aElement instanceof RtComponentInterface)) {
123             throw new KilimException("attempt to add a non Kilim interface to component " + getQualifiedName());
124         }
125                 
126         String JavaDoc lName = aElement.getLocalName();
127         
128         if (interfaces == null) {
129             interfaces = new ArrayList JavaDoc();
130         }
131         
132         if (containsElement(interfaces, lName)) {
133             String JavaDoc interfSort = null;
134             if (aElement.isProperty()) {
135                 interfSort = "property";
136             } else if (aElement.isCollectionPort()) {
137                 interfSort = "collection interface ";
138             } else if (aElement.isSingleValuePort()) {
139                 interfSort = "interface";
140             } else {
141                 interfSort = "provider [" + aElement.getClass() + "]";
142             }
143             throw new KilimException("name clash when adding the " + interfSort + " " + lName + " in component " + getQualifiedName());
144         }
145         
146         interfaces.add(aElement);
147     }
148     
149     /**
150      * removes the interface from a component.
151      * @param aElement : the interface to be removed
152      * @throws KilimException : generated if aElement is null, if the component has no interface or if the interface is not defined in the component
153      */

154     public void removeInterface(ComponentInterface aElement) throws KilimException {
155         if (aElement == null) {
156             throw new KilimException("attempt to remove a null interface from component " + getQualifiedName());
157         }
158         
159         if (interfaces == null) {
160             throw new KilimException("no interface in current component");
161         }
162         
163         Object JavaDoc previous = removeElement(interfaces, aElement.getLocalName());
164         if (previous == null) {
165             throw new KilimException("interface " + aElement.getLocalName() + " unknown in current component " + getQualifiedName());
166         }
167     }
168     
169     /**
170      * returns an interface defined in the component
171      * @param aName : the local name of the interface.
172      * @return ComponentInterface
173      */

174     public ComponentInterface getInterface(String JavaDoc aName) {
175         if (interfaces == null) {
176             return null;
177         }
178         return (ComponentInterface) getElement(interfaces, aName);
179     }
180     
181     /**
182      * returns as an iterator the interfaces defined in the component.
183      * @return Iterator
184      */

185     public Iterator JavaDoc getInterfaces() {
186         if (interfaces == null) {
187             return KILIM.EMPTY_ITERATOR;
188         }
189         return interfaces.iterator();
190     }
191         
192     /**
193      * @see org.objectweb.kilim.model.ContainerElement#getFactory()
194      */

195     public Factory getFactory() {
196         return factory;
197     }
198     
199     /**
200      * @see org.objectweb.kilim.description.Instance#getTemplate()
201      */

202     public TemplateDescription getTemplate() {
203         Instance instance = ((Instance) getElementDescription());
204         if (instance == null) {
205             return null;
206         } else {
207             return instance.getTemplate();
208         }
209     }
210     
211     /**
212      * @see org.objectweb.kilim.description.Instance#setTemplate(Template)
213      */

214     public void setTemplate(TemplateDescription aTemplate) {
215         template = aTemplate;
216     }
217     
218     /**
219      * @see java.lang.Object#toString()
220      */

221     public String JavaDoc toString() {
222         return getQualifiedName();
223     }
224     
225     /**
226      * adds a component as a subcomponent of the current component.
227      * @param aElement : the subcomponent.
228      * @throws KilimException : generated if aElement is null or if it is already defined as a subcomponent in the component.
229      */

230     public void addSubComponent(Component aElement) throws KilimException {
231         if (aElement == null) {
232             throw new KilimException("attempt to add a null subcomponent to component " + getQualifiedName());
233         }
234                 
235         String JavaDoc lName = aElement.getLocalName();
236         
237         if (subComponents == null) {
238             subComponents = new ArrayList JavaDoc();
239         }
240         
241         if (containsElement(subComponents, lName)) {
242             throw new KilimException("name clash when adding the component " + lName + "in component " + getQualifiedName());
243         }
244         
245         subComponents.add(aElement);
246     }
247     
248     /**
249      * removes the subcomponent from the current component.
250      * @param aName : the name of the child component to be removed.
251      * @throws KilimException : generated if aName is null or is unknown (i.e. it is not a the name of a child component)
252      */

253     public void removeSubComponent(String JavaDoc aName) throws KilimException {
254         if (aName == null) {
255             throw new KilimException("attempt to remove a child component through a null name in component " + getQualifiedName());
256         }
257         
258         if (subComponents == null) {
259             throw new KilimException("attempt to remove a component from component " + getQualifiedName() + " without subcomponent ");
260         }
261         
262         Object JavaDoc previous = removeElement(subComponents, aName);
263         if (previous == null) {
264             throw new KilimException("attempt to remove unknown subcomponent " + aName + " from component " + getQualifiedName());
265         }
266     }
267     
268     /**
269      * removes a component from the current component.
270      * @param aElement : the component to be removed.
271      * @throws KilimException : generated if aElement is null, if the component does not contain any subcomponent,
272      * if aElement is not a subcomponent of the current component.
273      */

274     public void removeSubComponent(Component aElement) throws KilimException {
275         if (aElement == null) {
276             throw new KilimException("attempt to remove a null component in component " + getQualifiedName());
277         }
278         
279         if (subComponents == null) {
280             throw new KilimException("attempt to remove a component from component " + getQualifiedName() + " without subcomponent ");
281         }
282         
283         Object JavaDoc previous = removeElement(subComponents, aElement.getLocalName());
284         if (previous == null) {
285             throw new KilimException("attempt to remove unknown subcomponent " + aElement.getLocalName() + " from component " + getQualifiedName());
286         }
287     }
288     
289     /**
290      * returns a subcomponent from its local name This method is not recursive and only looks for direct sub component.
291      * @param aName : the local name of the subcomponent.
292      * @return Component
293      */

294     public Component getSubComponent(String JavaDoc aName) {
295         if (subComponents == null) {
296             return null;
297         }
298         return (Component) getElement(subComponents, aName);
299     }
300     
301     /**
302      * returns as an iterator the direct subcomponents (i.e. the sub component of the current component).
303      * @return Iterator
304      */

305     public Iterator JavaDoc getSubComponents() {
306         if (subComponents == null) {
307             return KILIM.EMPTY_ITERATOR;
308         }
309         return subComponents.iterator();
310     }
311     
312     /**
313      * adds a new slot to a component.
314      * @param aSlot : the slot to be added
315      * @throws KilimException : generated if aSlot is null.
316      */

317     public void addSlot(ComponentSlot aSlot) throws KilimException {
318         if (aSlot == null) {
319             throw new KilimException("attempt to add a null slot in component " + getQualifiedName());
320         }
321         if (slots == null) {
322             slots = new ArrayList JavaDoc();
323         }
324         slots.add(aSlot);
325     }
326
327     /**
328      * removes a slot from a component.
329      * @param aName : the name of the slot to be removed.
330      * @throws KilimException : generated if aName is null, if the component does not contain slots or
331      * if it does not contain a slot whose name is aName
332      */

333     public void removeSlot(String JavaDoc aName) throws KilimException {
334         if (aName == null) {
335             throw new KilimException("attempt to remove a slot through a null name in component " + getQualifiedName());
336         }
337         if (slots == null) {
338             throw new KilimException("attempt to remove a slot from component " + getQualifiedName() + " without slot");
339         }
340         
341         Object JavaDoc result = removeElement(slots, aName);
342         if (result == null) {
343             throw new KilimException("attempt to remove an unknown slot " + aName + " from component " + getQualifiedName());
344         }
345     }
346     
347     /**
348      * returns a slot from its local name.
349      * @param aName : the local name of the slot.
350      * @return Slot
351      * @throws KilimException : generated if aName is null, if the component does not contain slots or
352      * if it does not contain a slot whose name is aName
353      */

354     public ComponentSlot getSlot(String JavaDoc aName) throws KilimException {
355         if (aName == null) {
356             throw new KilimException("attempt to get a null slot in component " + getQualifiedName());
357         }
358         if (slots == null) {
359             throw new KilimException("attempt to get slot " + aName + " from a component " + getQualifiedName() + " without slot");
360         }
361
362         RtComponentSlot slot1 = (RtComponentSlot) getElement(slots, aName);
363         if (slot1 == null) {
364             throw new KilimException("attempt to get an unknown slot " + aName + " in a component " + getQualifiedName());
365         }
366         return slot1;
367     }
368     
369     /**
370      * returns as an iterator the slots declared in the component.
371      * @return Iterator
372      */

373     public Iterator JavaDoc getSlots() {
374         if (slots == null) {
375             return KILIM.EMPTY_ITERATOR;
376         }
377         return slots.iterator();
378     }
379
380     /**
381      * This method is used to register slots in which the component is plugged to. This method is thus invoked internally
382      * by the plug method.
383      * @param aSlot : the slot to be register.
384      * @throws KilimException : generated if aSlot is null or if the component is already registered as a components' plugTo..
385      */

386     public void addPlugTo(ComponentSlot aSlot) throws KilimException {
387         if (aSlot == null) {
388             throw new KilimException("attempt to add a null slot in the list of plugged slotTo of component " + getQualifiedName());
389         }
390         if (plugTos == null) {
391             plugTos = new ArrayList JavaDoc();
392         }
393         
394         if (plugTos.contains(aSlot)) {
395             throw new KilimException("attempt to add an already plugged component " + aSlot.getQualifiedName() + " in the list of plugged components of component " + getQualifiedName());
396         }
397         plugTos.add(aSlot);
398     }
399
400     /**
401      * This method is used to unregister slots in which the component is plugged to. This method is thus invoked internally
402      * by the unplug method.
403      * @param aSlot : the slot to be removed.
404      * @throws KilimException : generated if aSlot is null or if the component is not plugged in aSlot.
405      */

406     public void removePlugTo(ComponentSlot aSlot) throws KilimException {
407         if (aSlot == null) {
408             throw new KilimException("attempt to remove a null slotTo from component " + getQualifiedName());
409         }
410         if (plugTos == null) {
411             throw new KilimException("attempt to remove a slotTo " + aSlot.getQualifiedName() + " from an unplugged component " + getQualifiedName());
412         }
413         
414         boolean result = plugTos.remove(aSlot);
415         if (result == false) {
416             throw new KilimException("attempt to remove an unknown slotTo " + aSlot.getQualifiedName() + " from an component " + getQualifiedName());
417         }
418     }
419
420     /**
421      * @see org.objectweb.kilim.model.Component#getPlugTos()
422      */

423     public Iterator JavaDoc getPlugTos() {
424         if (plugTos == null) {
425             return KILIM.EMPTY_ITERATOR;
426         }
427         return plugTos.listIterator();
428     }
429     
430     /**
431      * plugs a component in a slot defined in the current component.
432      * @param aName : the local name of the slot.
433      * @param aComponent : the component to be plugged.
434      * @throws KilimException : generated if aName is null, if aName is not the local name of a slot defined in the component or if aComponent is null.
435      */

436     public void plug(String JavaDoc aName, Component aComponent) throws KilimException {
437         RtComponentSlot slt = (RtComponentSlot) getSlot(aName);
438         slt.plug(aComponent);
439     }
440     
441     /**
442      * unplugs a component from a slot defined in the current component.
443      * @param aName : the local name of the slot.
444      * @param aComponent : the component to be plugged.
445      * @throws KilimException : generated if aName is null, if aName is not the local name of a slot defined in the component or if aComponent is null.
446      */

447     public void unplug(String JavaDoc aName, Component aComponent) throws KilimException {
448         RtComponentSlot slt = (RtComponentSlot) getSlot(aName);
449         slt.unplug(aComponent);
450         ((RtComponent) aComponent).removePlugTo(slt);
451     }
452         
453     /**
454      * @see org.objectweb.kilim.model.RuntimeSource#getValue(RuntimeContext)
455      */

456     public Object JavaDoc getValue() {
457         return this;
458     }
459         
460     /**
461      * @see org.objectweb.kilim.model.RuntimeSource#setEventSource(Object)
462      */

463     public void setEventSourceValue(Object JavaDoc aValue) throws KilimException {
464         throw new KilimException("attempt to set an event source to a component " + getQualifiedName());
465     }
466     
467     /**
468      * @see org.objectweb.kilim.model.RuntimeSource#getEventSource()
469      */

470     public Object JavaDoc getEventSourceValue() throws KilimException {
471         throw new KilimException("attempt to get the event source of a component " + getQualifiedName());
472     }
473     
474     /**
475      * @see org.objectweb.kilim.model.RuntimeSource#isEventSource()
476      */

477     public boolean isEventSource() {
478         return false;
479     }
480         
481     /**
482      * @see org.objectweb.kilim.model.RuntimeSource#addInterfaceListener(MultipleValueInterface)
483      */

484     public void addInterfaceListener(RtCollectionPort aInterface) throws KilimException {
485         if (nAryListeners == null) {
486             nAryListeners = new ArrayList JavaDoc();
487         }
488         
489         nAryListeners.add(aInterface);
490     }
491     
492     /**
493      * @see org.objectweb.kilim.model.RuntimeSource#removeInterfaceListener(MultipleValueInterface)
494      */

495     public void removeInterfaceListener(RtCollectionPort aInterface) throws KilimException {
496         nAryListeners.remove(aInterface);
497     }
498     
499     /**
500      * returns as an interator the interface the interface listeners.
501      * @return Iterator
502      */

503     public Iterator JavaDoc getInterfaceListeners() {
504         if (nAryListeners == null) {
505             return KILIM.EMPTY_ITERATOR;
506         }
507         return nAryListeners.listIterator();
508     }
509     
510     /**
511      * creates a copy of the component as defined in the template. The method forks does not account for any operation
512      * performed at runtime (late binding, instanciation, ....).
513      * @return Component
514      * @throws KilimException : generated when invoked on a component having no factory (should not be a KilimException but an InternalException FHO !!!)
515      */

516     public Component fork() throws KilimException {
517         if (factory == null) {
518             throw new KilimException("attempt to fork a component " + getQualifiedName() + " with a null factory ");
519         }
520         
521         RtComponent pCompo = (RtComponent) getContainingComponent();
522         if (pCompo != null) {
523             Component compo = ((ComponentFactory) pCompo.getFactory()).fork(this);
524             return compo;
525         } else {
526             TemplateDescription tmp = getTemplate();
527             Component compo = ComponentFactory.newComponent(tmp);
528             if (compo instanceof RtComponent) {
529                 ((RtComponent) compo).isForkedComponent(true);
530             }
531             return compo;
532         }
533     }
534     
535     /**
536      * @see org.objectweb.kilim.model.Component#isInitialized()
537      */

538     public boolean isInitialized() {
539         return isInitialized;
540     }
541     
542     /**
543      * @see org.objectweb.kilim.model.Component#setInitialized(boolean)
544      */

545     public void setInitialized() {
546         isInitialized = true;
547     }
548     
549     private boolean isForkedComponent() {
550         return isForkedComponent;
551     }
552     
553     private void isForkedComponent(boolean iFE) {
554         isForkedComponent = iFE;
555     }
556     
557     /**
558      * @see org.objectweb.kilim.model.Component#getInstanciationMgerFromConfiguration()
559      */

560     public InstanciationMger getInstanciationMgerFromConfiguration() throws KilimException {
561         //lookup for the right instanciation manager.
562
instanciationMger = null;
563         
564         //look for a "per instance" manager.
565
instanciationMger = KilimConfiguration.getInstanciationStrategy().getPerInstanceMger(getQualifiedName());
566         
567         //look up of a "per template" manager, if no "per instance" manager.is defined for the current instance.
568
if (instanciationMger == null) {
569             TemplateDescription template1 = getTemplate();
570             TemplateDescription template2 = null;
571             do {
572                 template2 = template1.getSuperTemplate();
573                 if (template2 != null) {
574                     template1 = template2;
575                 }
576             } while (template2 != null);
577
578             instanciationMger = KilimConfiguration.getInstanciationStrategy().getPerTemplateMger(template1.getName());
579         }
580         
581         //use of the default manager, if no "per template" manager.is defined for the current instance template.
582
if (instanciationMger == null) {
583                 instanciationMger = KilimConfiguration.getInstanciationStrategy().getDefaultMger();
584         }
585         
586         return instanciationMger;
587     }
588
589     /**
590      * @see org.objectweb.kilim.model.Component#getInstanciationMger()
591      */

592     public InstanciationMger getInstanciationMger() {
593         return instanciationMger;
594     }
595     
596     /**
597      * @see org.objectweb.kilim.model.Component#setInstanciationMger(InstanciationMger)
598      */

599     public void setInstanciationMger(InstanciationMger aMger) throws KilimException {
600         if (aMger == null) {
601             throw new KilimException("attempt to install a null instanciation manager to component " + getQualifiedName());
602         }
603         instanciationMger = aMger;
604     }
605     
606     /**
607      * @see org.objectweb.kilim.model.Component#release()
608      */

609     public void release() throws KilimException {
610         // remove from parent
611
Component compo = getContainingComponent();
612         boolean isSubCompo = false;
613         if (compo != null) {
614             compo.removeSubComponent(this);
615             isSubCompo = true;
616         }
617         
618       ComponentFactory fct = (ComponentFactory) getFactory();
619       ComponentFactory nfct = (ComponentFactory) fct.getContainingFactory();
620       if (nfct != null) {
621         nfct.removeSubFactory(fct);
622         nfct.removeChildNamingContext(fct.getLocalName());
623         fct.setParentNamingContext(null);
624
625         if (isSubCompo) {
626             nfct.removeBoundName(getLocalName());
627         }
628       }
629
630         // unplug explicitly...
631
ArrayList JavaDoc list = null;
632         for (Iterator JavaDoc iter = getPlugTos(); iter.hasNext();) {
633             if (list == null) {
634                 list = new ArrayList JavaDoc();
635             }
636             list.add(iter.next());
637         }
638               
639         if (list != null) {
640             for (Iterator JavaDoc iter = list.iterator(); iter.hasNext();) {
641                 RtComponentSlot slt = (RtComponentSlot) iter.next();
642                 slt.unplug(this);
643             }
644         }
645     }
646     
647     /**
648      * This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component
649      * (most controllers are used as instantiation managers or communication managers) according to its specific semantics.
650      * Controllers are thus just stored in a table contained in the kilim component object. This method registers a new controller in the component.
651      * @param aName : the local name of the controller.
652      * @param aController : the controller.
653      * @throws KilimException : generated if aName or aController is null.
654      */

655     public void addController(String JavaDoc aName, Object JavaDoc aController) throws KilimException {
656         if (aName == null) {
657             throw new KilimException("attempt to add a controller with a null name in component " + getQualifiedName());
658         }
659         if (aController == null) {
660             throw new KilimException("attempt to add a null controller in component " + getQualifiedName());
661         }
662         if (controllers == null) {
663             controllers = new HashMap JavaDoc();
664         }
665             
666         controllers.put(aName, aController);
667     }
668     
669     /**
670      * This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component
671      * (most controllers are used as instantiation managers or communication managers) according to its specific semantics.
672      * Controllers are thus just stored in a table contained in the kilim component object. This method removes a previously registered controller.
673      * @param aName : the local name of the controller.
674      * @throws KilimException : generated if aName is null or if the controller is not defined in the component.
675      */

676     public void removeController(String JavaDoc aName) throws KilimException {
677         if (aName == null) {
678             throw new KilimException("attempt to remove a null controller in component " + getQualifiedName());
679         }
680         if (controllers == null) {
681             throw new KilimException("attempt to remove a controller from component " + getQualifiedName() + " without controller");
682         }
683         
684         Object JavaDoc result = controllers.remove(aName);
685         if (result == null) {
686             throw new KilimException("attempt to remove an unknown controller " + aName + " from component " + getQualifiedName());
687         }
688     }
689     
690     /**
691      * This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component
692      * (most controllers are used as instantiation managers or communication managers) according to its specific semantics.
693      * Controllers are thus just stored in a table contained in the kilim component object. This method returns the controller identified by its name.
694      * @param aName : the name of the controller
695      * @return Object
696      * @throws KilimException : generated if aName is null or if the controller is not defined in the component.
697      */

698     public Object JavaDoc getController(String JavaDoc aName) throws KilimException {
699         if (aName == null) {
700             throw new KilimException("attempt to get a controller through a null name in component " + getQualifiedName());
701         }
702         
703         if (controllers == null) {
704             throw new KilimException("attempt to get a controller " + aName + " from a component " + getQualifiedName() + " without controller");
705         }
706
707         Object JavaDoc ctrl = controllers.get(aName);
708         if (ctrl == null) {
709             throw new KilimException("attempt to get an unknown controller " + aName + " in a component " + getQualifiedName());
710         }
711         return ctrl;
712     }
713     
714     /**
715      * This method is an extension introduced to ease the mapping with the FRACTAL model : a controller is a technical object internally used by the component
716      * (most controllers are used as instantiation managers or communication managers) according to its specific semantics.
717      * Controllers are thus just stored in a table contained in the kilim component object. This method returns as an iterator the controllers defined in the component.
718      * @return Iterator
719      */

720     public Iterator JavaDoc getControllers() {
721         if (controllers == null) {
722             return KILIM.EMPTY_ITERATOR;
723         }
724         return controllers.values().iterator();
725     }
726 }
Popular Tags