|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.izforge.izpack.util.LibraryRemover
public class LibraryRemover
This class tries to remove a given list of files which are locked by this process. For this the
paths of the files are stored in a temporary file and a new process will be created. The class
files which are needed by the new process will be unpacked from the jar file under users temp dir
in a "sandbox". The new process receive the path of the temporary file and some other
information. After a wait intervall it reads the path file and removes all files which there are
listed. Next the created "sandbox" and the path file will be removed. This class uses the
characteristik of the system loader that jar files will be keeped open, simple class files will
be closed after loading a class. Therefore jar files are locked and cannot be deleted, class
files are not locked and deletable.
The idea for this stuff is copied from Chadwick McHenry's SelfModifier in the uninstaller stuff
of IzPack.
Nested Class Summary | |
---|---|
static class |
LibraryRemover.StreamProxy
|
Field Summary | |
---|---|
private static java.lang.String |
BASE_KEY
System property name of base for log and sandbox of secondary processes. |
private java.util.Date |
date
Also for logging time. |
private java.text.SimpleDateFormat |
isoPoint
For logging time. |
private static java.lang.String |
JAVA_HOME
VM home Needed for the java command. |
(package private) java.io.PrintStream |
log
******************************************************************************************** --------------------------------------------------------------------- Logging --------------------------------------------------------------------- Copied from com.izforge.izpack.uninstaller.SelfModifier. |
private java.io.File |
logFile
Log for phase 2, because we can't capture the stdio from them. |
private int |
phase
Phase of this process. |
private static java.lang.String |
PHASE_KEY
System property name of phase (1, 2, or 3) indicator. |
private static java.lang.String |
PREFIX
Prefix of sandbox, path and log file. |
private java.io.File |
sandbox
Directory which we extract too, invoke from, and finally delete. |
private static java.lang.String[] |
SANDBOX_CONTENT
All class files which are needed for the second process. |
private java.io.File |
specFile
The file which contains the paths of the files to delete. |
Constructor Summary | |
---|---|
private |
LibraryRemover(int phase)
Constructor for both phases. |
Method Summary | |
---|---|
private static java.lang.String |
addExtension(java.lang.String command)
Copied from com.izforge.izpack.uninstaller.SelfModifier. |
private java.io.PrintStream |
checkLog()
|
static boolean |
deleteTree(java.io.File file)
Recursively delete a file structure. |
private java.util.ArrayList<java.io.File> |
getFilesList()
Returns an ArrayList of the files to delete. |
private void |
initJavaExec()
This call ensures that java can be exec'd in a separate process. |
static void |
invoke(java.util.List<java.lang.String> temporaryFileNames)
Entry point for phase 1. |
private void |
invoke1(java.util.List<java.lang.String> temporaryFileNames)
Internal invoke method for phase 1. |
private void |
invoke2()
Invoke methode for phase 2. |
private static java.lang.String |
javaCommand()
Copied from com.izforge.izpack.uninstaller.SelfModifier. |
private void |
log(java.lang.String msg)
|
private void |
log(java.lang.Throwable t)
|
static void |
main(java.lang.String[] args)
|
private java.lang.Process |
spawn(int nextPhase)
Copied from com.izforge.izpack.uninstaller.SelfModifier. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String[] SANDBOX_CONTENT
private static final java.lang.String BASE_KEY
private static final java.lang.String PHASE_KEY
private static final java.lang.String JAVA_HOME
private static final java.lang.String PREFIX
private int phase
private java.io.File logFile
private java.io.File sandbox
private java.io.File specFile
private java.text.SimpleDateFormat isoPoint
private java.util.Date date
java.io.PrintStream log
Constructor Detail |
---|
private LibraryRemover(int phase) throws java.io.IOException
phase
- for which an object should be created.
java.io.IOException
Method Detail |
---|
public static void invoke(java.util.List<java.lang.String> temporaryFileNames) throws java.io.IOException
temporaryFileNames
-
java.io.IOException
private void initJavaExec() throws java.io.IOException
java.io.IOException
- if an I/O error occurs, indicating java is unable to be exec'd
java.lang.SecurityException
- if a security manager exists and doesn't allow creation of a
subprocessprivate void invoke1(java.util.List<java.lang.String> temporaryFileNames) throws java.io.IOException
temporaryFileNames
- list of paths of the files which should be removed
java.io.IOException
private java.util.ArrayList<java.io.File> getFilesList() throws java.lang.Exception
java.lang.Exception
- Description of the Exceptionprivate void invoke2()
private java.lang.Process spawn(int nextPhase) throws java.io.IOException
nextPhase
- phase of the spawn
java.io.IOException
public static boolean deleteTree(java.io.File file)
private static java.lang.String addExtension(java.lang.String command)
private static java.lang.String javaCommand()
public static void main(java.lang.String[] args)
private java.io.PrintStream checkLog()
private void log(java.lang.Throwable t)
private void log(java.lang.String msg)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |