1 26 27 package org.objectweb.openccm.OpenCCM_DCI.cif; 28 29 37 public class DCIDeploymentSegImpl 38 extends org.objectweb.openccm 39 .OpenCCM_DCI.DCIManagerSessionComposition 40 .DCIDeploymentSeg 41 { 42 48 52 private class AssemblyManagerModelIterator 53 { 54 private org.objectweb.openccm.OpenCCM_DCI. 56 DCIManagerPackage.assembly_manager_modelsConnection [] 57 connect; 58 59 private int index; 61 62 67 public AssemblyManagerModelIterator() 68 { 69 rewind(); 70 } 71 72 76 public org.objectweb.openccm.OpenCCM_DCI.AssemblyManagerModel 77 next() 78 throws java.util.NoSuchElementException 79 { 80 if(index==connect.length) 81 throw new java.util.NoSuchElementException (); 82 index++; 83 return connect[index-1].objref; 84 } 85 86 90 public org.objectweb.openccm.OpenCCM_DCI.AssemblyManagerModel 91 current() 92 { 93 return connect[index-1].objref; 94 } 95 96 100 public boolean 101 hasNext() 102 { 103 return index<connect.length; 104 } 105 106 public void 107 remove() 108 { 109 } 111 112 116 public void 117 rewind() 118 { 119 index=0; 121 connect=DCI.get_connections_assembly_manager_models(); 123 } 124 125 129 public int 130 length() 131 { 132 return connect.length; 133 } 134 } 135 136 142 private String prefix="DCIDeploymentSeg >> "; 144 145 private AssemblyManagerModelIterator ammIterator; 147 148 private org.objectweb.openccm.OpenCCM_DCI.DCIManagerCCM DCI; 150 151 157 private org.objectweb.openccm.OpenCCM_DCI.AssemblyManagerModel 158 getAssemblyManagerModel(String assemblyUUID) 159 throws org.ist.coach.DCI.UnknownAssembly 160 { 161 for(ammIterator.rewind(); 162 ammIterator.hasNext(); ) 163 { 164 if(ammIterator.next().assemblyUUID().equals(assemblyUUID)) 165 { 166 return ammIterator.current(); 168 } 169 } 170 throw new org.ist.coach.DCI.UnknownAssembly(); 171 } 172 173 179 185 public void setupDCI() 186 { 187 DCI=(org.objectweb.openccm.OpenCCM_DCI.DCIManagerCCM)get_context(); 188 ammIterator=new AssemblyManagerModelIterator(); 189 } 190 191 197 public String 198 install_with_archive(byte[] archive) 199 throws org.omg.Components.Deployment.InstallationFailure, 200 org.ist.coach.DCI.AlreadyInstalled, 201 org.ist.coach.DCI.InvalidArchive 202 { 203 if(DCI.get_connection_assembly_factory()==null) 205 { 206 throw new org.omg.Components.Deployment.InstallationFailure(); 207 } 208 209 try 210 { 211 org.objectweb.openccm.OpenCCM_DCI.AssemblyManagerModel amm= 213 DCI.get_connection_assembly_manager_model_home() 214 .create_assembly_model_archive(archive); 215 amm.connect_assembly_factory(DCI.get_connection_assembly_factory()); 217 amm.connect_assembly_manager_model_registration 220 (DCI.provide_assembly_manager_model_registration()); 221 amm.configuration_complete(); 223 return amm.assemblyUUID(); 225 } 226 catch(Exception exc) 227 { 228 exc.printStackTrace(System.err); 230 throw new org.omg.Components.Deployment.InstallationFailure(); 231 } 232 } 233 234 240 public String 241 install_with_descriptor(String descriptor) 242 throws org.omg.Components.Deployment.InstallationFailure, 243 org.ist.coach.DCI.AlreadyInstalled 244 { 245 if(DCI.get_connection_assembly_factory()==null) 247 { 248 throw new org.omg.Components.Deployment.InstallationFailure(); 249 } 250 251 try 252 { 253 org.objectweb.openccm.OpenCCM_DCI.AssemblyManagerModel amm= 255 DCI.get_connection_assembly_manager_model_home() 256 .create_assembly_model(descriptor); 257 amm.connect_assembly_factory(DCI.get_connection_assembly_factory()); 259 amm.connect_assembly_manager_model_registration 262 (DCI.provide_assembly_manager_model_registration()); 263 amm.configuration_complete(); 265 return amm.assemblyUUID(); 267 } 268 catch(Exception exc) 269 { 270 exc.printStackTrace(System.err); 272 273 throw new org.omg.Components.Deployment.InstallationFailure(); 274 } 275 } 276 277 282 public String 283 update_with_archive(String old_assemblyUUID, 284 byte[] archive) 285 throws org.ist.coach.DCI.UninstallationFailure, 286 org.ist.coach.DCI.UnknownAssembly, 287 org.omg.Components.Deployment.InstallationFailure, 288 org.ist.coach.DCI.AlreadyInstalled, 289 org.ist.coach.DCI.InvalidArchive 290 { 291 throw new org.omg.CORBA.NO_IMPLEMENT (); 293 } 294 295 300 public String 301 update_with_descriptor(String old_assemblyUUID, 302 String descriptor) 303 throws org.ist.coach.DCI.UninstallationFailure, 304 org.ist.coach.DCI.UnknownAssembly, 305 org.omg.Components.Deployment.InstallationFailure, 306 org.ist.coach.DCI.AlreadyInstalled 307 { 308 throw new org.omg.CORBA.NO_IMPLEMENT (); 310 } 311 312 316 public void 317 uninstall(String assemblyUUID) 318 throws org.ist.coach.DCI.UninstallationFailure, 319 org.ist.coach.DCI.UnknownAssembly, 320 org.ist.coach.DCI.AssemblyUsed 321 { 322 getAssemblyManagerModel(assemblyUUID) 323 .provide_assembly_instance_management() 324 .uninstall(); 325 } 326 327 334 public String 335 create_assembly_instance(String assemblyUUID) 336 throws org.ist.coach.DCI.CreationFailure 337 { 338 try 339 { 340 return 342 getAssemblyManagerModel(assemblyUUID) 343 .provide_assembly_instance_management() 344 .create_assembly_instance(); 345 } 346 catch(Exception e) 347 { 348 System.err.println(prefix+ 349 "Problem occured during the creation of instance"); 350 System.err.println(prefix+e.getMessage()); 351 throw new org.ist.coach.DCI.CreationFailure(); 352 } 353 } 354 355 362 public String [] 363 get_assembly_instances(String assemblyUUID) 364 throws org.ist.coach.DCI.UnknownAssembly 365 { 366 try 367 { 368 return 370 getAssemblyManagerModel(assemblyUUID) 371 .provide_assembly_instance_management() 372 .get_assembly_instances(); 373 } 374 catch(Exception exc) 375 { 376 exc.printStackTrace(System.err); 378 379 throw new org.ist.coach.DCI.UnknownAssembly(); 380 } 381 } 382 383 389 public org.ist.coach.DCI.AssemblyManager 390 get_assembly_manager(String instance_id) 391 throws org.ist.coach.DCI.UnknownAssembly 392 { 393 for(ammIterator.rewind(); 395 ammIterator.hasNext();) 396 { 397 try 398 { 399 return ammIterator.next() 400 .provide_assembly_instance_management() 401 .get_assembly_manager(instance_id); 402 } 403 catch(org.ist.coach.DCI.UnknownAssembly e) 404 { 405 } 406 } 407 408 throw new org.ist.coach.DCI.UnknownAssembly(); 410 } 411 412 417 public void 418 destroy_assembly_instance(String instance_id) 419 throws org.ist.coach.DCI.DestroyError 420 { 421 for(ammIterator.rewind(); ammIterator.hasNext();) 423 { 424 try 425 { 426 ammIterator.next() 427 .provide_assembly_instance_management() 428 .get_assembly_manager(instance_id); 429 ammIterator.current() 430 .provide_assembly_instance_management() 431 .destroy_assembly_instance(instance_id); 432 return ; 433 } 434 catch(org.ist.coach.DCI.UnknownAssembly ua) 435 { 436 } 437 } 438 439 throw new org.ist.coach.DCI.DestroyError() ; 441 } 442 443 448 public String [] 449 get_assemblies() 450 { 451 java.util.LinkedList ll=new java.util.LinkedList (); 452 453 for(ammIterator.rewind(); 455 ammIterator.hasNext();) 456 ll.addLast(ammIterator.next().assemblyUUID()); 457 458 return (String [])ll.toArray(new String [ll.size()]); 460 } 461 462 467 public String 468 lookup_assembly(String assemblyUUID) 469 throws org.ist.coach.DCI.UnknownAssembly 470 { 471 return getAssemblyManagerModel(assemblyUUID).xml_descriptor(); 472 } 473 } 474 | Popular Tags |