1 21 22 package com.izforge.izpack.event; 23 24 import java.io.InputStream ; 25 import java.io.ObjectInputStream ; 26 import java.util.List ; 27 28 import com.coi.tools.os.win.NativeLibException; 29 import com.izforge.izpack.util.AbstractUIProgressHandler; 30 import com.izforge.izpack.util.TargetFactory; 31 import com.izforge.izpack.util.os.RegistryHandler; 32 import com.izforge.izpack.util.os.WrappedNativeLibException; 33 34 42 public class RegistryUninstallerListener extends NativeUninstallerListener 43 { 44 45 48 public RegistryUninstallerListener() 49 { 50 super(); 51 } 52 53 59 public void beforeDeletion(List files, AbstractUIProgressHandler handler) throws Exception 60 { 61 InputStream in = getClass().getResourceAsStream("/registryEntries"); 63 if (in == null) 64 { return; 66 } 67 ObjectInputStream objIn = new ObjectInputStream (in); 68 List allActions = (List ) objIn.readObject(); 69 objIn.close(); 70 in.close(); 71 if (allActions == null || allActions.size() < 1) return; 72 try 73 { 74 RegistryHandler registryHandler = initializeRegistryHandler(); 75 if (registryHandler == null) return; 76 registryHandler.activateLogging(); 77 registryHandler.setLoggingInfo(allActions); 78 registryHandler.rewind(); 79 } 80 catch (Exception e) 81 { 82 if (e instanceof NativeLibException) 83 { 84 throw new WrappedNativeLibException(e); 85 } 86 else 87 throw e; 88 } 89 } 90 91 private RegistryHandler initializeRegistryHandler() throws Exception 92 { 93 RegistryHandler registryHandler = null; 94 try 95 { 96 registryHandler = (RegistryHandler) (TargetFactory.getInstance() 97 .makeObject("com.izforge.izpack.util.os.RegistryHandler")); 98 } 99 catch (Throwable exception) 100 { 101 exception.printStackTrace(); 102 registryHandler = null; } 104 if (registryHandler != null && (!registryHandler.good() || !registryHandler.doPerform())) 105 { 106 System.out.println("initializeRegistryHandler is Bad " + registryHandler.good() 107 + registryHandler.doPerform()); 108 registryHandler = null; 109 } 110 return (registryHandler); 111 } 112 113 } 114 | Popular Tags |