1 26 27 package org.objectweb.openccm.Deployment; 28 29 39 40 public class ComponentServerBase 41 { 42 48 51 protected org.objectweb.ccm.util.Vector containers_; 52 53 56 protected org.omg.Components.ConfigValue[] configuration_; 57 58 62 65 68 protected org.objectweb.openccm.Deployment.listener.ComponentServerListener listener_; 69 70 71 77 82 public 83 ComponentServerBase( ) 85 { 86 containers_ = new org.objectweb.ccm.util.Vector(); 89 configuration_ = new org.omg.Components.ConfigValue[0]; 90 listener_ = null; 91 92 org.objectweb.openccm.Deployment.listener.TheComponentServerConfigurator.get_instance().configure_component_server(new ComponentServerLocalImpl(this)); 93 } 94 95 100 public ComponentServerBase( org.omg.Components.ConfigValue[] config){ 101 containers_ = new org.objectweb.ccm.util.Vector(); 102 this.listener_ = null; 103 this.configuration_=config; 104 org.objectweb.openccm.Deployment.listener.TheComponentServerConfigurator.get_instance().configure_component_server(new ComponentServerLocalImpl(this)); 105 106 } 107 113 123 public void 124 add_listener (org.objectweb.openccm.Deployment.listener.ComponentServerListener listener) 125 { 126 if (listener_ == null) 127 listener_ = listener; 128 else 129 listener_.set_delegate(listener); 130 } 131 137 142 144 145 151 public void 152 add_container (org.omg.Components.Deployment.Container cont_ref) 153 { 154 containers_.add(cont_ref); 155 listener_.on_add (cont_ref); 156 } 157 158 163 public void 164 unregister_container(org.omg.Components.Deployment.Container ref) 165 throws org.omg.Components.RemoveFailure 166 { 167 listener_.on_remove (ref); 168 169 for(java.util.Iterator it=containers_.iterator();it.hasNext(); ) 170 if(ref._is_equivalent(((org.omg.Components.Deployment.Container)it.next()))) 171 { 172 it.remove(); 173 return ; 174 } 175 176 throw new org.omg.Components.RemoveFailure(); 178 } 179 180 186 193 public org.omg.Components.ConfigValue[] 194 configuration() 195 { 196 return configuration_; 197 } 198 199 209 public void 210 configuration(org.omg.Components.ConfigValue[] config) 211 { 212 configuration_ = config; 213 } 214 215 222 public org.omg.Components.Deployment.ServerActivator 223 get_server_activator() 224 { 225 throw new org.omg.CORBA.NO_IMPLEMENT (); 229 } 230 231 238 public org.omg.Components.Deployment.Container 239 create_container(ComponentServerImpl csi,org.omg.Components.ConfigValue[] config) 240 throws org.omg.Components.CreateFailure, 241 org.omg.Components.Deployment.InvalidConfiguration 242 { 243 ContainerImpl cont = new ContainerImpl(config,csi); 245 246 org.omg.CORBA.Object ref = cont._this_object(org.objectweb.openccm.corba.TheORB.getORB()); 248 org.omg.Components.Deployment.Container cont_ref = 249 org.omg.Components.Deployment.ContainerHelper.narrow(ref); 250 cont.the_container_ref(cont_ref); 251 listener_.on_create (cont_ref); 252 253 return cont_ref; 254 } 255 256 263 public void 264 remove_container(org.omg.Components.Deployment.Container ref) 265 throws org.omg.Components.RemoveFailure 266 { 267 277 278 for(int i=0; i<containers_.size(); i++) 280 { 281 org.omg.Components.Deployment.Container c = 282 (org.omg.Components.Deployment.Container)containers_.get(i); 283 284 if(ref._is_equivalent(c)) 286 { 287 ref.remove(); 288 return; 289 } 290 } 291 292 throw new org.omg.Components.RemoveFailure(); 294 } 295 296 303 public org.omg.Components.Deployment.Container[] 304 get_containers() 305 { 306 org.omg.Components.Deployment.Container[] result = 307 new org.omg.Components.Deployment.Container[containers_.size()]; 308 309 for (int i=0;i<result.length;i++) 310 result[i] = (org.omg.Components.Deployment.Container)containers_.get(i); 311 312 return result; 313 } 314 315 322 public void 323 remove() 324 throws org.omg.Components.RemoveFailure 325 { 326 329 org.omg.Components.Deployment.Container[] containers = get_containers(); 331 for(int i=0; i<containers.length; i++) 332 { 333 containers[i].remove(); 334 } 335 listener_.on_destroy(); 336 337 349 } 350 } 351 352 | Popular Tags |