1 17 18 package org.apache.geronimo.deployment.plugin.local; 19 20 import java.util.List ; 21 import javax.enterprise.deploy.shared.CommandType ; 22 import javax.enterprise.deploy.shared.ModuleType ; 23 import javax.enterprise.deploy.spi.TargetModuleID ; 24 25 import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl; 26 import org.apache.geronimo.kernel.Kernel; 27 import org.apache.geronimo.kernel.config.Configuration; 28 import org.apache.geronimo.kernel.config.ConfigurationManager; 29 import org.apache.geronimo.kernel.config.ConfigurationUtil; 30 import org.apache.geronimo.kernel.repository.Artifact; 31 import org.apache.geronimo.gbean.AbstractName; 32 33 36 public class StartCommand extends CommandSupport { 37 private final Kernel kernel; 38 private final TargetModuleID [] modules; 39 40 public StartCommand(Kernel kernel, TargetModuleID modules[]) { 41 super(CommandType.START); 42 this.kernel = kernel; 43 this.modules = modules; 44 } 45 46 public void run() { 47 try { 48 ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel); 49 try { 50 for (int i = 0; i < modules.length; i++) { 51 TargetModuleID module = modules[i]; 52 53 Artifact moduleID = Artifact.create(module.getModuleID()); 55 if (configurationManager.isRunning(moduleID)) { 56 updateStatus("Module " + moduleID + " is already running"); 57 Thread.sleep(100); 58 continue; 59 } 60 61 if(!configurationManager.isLoaded(moduleID)) { 63 configurationManager.loadConfiguration(moduleID); 64 } 65 66 configurationManager.startConfiguration(moduleID); 68 69 List kids = loadChildren(kernel, moduleID.toString()); 72 73 TargetModuleIDImpl id = new TargetModuleIDImpl(modules[i].getTarget(), module.getModuleID(), 75 (String []) kids.toArray(new String [kids.size()])); 76 if (isWebApp(kernel, moduleID.toString())) { 77 id.setType(ModuleType.WAR); 78 } 79 if (id.getChildTargetModuleID() != null) { 80 for (int k = 0; k < id.getChildTargetModuleID().length; k++) { 81 TargetModuleIDImpl child = (TargetModuleIDImpl) id.getChildTargetModuleID()[k]; 82 if (isWebApp(kernel, child.getModuleID())) { 83 child.setType(ModuleType.WAR); 84 } 85 } 86 } 87 addModule(id); 88 } 89 } finally { 90 ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager); 91 } 92 addWebURLs(kernel); 93 complete("Completed"); 94 } catch (Exception e) { 95 e.printStackTrace(); 96 doFail(e); 97 } 98 } 99 } 100 | Popular Tags |