1 26 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer; 27 28 import org.objectweb.openccm.descriptor.componentassembly.beans.ComponentfilerefBeanImpl; 30 import org.objectweb.openccm.descriptor.componentassembly.beans.ComponentinstantiationBean; 31 import org.objectweb.openccm.descriptor.componentassembly.beans.HomeplacementBeanImpl; 32 import org.objectweb.openccm.descriptor.componentassembly.beans.RegisterwithhomefinderBeanImpl; 33 import org.objectweb.openccm.descriptor.componentassembly.beans.RegisterwithnamingBeanImpl; 34 import org.objectweb.openccm.descriptor.componentassembly.beans.RegisterwithtraderBeanImpl; 35 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.HandlerBase; 36 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base.InitializationError; 37 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.registrar.*; 38 import org.objectweb.openccm.descriptor.softpkg.ccm.DefaultDescriptorDeployer; 39 import org.objectweb.openccm.descriptor.softpkg.ccm.DescriptorDeployerInterface; 40 41 49 public class HomeplacementDeployerHandler 50 extends HandlerBase 51 { 52 private HomeplacementDeployer _deploy; 58 81 public Object 82 getInstance(HomeplacementBeanImpl homeplacement) 83 throws InitializationError 84 { 85 if(_deploy==null){ 86 _deploy=new HomeplacementDeployer(); 87 _deploy.connectHomeplacement(homeplacement); 88 applyCommonConfig(_deploy); 89 if(homeplacement.getComponentinstantiationList()!=null) 90 for(java.util.Iterator i=homeplacement.getComponentinstantiationList().iterator();i.hasNext(); ){ 91 ComponentinstantiationDeployer current=(ComponentinstantiationDeployer) 92 getDeployer((ComponentinstantiationBean)i.next()); 93 _deploy.connectComponentInstantiationDeployer(current); 94 } 95 if(homeplacement.getRegisterwithnamingList()!=null) 96 for(java.util.Iterator i=homeplacement.getRegisterwithnamingList().iterator();i.hasNext(); ){ ; 97 _deploy.connectRegisterwithnamingDeployer 98 ((RegisterwithnamingDeployer) 99 getDeployer((RegisterwithnamingBeanImpl)i.next())); 100 } 101 if(homeplacement.getRegisterwithtraderList()!=null) 102 for(java.util.Iterator i=homeplacement.getRegisterwithtraderList().iterator();i.hasNext(); ){ ; 103 _deploy.connectRegisterwithtraderDeployer 104 ((RegisterwithtraderDeployer) 105 getDeployer((RegisterwithtraderBeanImpl)i.next())); 106 } 107 _deploy.connectHomeplacementInfo 108 ( (HomeplacementDeployInfo) 109 homeplacement.getExtensionManager(). 110 getExtensionByName("ccm.deployer.installer.DeployInfo") 111 .getInstance() ); 112 113 if(homeplacement.getDestination()!=null) 114 _deploy.connectDestinationDeployer 115 ((DestinationDeployer)getDeployer(homeplacement.getDestination())); 116 117 ComponentfileDeployer componentfile; 118 119 if(homeplacement.getComponentfileref()==null) 120 throw new InitializationError(_deploy,"No componentfileref was specified "+ 121 "check you homeplacement element description it must specify it\n"+ 122 _deploy.getStringifiedDeployerDescription() 123 ); 124 if(homeplacement.getComponentimplref()==null) 125 throw new InitializationError(_deploy,"No componentimplref was specified "+ 126 "check you homeplacement element description it must specify it\n"+ 127 _deploy.getStringifiedDeployerDescription() 128 ); 129 130 try{ 131 if(((ComponentfilerefBeanImpl) 132 homeplacement 133 .getComponentfileref()) 134 .pullIdref()==null) 135 throw new InitializationError 136 (_deploy,"The componentfileref "+homeplacement 137 .getComponentfileref().getIdref()+" is not a valid componentfile "+ 138 "identifiant, check your CAD file it specifies bad componentfile"+ 139 " idref\n"+_deploy.getStringifiedDeployerDescription()); 140 141 if(((ComponentfilerefBeanImpl) 142 homeplacement 143 .getComponentfileref()) 144 .pullIdref()==null) 145 throw new InitializationError(_deploy,"Bad componentfile identifiant was specified "+ 146 homeplacement.getComponentfileref().getIdref()+ 147 " denote a non existing componentfile check you homeplacement element description\n"+ 148 _deploy.getStringifiedDeployerDescription() 149 ); 150 151 componentfile=(ComponentfileDeployer) 152 getDeployer(((ComponentfilerefBeanImpl) 153 homeplacement 154 .getComponentfileref()) 155 .pullIdref()); 156 } 157 catch(java.lang.ClassCastException e){ 158 throw new InitializationError(_deploy,"Similar identifiants was detected, it was expected that "+ 159 homeplacement.getComponentfileref().getIdref()+ 160 " denote a componentfile but a "+ 161 ((ComponentfilerefBeanImpl) 162 homeplacement.getComponentfileref()) 163 .pullIdref().getClass().getName()+" was found "+ 164 "check your CAD file a identifiant is used for two different elements;"+ 165 " To achieved successfully the deployment use different name for this two identifiants"); 166 } 167 catch(java.lang.NullPointerException e){ 168 throw new InitializationError(_deploy,"Bad componentfileref was specified "+ 169 homeplacement.getComponentfileref().getIdref()+ 170 " denote a non existing componentfile check you homeplacement element description\n"+ 171 _deploy.getStringifiedDeployerDescription() 172 ); 173 } 174 175 _deploy.connectSoftpkgDeployer(componentfile.getSoftpkgDeployer()); 176 177 178 if(componentfile.getImplementationDeployer 179 (homeplacement.getComponentimplref().getIdref())!=null){ 180 181 _deploy.connectImplementationDeployer 182 (componentfile.getImplementationDeployer 183 (homeplacement.getComponentimplref().getIdref())); 184 185 } 186 else { 187 throw new InitializationError(_deploy,"Bad componentimplref was specified "+ 188 homeplacement.getComponentimplref().getIdref()+ 189 " denote a non existing implementation check you homeplacement element description\n"+ 190 _deploy.getStringifiedDeployerDescription() 191 ); 192 } 193 if(_deploy.getDestinationDeployer()!=null) 194 { 195 ((DestinationDeployerContext) 196 _deploy.getDestinationDeployer()) 197 .connectSoftpkgDeployer(_deploy.getSoftpkgDeployer()); 198 199 ((DestinationDeployerContext) 200 _deploy.getDestinationDeployer()) 201 .connectImplementationDeployer 202 (_deploy.getImplementationDeployer()); 203 204 } 205 DescriptorDeployerInterface descr=new DefaultDescriptorDeployer(); 206 if(_deploy.getSoftpkgDeployer().getDescriptorDeployers()!=null&& 207 _deploy.getSoftpkgDeployer().getDescriptorDeployers().length>0){ 208 209 descr=_deploy.getSoftpkgDeployer().getDescriptorDeployers()[0]; 210 211 } 212 213 if(_deploy.getImplementationDeployer().getDescriptorDeployers()!=null&& 214 _deploy.getImplementationDeployer().getDescriptorDeployers().length>0){ 215 216 descr=_deploy.getImplementationDeployer().getDescriptorDeployers()[0]; 217 218 } 219 220 if(homeplacement.getRegisterwithhomefinderList()!=null) 221 for(java.util.Iterator i=homeplacement.getRegisterwithhomefinderList().iterator();i.hasNext(); ){ 222 RegisterwithhomefinderDeployer rwhf= 223 ((RegisterwithhomefinderDeployer) 224 getDeployer((RegisterwithhomefinderBeanImpl)i.next())); 225 rwhf.connectDescriptorDeployer(descr); 226 _deploy.connectRegisterwithhomefinderDeployer(rwhf); 227 } 228 } 231 232 return (_deploy); 233 } 234 235 } 236 | Popular Tags |