001
014
015 package com.liferay.portal.zip;
016
017 import com.liferay.portal.kernel.util.ReflectionUtil;
018
019 import java.lang.reflect.Field;
020
021
024 public class TrueZIPHelperUtil {
025
026 public static void initialize() {
027 try {
028 Class.forName(
029 "de.schlichtherle.io.ArchiveControllers", true,
030 TrueZIPHelperUtil.class.getClassLoader());
031
032 Class<?> clazz = Class.forName(
033 "de.schlichtherle.io.ArchiveControllers$ShutdownHook");
034
035 Field field = ReflectionUtil.getDeclaredField(clazz, "SINGLETON");
036
037 Thread thread = (Thread)field.get(null);
038
039 Runtime runtime = Runtime.getRuntime();
040
041 if (runtime.removeShutdownHook(thread)) {
042 _thread = thread;
043 }
044 }
045 catch (Exception e) {
046 ReflectionUtil.throwException(e);
047 }
048 }
049
050 public static void shutdown() {
051 Thread thread = _thread;
052
053 if (thread != null) {
054 thread.start();
055
056 try {
057 thread.join();
058 }
059 catch (InterruptedException ie) {
060 ReflectionUtil.throwException(ie);
061 }
062 }
063 }
064
065 private static volatile Thread _thread;
066
067 }