blob: dda07672a480aff18f0db02b3fdff76ba430f8a5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/*******************************************************************************
* Copyright (c) 2001, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jee.archive.internal;
import java.io.File;
import org.eclipse.jst.j2ee.commonarchivecore.internal.util.DeleteOnExitUtility;
/**
* Used as an optimization for reading jars within jars. Reading from a ZipFile is much faster than
* from a ZipInputStream, therefore, when possible, it makes sense to copy the nested jar to a temp
* file. It is the responsibility of the caller to ensure that the temp file gets deleted on normal
* system exit, using the helper method on java.io.File. This adapter will also delete the file
* when closed or finalized.
*/
public class TempZipFileArchiveLoadAdapterImpl extends ZipFileArchiveLoadAdapterImpl {
protected File file;
public TempZipFileArchiveLoadAdapterImpl() {
super();
}
public TempZipFileArchiveLoadAdapterImpl(java.io.File file) throws java.io.IOException {
super(ArchiveUtil.newZipFile(file));
this.file = file;
}
public File getFile(){
return file;
}
@Override
public void close() {
super.close();
File file = getFile();
file.delete();
DeleteOnExitUtility.fileHasBeenDeleted(file);
}
}
|