1 26 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer; 27 28 import java.util.Arrays ; 29 import java.util.Hashtable ; 30 import java.util.List ; 31 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.FatalDeploymentException; 32 import org.objectweb.openccm.descriptor.softpkg.ccm.DependencyResolutionFailureException; 33 import org.objectweb.openccm.Deployment.Server; 34 import org.objectweb.openccm.Deployment.ServerHelper; 35 import org.omg.Components.CCMHome; 36 import org.omg.Components.ConfigValue; 37 import org.omg.Components.Deployment.ComponentInstallation; 38 import org.omg.Components.Deployment.Container; 39 40 48 public class CSDestinationDeployer 49 extends DestinationDeployerBase 50 { 51 52 private Server server; 58 private Hashtable containerTable; 59 private java.util.List config_values; 60 public CSDestinationDeployer(){ 66 containerTable=new Hashtable (); 67 config_values=new java.util.LinkedList (); 68 } 69 70 81 private Server getServer() 82 throws Exception 83 { 84 if (server == null) { 85 server = ServerHelper.narrow(getFindbyDeployer().resolveReference()); 86 } 87 return server; 88 } 89 100 private CCMHome 101 installCCMHome( 102 ConfigValue[] csConfig, 103 ConfigValue[] contConfig, 104 ConfigValue[] homeConfig, 105 String implID, 106 String entryPoint) 107 throws FatalDeploymentException 108 { 109 110 CCMHome home = null; 111 try { 112 Container cont = getServer() 113 .provide_component_server() 114 .create_container(contConfig); 115 home = cont.install_home(implID, entryPoint, homeConfig); 116 containerTable.put(home, cont); 117 } catch (Exception e) { 118 throw new FatalDeploymentException(this,e,"Cannot deploy the CCMHome on the required destination"); 119 } 120 return home; 121 } 122 123 135 public ComponentInstallation 136 getComponentInstallation() 137 throws FatalDeploymentException { 138 139 try { 140 return getServer().provide_install(); 141 } catch (Exception e) { 142 throw new FatalDeploymentException(this,e,"Cannot acces to the componentinstallation on the required destination"); 143 } 144 } 145 152 public void 153 resolveDependency() 154 throws FatalDeploymentException 155 { 156 try{ 157 config_values.addAll(Arrays.asList(getSoftpkgDeployer() 158 .processDependencies 159 (getComponentInstallation()))); 160 List l=Arrays.asList(getImplementationDeployer() 161 .install(getComponentInstallation())); 162 163 config_values.addAll(l); 164 165 } 166 catch(DependencyResolutionFailureException e){ 167 getErrorManager().submitException(e); 168 } 169 } 170 177 public CCMHome 178 installHome() 179 throws FatalDeploymentException 180 { 181 ConfigValue[] config_home =(ConfigValue[]) 182 config_values.toArray(new ConfigValue[config_values.size()]); 183 184 return installCCMHome(new ConfigValue[0], 185 new ConfigValue[0], 186 config_home, 187 getImplementationDeployer().getImplementation().getId(), 188 getImplementationDeployer().getEntryPoint()); 189 } 190 191 192 198 public void 199 removeHome(CCMHome home) 200 throws FatalDeploymentException 201 { 202 try { 203 Container cont = (Container) containerTable.remove(home); 204 cont.remove_home(home); 205 cont.remove(); 206 } catch (Exception e) { 207 throw new FatalDeploymentException(e); 208 } 209 } 210 211 } 212 | Popular Tags |