1 27 package org.objectweb.openccm.Containers.MetaInformation; 28 29 import org.objectweb.ccm.util.Table; 30 import org.omg.CORBA.LocalObject ; 31 import org.omg.Components.InvalidName; 32 33 39 public class ComponentInstanceListImpl 40 extends LocalObject 41 implements ComponentInstanceList 42 { 43 44 private Table _components; 45 46 public ComponentInstanceListImpl() 47 { 48 _components = new Table(); 49 } 50 51 54 public ComponentInstance 55 get_component_instance(String name) 56 throws InvalidName 57 { 58 ComponentInstance result = (ComponentInstance) _components.get(name); 59 if(result == null) 60 throw new InvalidName(); 61 return result; 62 } 63 64 67 public ComponentInstance[] 68 get_named_component_instances(String [] names) 69 throws InvalidName 70 { 71 ComponentInstance[] result = new ComponentInstance[names.length]; 72 73 75 int i = 0; 76 for(i=0;i<names.length;i++) 77 { 78 result[i] = (ComponentInstance)_components.get(names[i]); 79 80 if(result[i] == null) 81 { 82 throw new InvalidName(); 83 } 84 } 85 86 return result; 87 } 88 89 92 public ComponentInstance[] 93 get_all_component_instances() 94 { 95 ComponentInstance[] result = new ComponentInstance[_components.size()]; 96 97 int idx = 0; 99 for(java.util.Enumeration elements = _components.elements(); elements.hasMoreElements(); ) 100 { 101 ComponentInstance info = (ComponentInstance)elements.nextElement(); 102 result[idx++] = info; 103 } 104 return result; 105 } 106 107 110 public void add_component_instance(ComponentInstance cpi) 111 { 112 String key = cpi.type_reference().name() + cpi.toString().substring(cpi.toString().lastIndexOf("@")); 113 114 _components.put(key,cpi); 115 116 } 117 118 121 public void remove_component_instance(String name) 122 throws InvalidName 123 { 124 Object result = _components.remove(name); 125 126 if (result == null) throw new InvalidName(); 127 } 128 } 129 | Popular Tags |