1 10 11 package org.mmbase.applications.packaging; 12 13 import java.util.Iterator ; 14 15 import org.mmbase.applications.packaging.bundlehandlers.BundleInterface; 16 import org.mmbase.applications.packaging.installhandlers.uninstallThread; 17 import org.mmbase.applications.packaging.packagehandlers.PackageInterface; 18 import org.mmbase.util.logging.Logger; 19 import org.mmbase.util.logging.Logging; 20 21 27 public class UninstallManager { 28 private static Logger log = Logging.getLoggerInstance(UninstallManager.class); 29 30 private static boolean active = false; 32 33 private static boolean bundle = false; 35 36 private static PackageInterface pkg; 38 39 private static BundleInterface bnd; 40 41 private static uninstallThread runner; 42 43 private static String state; 44 45 48 public static synchronized boolean uninstallPackage(PackageInterface p) { 49 if (!active) { 50 active = true; 52 53 bundle = false; 55 56 pkg = p; 58 state = "uninstalling"; 59 p.clearInstallSteps(); 60 runner = new uninstallThread(); 61 return true; 62 } else { 63 return false; 66 } 67 } 68 69 70 74 public static void performUninstall() { 75 try { 76 if (bnd != null) { 77 bnd.uninstall(); 78 state = "waiting"; 79 active = false; 80 bnd = null; 81 } else if (pkg != null) { 82 pkg.uninstall(); 83 state = "waiting"; 84 active = false; 85 pkg = null; 86 } 87 } catch(Exception e) { 88 log.error("performInstall problem"); 89 } 90 } 91 92 93 96 public static synchronized boolean uninstallBundle(BundleInterface b) { 97 if (!active) { 98 active = true; 100 101 bundle = true; 103 104 bnd = b; 106 107 state = "uninstalling"; 108 109 b.clearInstallSteps(); 110 111 runner = new uninstallThread(); 112 113 return true; 114 } else { 115 return false; 118 } 119 } 120 121 122 public void setState(String state) { 123 this.state = state; 124 } 125 126 public String getState() { 127 return state; 128 } 129 130 public static boolean isActive() { 131 return active; 132 } 133 134 public static PackageInterface getUnInstallingPackage() { 135 return pkg; 136 } 137 138 public static BundleInterface getUnInstallingBundle() { 139 return bnd; 140 } 141 142 public static Iterator getUninstallSteps() { 143 return pkg.getInstallSteps(); 144 } 145 } 146 | Popular Tags |