1 17 package org.apache.geronimo.deployment.plugin.local; 18 19 import java.net.URI ; 20 import javax.enterprise.deploy.shared.CommandType ; 21 import javax.enterprise.deploy.spi.TargetModuleID ; 22 23 import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl; 24 import org.apache.geronimo.kernel.InternalKernelException; 25 import org.apache.geronimo.kernel.Kernel; 26 import org.apache.geronimo.kernel.config.ConfigurationManager; 27 import org.apache.geronimo.kernel.config.ConfigurationUtil; 28 import org.apache.geronimo.kernel.config.NoSuchConfigException; 29 import org.apache.geronimo.kernel.repository.Artifact; 30 31 34 public class UndeployCommand extends CommandSupport { 35 private static final String [] UNINSTALL_SIG = {URI .class.getName()}; 36 private final Kernel kernel; 37 private final TargetModuleID [] modules; 38 39 public UndeployCommand(Kernel kernel, TargetModuleID modules[]) { 40 super(CommandType.UNDEPLOY); 41 this.kernel = kernel; 42 this.modules = modules; 43 } 44 45 public void run() { 46 try { 47 ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); 48 try { 49 for (int i = 0; i < modules.length; i++) { 50 TargetModuleIDImpl module = (TargetModuleIDImpl) modules[i]; 51 52 Artifact moduleID = Artifact.create(module.getModuleID()); 53 try { 54 if(!configurationManager.isOnline()) { 55 configurationManager.loadConfiguration(moduleID); 59 } 60 61 configurationManager.stopConfiguration(moduleID); 62 63 64 configurationManager.unloadConfiguration(moduleID); 65 updateStatus("Module " + moduleID + " unloaded."); 66 } catch (InternalKernelException e) { 67 } catch (NoSuchConfigException e) { 69 } 71 72 try { 73 configurationManager.uninstallConfiguration(moduleID); 74 updateStatus("Module " + moduleID + " uninstalled."); 75 addModule(module); 76 } catch (NoSuchConfigException e) { 77 } 79 } 80 } finally { 81 ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager); 82 } 83 84 if (getModuleCount() < modules.length) { 86 updateStatus("Some of the modules to undeploy were not previously deployed. This is not treated as an error."); 87 } 88 complete("Completed"); 89 } catch (Exception e) { 90 doFail(e); 91 } 92 } 93 } 94 | Popular Tags |