1 26 27 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer; 28 29 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.*; 31 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.registrar.*; 32 import org.objectweb.openccm.descriptor.componentassembly.*; 33 import org.omg.Components.CCMHome; 34 35 36 44 public class HomeplacementDeployer extends HomeplacementDeployerContext{ 45 46 52 private class CannotSetupHomeException extends Exception {}; 53 54 private org.omg.Components.CCMHome homePlaced; 55 56 private org.objectweb.openccm.descriptor.softpkg.Descriptor descriptor; 57 58 69 70 75 private void 76 setupSoftpkgDependency() 77 throws FatalDeploymentException 78 { 79 getDestinationDeployer().resolveDependency(); 80 81 } 82 83 89 private org.omg.Components.CCMHome 90 setupHome() 91 throws FatalDeploymentException, 92 CannotSetupHomeException 93 94 { 95 try { 96 97 return getDestinationDeployer().installHome(); 98 99 }catch(Error err){System.out.println(err.getMessage());} 100 101 throw new CannotSetupHomeException(); 102 } 103 108 private void 109 proceedHomeRegistration() 110 throws FatalDeploymentException 111 { 112 traverse(this,getRegisterwithnamingDeployers()); 113 traverse(this,getRegisterwithhomefinderDeployers()); 114 traverse(this,getRegisterwithtraderDeployers()); 115 } 116 117 123 135 public void 136 visit(ComponentinstantiationDeployer comp, DeployerInactiveState status) 137 throws FatalDeploymentException 138 { 139 try{ 140 comp.deploy(homePlaced); 141 } 142 catch(ComponentInstantiationFailureException e){ 143 getErrorManager().submitException(e); 144 } 145 } 146 153 public void 154 visit(RegisterwithhomefinderDeployer deployer, DeployerInactiveState status) 155 { 156 try{ 157 deployer.register_home(descriptor,homePlaced); 158 } 159 catch(Exception e){ 160 e.printStackTrace(); 161 } 162 } 163 170 public void visit(RegisterwithnamingDeployer deployer, 171 DeployerInactiveState status) 172 throws FatalDeploymentException{ 173 try{ 174 deployer.rebind(homePlaced); 175 } 176 catch(NameserviceRegistrationFailureException e){ 177 getErrorManager().submitException(e); 178 } 179 } 180 187 public void visit(RegisterwithtraderDeployer deployer, DeployerInactiveState status){ 188 try{ 189 deployer.deploy(homePlaced); 190 } 191 catch(Exception e){ 192 e.printStackTrace(); 193 } 194 } 195 196 197 198 204 public void 205 deploy() 206 throws FatalDeploymentException 207 { 208 setupSoftpkgDependency(); 209 try { 210 212 homePlaced =setupHome() ; 213 getHomeplacementInfo().setCorbaReference(homePlaced); 215 getLogger().log("Home "+getHomeplacement().getId()+"is deployed"); 216 } 217 catch(Exception e){ 218 System.err.println("Problem occurred during the deployment of "+getHomeplacement().getId()); 219 e.printStackTrace(); 220 221 } 222 traverse(this,getComponentInstantiationDeployers()); 224 proceedHomeRegistration(); 225 getLifeCycleManager().stepEndedSuccessFully(); 226 } 227 228 232 public CCMHome getHome(){ 233 return homePlaced; 234 } 235 236 237 241 public void 242 tearDown() 243 throws FatalDeploymentException 244 { 245 Homeplacement hi=getHomeplacement(); 246 traverse(this,getComponentInstantiationDeployers()); 247 traverse(this,getRegisterwithnamingDeployers()); 248 traverse(this,getRegisterwithtraderDeployers()); 249 traverse(this,getRegisterwithhomefinderDeployers()); 250 getDestinationDeployer().removeHome(homePlaced); 252 getLifeCycleManager().stepEndedSuccessFully(); 253 } 254 255 267 public void 268 visit(ComponentinstantiationDeployer comp, DeployerActiveState status) 269 { 270 try{ 271 comp.tearDown(); 272 } 273 catch(Exception e) 274 { 275 System.out.println("Cannot remove the instance"); 276 e.printStackTrace(); 277 } 278 } 279 286 public void 287 visit(RegisterwithhomefinderDeployer deployer, DeployerActiveState status) 288 { 289 try{ 290 deployer.unregister_home(); 291 } 292 catch(Exception e){ 293 e.printStackTrace(); 294 } 295 } 296 303 public void 304 visit( 305 RegisterwithnamingDeployer deployer, 306 DeployerActiveState status) 307 { 308 try { 309 deployer.unbind(); 310 } catch (Exception e) { 311 e.printStackTrace(); 312 } 313 } 314 321 public void 322 visit( 323 RegisterwithtraderDeployer deployer, 324 DeployerActiveState status) 325 { 326 try { 327 deployer.tearDown(); 328 } catch (Exception e) { 329 e.printStackTrace(); 330 } 331 } 332 } 333 | Popular Tags |