geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dwo...@apache.org
Subject svn commit: r537224 - in /geronimo/server/trunk: applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/configmanager/ modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/ modules/ge...
Date Fri, 11 May 2007 16:25:52 GMT
Author: dwoods
Date: Fri May 11 09:25:51 2007
New Revision: 537224

URL: http://svn.apache.org/viewvc?view=rev&rev=537224
Log:
GERONIMO-1285 Deployer does not list all modules that have been stopped
Slight rework, to remove the extraneous updateStatus() calls when processing the childs.
Also updated StopCommand to display "Module <id> is already stopped" instead of treating
it as a failure.
Rakesh, thanks for the patches.

Modified:
    geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
    geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
    geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
    geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java

Modified: geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java?view=diff&rev=537224&r1=537223&r2=537224
==============================================================================
--- geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
(original)
+++ geronimo/server/trunk/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
Fri May 11 09:25:51 2007
@@ -22,8 +22,17 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.deploy.shared.ModuleType;
+import javax.enterprise.deploy.spi.DeploymentManager;
+import javax.enterprise.deploy.spi.Target;
+import javax.enterprise.deploy.spi.TargetModuleID;
+import javax.enterprise.deploy.spi.exceptions.TargetException;
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
@@ -32,9 +41,13 @@
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
+
+import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.console.BasePortlet;
 import org.apache.geronimo.console.util.PortletManager;
+import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
 import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.kernel.DependencyManager;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelRegistry;
@@ -50,6 +63,7 @@
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.MissingDependencyException;
 import org.apache.geronimo.management.geronimo.WebModule;
+import org.apache.geronimo.kernel.config.LifecycleResults;
 
 public class ConfigManagerPortlet extends BasePortlet {
 
@@ -73,6 +87,111 @@
 
     private PortletRequestDispatcher helpView;
 
+    private void printChilds(AbstractName config, int tab) {
+        messageStatus += "<br/>";
+        for (int i=0;i<tab;i++)
+            messageStatus += "&nbsp;&nbsp;";
+        messageStatus +=config.toString();
+
+        DependencyManager depMgr = kernel.getDependencyManager();
+
+        java.util.Set children = depMgr.getChildren(config);
+        for (Iterator itr = children.iterator(); itr.hasNext(); ) {
+            AbstractName child = (AbstractName)itr.next();
+            //if(configManager.isConfiguration(child.getArtifact()))
+            if (child.getNameProperty("configurationName") != null) {
+                printChilds(child,tab+1);
+            }
+        }
+    }
+
+    public static List loadChildren(Kernel kernel, String configName) {
+        List kids = new ArrayList();
+
+        Map filter = new HashMap();
+        filter.put("J2EEApplication", configName);
+
+        filter.put("j2eeType", "WebModule");
+        Set test = kernel.listGBeans(new AbstractNameQuery(null, filter));
+        for (Iterator it = test.iterator(); it.hasNext();) {
+            AbstractName child = (AbstractName) it.next();
+            String childName = child.getNameProperty("name");
+            kids.add(childName);
+        }
+
+        filter.put("j2eeType", "EJBModule");
+        test = kernel.listGBeans(new AbstractNameQuery(null, filter));
+        for (Iterator it = test.iterator(); it.hasNext();) {
+            AbstractName child = (AbstractName) it.next();
+            String childName = child.getNameProperty("name");
+            kids.add(childName);
+        }
+
+        filter.put("j2eeType", "AppClientModule");
+        test = kernel.listGBeans(new AbstractNameQuery(null, filter));
+        for (Iterator it = test.iterator(); it.hasNext();) {
+            AbstractName child = (AbstractName) it.next();
+            String childName = child.getNameProperty("name");
+            kids.add(childName);
+        }
+
+        filter.put("j2eeType", "ResourceAdapterModule");
+        test = kernel.listGBeans(new AbstractNameQuery(null, filter));
+        for (Iterator it = test.iterator(); it.hasNext();) {
+            AbstractName child = (AbstractName) it.next();
+            String childName = child.getNameProperty("name");
+            kids.add(childName);
+        }
+        return kids;
+    }
+
+    public static boolean isWebApp(Kernel kernel, String configName) {
+        Map filter = new HashMap();
+        filter.put("j2eeType", "WebModule");
+        filter.put("name", configName);
+        Set set = kernel.listGBeans(new AbstractNameQuery(null, filter));
+        return set.size() > 0;
+    }
+
+    public void printResults(Set lcresult, String action) {
+
+        java.util.Iterator iterator= lcresult.iterator();
+        while (iterator.hasNext()) {
+            Artifact config = (Artifact)iterator.next();
+
+            //TODO might be a hack
+            List kidsChild = loadChildren(kernel, config.toString());
+
+            // Build a response obect containg the started configuration and a list of it's
contained modules
+            TargetModuleIDImpl idChild = new TargetModuleIDImpl(null, config.toString(),
+                                                                (String[]) kidsChild.toArray(new
String[kidsChild.size()]));
+            if (isWebApp(kernel, config.toString())) {
+                idChild.setType(ModuleType.WAR);
+            }
+            if (idChild.getChildTargetModuleID() != null) {
+                for (int k = 0; k < idChild.getChildTargetModuleID().length; k++) {
+                    TargetModuleIDImpl child = (TargetModuleIDImpl) idChild.getChildTargetModuleID()[k];
+                    if (isWebApp(kernel, child.getModuleID())) {
+                        child.setType(ModuleType.WAR);
+                    }
+                }
+            }
+            messageStatus += "    ";
+            messageStatus += idChild.getModuleID()+(idChild.getWebURL() == null || !action.equals(START_ACTION)
? "" : " @ "+idChild.getWebURL());
+            messageStatus += "<br />";
+            if (idChild.getChildTargetModuleID() != null) {
+                for (int j = 0; j < idChild.getChildTargetModuleID().length; j++) {
+                    TargetModuleID child = idChild.getChildTargetModuleID()[j];
+                    messageStatus += "      `-> "+child.getModuleID()+(child.getWebURL()
== null || !action.equals(START_ACTION) ? "" : " @ "+child.getWebURL());
+                    messageStatus += "<br />";
+                }
+            }
+            messageStatus += "<br />";
+
+
+        }
+    }
+
     public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)
throws PortletException, IOException {
         String action = actionRequest.getParameter("action");
         actionResponse.setRenderParameter("message", ""); // set to blank first
@@ -86,23 +205,26 @@
                     configurationManager.loadConfiguration(configId);
                 }
                 if(!configurationManager.isRunning(configId)) {
-                    configurationManager.startConfiguration(configId);
+                    org.apache.geronimo.kernel.config.LifecycleResults lcresult = configurationManager.startConfiguration(configId);
                     messageStatus = "Started application<br /><br />";
+                    this.printResults(lcresult.getStarted(), action);
                 }
             } else if (STOP_ACTION.equals(action)) {
                 if(configurationManager.isRunning(configId)) {
                     configurationManager.stopConfiguration(configId);
                 }
                 if(configurationManager.isLoaded(configId)) {
-                    configurationManager.unloadConfiguration(configId);
+                    LifecycleResults lcresult = configurationManager.unloadConfiguration(configId);
                     messageStatus = "Stopped application<br /><br />";
+                    this.printResults(lcresult.getUnloaded(), action);
                 }
             } else if (UNINSTALL_ACTION.equals(action)) {
                 configurationManager.uninstallConfiguration(configId);
-                messageStatus = "Uninstalled application<br /><br />";
+                messageStatus = "Uninstalled application<br /><br />"+configId+"<br
/><br />";                
             } else if (RESTART_ACTION.equals(action)) {
-                configurationManager.restartConfiguration(configId);
+                LifecycleResults lcresult = configurationManager.restartConfiguration(configId);
                 messageStatus = "Restarted application<br /><br />";
+                this.printResults(lcresult.getStarted(), START_ACTION);
             } else {
                 messageStatus = "Invalid value for changeState: " + action + "<br /><br
/>";
                 throw new PortletException("Invalid value for changeState: " + action);

Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java?view=diff&rev=537224&r1=537223&r2=537224
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
(original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StartCommand.java
Fri May 11 09:25:51 2007
@@ -64,7 +64,7 @@
                     }
 
                     // Start
-                    configurationManager.startConfiguration(moduleID);
+                    org.apache.geronimo.kernel.config.LifecycleResults lcresult = configurationManager.startConfiguration(moduleID);
 
                     // Determine the child modules of the configuration
                     //TODO might be a hack
@@ -85,6 +85,30 @@
                         }
                     }
                     addModule(id);
+                    java.util.Iterator iterator = lcresult.getStarted().iterator();
+                    while (iterator.hasNext()) {
+                        Artifact config = (Artifact)iterator.next();
+                        if (!config.toString().equals(id.getModuleID())) {
+                            //TODO might be a hack
+                            List kidsChild = loadChildren(kernel, config.toString());
+
+                            // Build a response obect containg the started configuration
and a list of it's contained modules
+                            TargetModuleIDImpl idChild = new TargetModuleIDImpl(null, config.toString(),
+                                    (String[]) kidsChild.toArray(new String[kidsChild.size()]));
+                            if (isWebApp(kernel, config.toString())) {
+                                idChild.setType(ModuleType.WAR);
+                            }
+                            if (idChild.getChildTargetModuleID() != null) {
+                                for (int k = 0; k < idChild.getChildTargetModuleID().length;
k++) {
+                                    TargetModuleIDImpl child = (TargetModuleIDImpl) idChild.getChildTargetModuleID()[k];
+                                    if (isWebApp(kernel, child.getModuleID())) {
+                                        child.setType(ModuleType.WAR);
+                                    }
+                                }
+                            }
+                            addModule(idChild);                            
+                        }
+                    }
                 }
             } finally {
                 ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);

Modified: geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java?view=diff&rev=537224&r1=537223&r2=537224
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
(original)
+++ geronimo/server/trunk/modules/geronimo-deploy-jsr88/src/main/java/org/apache/geronimo/deployment/plugin/local/StopCommand.java
Fri May 11 09:25:51 2007
@@ -17,12 +17,15 @@
 
 package org.apache.geronimo.deployment.plugin.local;
 
+import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
 import org.apache.geronimo.kernel.repository.Artifact;
 
+import java.util.List;
 import javax.enterprise.deploy.shared.CommandType;
+import javax.enterprise.deploy.shared.ModuleType;
 import javax.enterprise.deploy.spi.TargetModuleID;
 
 /**
@@ -41,22 +44,58 @@
     public void run() {
         try {
             ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
+            int alreadyStopped = 0;
+
             try {
                 for (int i = 0; i < modules.length; i++) {
                     TargetModuleID module = modules[i];
                     Artifact moduleID = Artifact.create(module.getModuleID());
-                    if(configurationManager.isRunning(moduleID)) {
-                        configurationManager.stopConfiguration(moduleID);
+                    org.apache.geronimo.kernel.config.LifecycleResults lcresult = null;
+
+                    if (configurationManager.isRunning(moduleID)) {
+                        lcresult = configurationManager.stopConfiguration(moduleID);
+                        addModule(module);
+                    } else {
+                        updateStatus("Module " + moduleID + " is already stopped");
+                        alreadyStopped++;
                     }
-                    if(configurationManager.isLoaded(moduleID)) {
+
+                    if (configurationManager.isLoaded(moduleID)) {
                         configurationManager.unloadConfiguration(moduleID);
-                        addModule(module);
+                    }
+
+                    if (lcresult != null) {
+                        java.util.Iterator iterator = lcresult.getStopped().iterator();
+                        while (iterator.hasNext()) {
+                            Artifact config = (Artifact)iterator.next();
+                            if (!config.toString().equals(module.getModuleID())) {
+                                //TODO might be a hack
+                                List kidsChild = loadChildren(kernel, config.toString());
+                                //this.updateStatus("printing kidsChild="+kidsChild);
+                                //this.updateStatus("printing config="+config.toString());
+                                // Build a response obect containg the started configuration
and a list of it's contained modules
+                                TargetModuleIDImpl idChild = new TargetModuleIDImpl(null,
config.toString(),
+                                        (String[]) kidsChild.toArray(new String[kidsChild.size()]));
+                                if (isWebApp(kernel, config.toString())) {
+                                    idChild.setType(ModuleType.WAR);
+                                }
+                                if (idChild.getChildTargetModuleID() != null) {
+                                    for (int k = 0; k < idChild.getChildTargetModuleID().length;
k++) {
+                                        TargetModuleIDImpl child = (TargetModuleIDImpl) idChild.getChildTargetModuleID()[k];
+                                        if (isWebApp(kernel, child.getModuleID())) {
+                                            child.setType(ModuleType.WAR);
+                                        }
+                                    }
+                                }
+                                addModule(idChild);
+                            }
+                        }
                     }
                 }
             } finally {
                 ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
             }
-            if(getModuleCount() < modules.length) {
+            if ((getModuleCount() + alreadyStopped) < modules.length) {
                 fail("Some modules could not be stopped");
             } else {
                 complete("Completed");

Modified: geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java?view=diff&rev=537224&r1=537223&r2=537224
==============================================================================
--- geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java
(original)
+++ geronimo/server/trunk/modules/geronimo-deploy-tool/src/main/java/org/apache/geronimo/deployment/cli/CommandStart.java
Fri May 11 09:25:51 2007
@@ -59,11 +59,23 @@
         out.println();
         for(int i = 0; i < done.length; i++) {
             TargetModuleID id = done[i];
-            out.print(DeployUtils.reformat(getAction()+" "+id.getModuleID()+(multiple ? "
on "+id.getTarget().getName() : "")+(id.getWebURL() == null || !getAction().equals("Started")
? "" : " @ "+id.getWebURL()),4, 72));
+            out.print(DeployUtils.reformat(getAction()+" "+id.getModuleID()+((multiple &&
id.getTarget() != null) ? " on "+ id.getTarget().getName() : "")+(id.getWebURL() == null ||
!getAction().equals("Started") ? "" : " @ "+id.getWebURL()),4, 72));
             if(id.getChildTargetModuleID() != null) {
                 for (int j = 0; j < id.getChildTargetModuleID().length; j++) {
                     TargetModuleID child = id.getChildTargetModuleID()[j];
-                    out.print(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL()
== null || !getAction().equals("Started") ? "" : " @ "+child.getWebURL()),4, 72));
+                    out.print(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL()
== null || getAction().toLowerCase().indexOf("started") == -1 ? "" : " @ "+child.getWebURL()),4,
72));
+                }
+            } // Also print childs if existing in earlier configuration
+            else{
+                java.util.Iterator iterator = DeployUtils.identifyTargetModuleIDs(allModules,
id.getModuleID(), false).iterator();
+                if(iterator.hasNext()){
+                    TargetModuleID childs = (TargetModuleID)iterator.next();
+                    if(childs.getChildTargetModuleID() != null) {
+                        for (int j = 0; j < childs.getChildTargetModuleID().length; j++)
{
+                            TargetModuleID child = childs.getChildTargetModuleID()[j];
+                            out.print(DeployUtils.reformat("  `-> "+child.getModuleID()+(child.getWebURL()
== null || getAction().toLowerCase().indexOf("started") == -1 ? "" : " @ "+child.getWebURL()),4,
72));
+                        }
+                    }
                 }
             }
             out.println();



Mime
View raw message