1 26 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.base; 27 28 import java.net.ServerSocket ; 29 import java.util.LinkedList ; 30 import java.util.Hashtable ; 31 import java.util.Iterator ; 32 import java.util.Enumeration ; 33 import java.io.File ; 34 import java.io.InputStream ; 35 import java.io.Reader ; 36 import java.io.IOException ; 37 import java.util.zip.ZipFile ; 38 import org.ist.coach.DCI.DCIInformation; 39 import org.objectweb.openccm.descriptor.ZipEntryRetriever; 40 import org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer.DestinationDeployerFactory; 41 import org.objectweb.openccm.descriptor.StreamManager; 42 import org.ist.coach.DCI.AssemblyManager; 43 import org.omg.Components.CCMObject; 44 import org.omg.Components.HomeFinder; 45 import org.omg.Components.HomeRegistration; 46 import org.omg.CosNaming.NamingContextExt ; 47 48 56 public abstract class RootDeployerContext 57 extends DeployerContext 58 implements StreamManager{ 59 65 66 private NamingContextExt naming; 68 private LinkedList components; 70 private SymbolConvertion sc; 72 private HomeFinder homefinder; 74 private HomeRegistration homeregistration; 76 private DCIInformation dciInfo; 78 private ZipEntryRetriever zipRetriever; 80 private ServerSocket ssocket; 82 private DeploymentLogger deploymentLogger; 84 private AssemblyManager assemblyManager; 86 private DestinationDeployerFactory destinationDeployerFactory; 88 private ErrorManager errorManager; 90 private String workDir; 92 private Hashtable temporaryFiles; 94 private LinkedList openInputStreams; 96 private LinkedList openReaders; 98 private LinkedList openZipFiles; 100 106 public RootDeployerContext(){ 107 components=new LinkedList (); 108 temporaryFiles=new Hashtable (); 109 openInputStreams=new LinkedList (); 110 openReaders=new LinkedList (); 111 openZipFiles=new LinkedList (); 112 } 113 119 125 public void 126 connectNamingContextExt(NamingContextExt naming) 127 { 128 this.naming=naming; 129 } 130 131 public NamingContextExt 132 getNamingContextExt() 133 { 134 return naming; 135 } 136 137 public void 138 connectHomeFinder(HomeFinder homefinder) 139 { 140 this.homefinder=homefinder; 141 } 142 143 public HomeFinder 144 getHomefinder() 145 { 146 return homefinder; 147 } 148 149 150 public void 151 connectHomeregistration(HomeRegistration homeregistration) 152 { 153 this.homeregistration=homeregistration; 154 } 155 156 public HomeRegistration 157 getHomeRegistration() 158 { 159 return homeregistration; 160 } 161 162 public void 163 connectDCIInformation(DCIInformation dciInfo) 164 { 165 this.dciInfo=dciInfo; 166 } 167 168 public DCIInformation 169 getDCIInformation() 170 { 171 return dciInfo; 172 } 173 174 public void 175 connectZipEntryRetriever(ZipEntryRetriever zipRetriever) 176 { 177 this.zipRetriever=zipRetriever; 178 } 179 180 public ZipEntryRetriever 181 getZipEntryRetriever() 182 { 183 return zipRetriever; 184 } 185 186 public void 187 connectServerSocket(ServerSocket ssocket) 188 { 189 this.ssocket=ssocket; 190 } 191 192 public ServerSocket 193 getServerSocket() 194 { 195 return ssocket; 196 } 197 198 public void 199 connectComponent(CCMObject comp) 200 { 201 components.addLast(comp); 202 } 203 204 public void 205 disconnectComponent(CCMObject comp) 206 { 207 components.remove(comp); 208 } 209 public CCMObject [] 210 getComponents() 211 { 212 return (CCMObject[])components.toArray(new CCMObject[components.size()]); 213 } 214 215 public void 216 connectConvertTool(SymbolConvertion sc) 217 { 218 this.sc=sc; 219 } 220 221 public String 222 convertSymbol(String ch) 223 { 224 return sc.convertSymbol(ch); 225 } 226 227 public RootDeployerContext 228 getRootDeployerContext() 229 { 230 return this; 231 } 232 233 234 237 public DeploymentLogger 238 getDeploymentLogger() 239 { 240 return deploymentLogger; 241 } 242 243 246 public void 247 connectDeploymentLogger(DeploymentLogger logger) 248 { 249 deploymentLogger = logger; 250 } 251 252 255 public AssemblyManager 256 getAssemblyManager() 257 { 258 return assemblyManager; 259 } 260 261 264 public void 265 connectAssemblyManager(AssemblyManager manager) 266 { 267 assemblyManager = manager; 268 } 269 270 273 public DestinationDeployerFactory 274 getDestinationDeployerFactory() 275 { 276 return destinationDeployerFactory; 277 } 278 279 282 public void 283 connectDestinationDeployerFactory(DestinationDeployerFactory factory) 284 { 285 destinationDeployerFactory = factory; 286 } 287 288 291 public ErrorManager 292 getErrorManager() 293 { 294 return errorManager; 295 } 296 297 300 public void 301 connectErrorManager(ErrorManager manager) 302 { 303 errorManager = manager; 304 } 305 306 public void 307 setWorkDir(String workDir) 308 { 309 this.workDir=workDir; 310 } 311 312 public String 313 getWorkDir() 314 { 315 return workDir; 316 } 317 318 public void 319 connectTemporaryFile(File file) 320 { 321 temporaryFiles.put(System.currentTimeMillis()+"",file); 322 } 323 324 public void 325 connectTemporaryFile(File file, String identifier) 326 { 327 temporaryFiles.put(identifier,file); 328 } 329 330 public boolean 331 isAlreadyDownloaded(String identifier) 332 { 333 return temporaryFiles.containsKey(identifier); 334 } 335 336 public File 337 getTemporaryFile(String identifier) 338 { 339 return (File )temporaryFiles.get(identifier); 340 } 341 342 public void 343 deleteAllTemporaryFiles() 344 { 345 if(temporaryFiles.size()<1)return; 346 347 for(Enumeration keys=temporaryFiles.keys();keys.hasMoreElements();){ 348 String key=(String )keys.nextElement(); 349 File f=(File )temporaryFiles.remove(key); 350 if(!f.delete()) 351 f.deleteOnExit(); 352 } 353 } 354 355 public void 356 connectOpenInputStream(InputStream isr) 357 { 358 openInputStreams.add(isr); 359 } 360 361 public void 362 closeAllOpenInputStreams() 363 throws IOException 364 { 365 if(openInputStreams.size()>0) 366 for(InputStream r=(InputStream )openInputStreams.removeFirst(); 367 openInputStreams.size()>0; 368 r=(InputStream )openInputStreams.removeFirst()) 369 r.close(); 370 } 371 372 public void 373 connectOpenReader(Reader reader) 374 { 375 openReaders.add(reader); 376 } 377 public void 378 closeAllOpenReaders() 379 throws IOException 380 { 381 if(openReaders.size()>0) 382 for(Reader r=(Reader )openReaders.removeFirst(); 383 openReaders.size()>0; 384 r=(Reader )openReaders.removeFirst()) 385 r.close(); 386 } 387 388 public void 389 connectOpenZipFile(ZipFile zf) 390 { 391 openZipFiles.add(zf); 392 } 393 394 public void 395 closeAllOpenZipFile() 396 throws IOException 397 { 398 if(openZipFiles.size()>0) 399 for(ZipFile r=(ZipFile )openZipFiles.removeFirst(); 400 openZipFiles.size()>0; 401 r=(ZipFile )openZipFiles.removeFirst()) 402 r.close(); 403 } 404 public void 405 clearAllStream() 406 throws IOException 407 { 408 closeAllOpenReaders(); 409 closeAllOpenInputStreams(); 410 closeAllOpenZipFile(); 411 deleteAllTemporaryFiles(); 412 } 413 } 414 | Popular Tags |