geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r398234 - in /geronimo/branches/1.1/applications/console-standard/src: java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java webapp/WEB-INF/view/configmanager/normal.jsp
Date Sat, 29 Apr 2006 20:52:39 GMT
Author: ammulder
Date: Sat Apr 29 13:52:38 2006
New Revision: 398234

URL: http://svn.apache.org/viewcvs?rev=398234&view=rev
Log:
Show web app context-root in console (GERONIMO-1376).  Thanks for patch!

Modified:
    geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
    geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/configmanager/normal.jsp

Modified: geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java?rev=398234&r1=398233&r2=398234&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
(original)
+++ geronimo/branches/1.1/applications/console-standard/src/java/org/apache/geronimo/console/configmanager/ConfigManagerPortlet.java
Sat Apr 29 13:52:38 2006
@@ -18,9 +18,10 @@
 package org.apache.geronimo.console.configmanager;
 
 import java.io.IOException;
+import java.io.Serializable;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 import javax.portlet.ActionRequest;
@@ -31,16 +32,19 @@
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.WindowState;
-
 import org.apache.geronimo.console.BasePortlet;
+import org.apache.geronimo.console.util.PortletManager;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelRegistry;
 import org.apache.geronimo.kernel.config.ConfigurationInfo;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
-import org.apache.geronimo.kernel.config.NoSuchConfigException;
 import org.apache.geronimo.kernel.config.LifecycleException;
+import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.management.State;
 import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.management.geronimo.WebModule;
 
 public class ConfigManagerPortlet extends BasePortlet {
 
@@ -125,24 +129,28 @@
             return;
         }
 
-        List configInfo = new ArrayList();
+        List moduleDetails = new ArrayList();
         ConfigurationManager configManager = ConfigurationUtil.getConfigurationManager(kernel);
         List infos = configManager.listConfigurations();
         for (Iterator j = infos.iterator(); j.hasNext();) {
             ConfigurationInfo info = (ConfigurationInfo) j.next();
             if (shouldListConfig(info)) {
-                configInfo.add(info);
+                ModuleDetails details = new ModuleDetails(info.getConfigID(), info.getType(),
info.getState());
+
+                if (info.getType().getValue()== ConfigurationModuleType.WAR.getValue()){
+                    WebModule webModule = (WebModule) PortletManager.getModule(renderRequest,
info.getConfigID());
+                    if (webModule != null) {
+                        details.setContextPath(webModule.getContextPath());
+                        details.setUrlFor(webModule.getURLFor());
+                    }
+                }
+                moduleDetails.add(details);
             }
         }
-        Collections.sort(configInfo, new Comparator() {
-            public int compare(Object o1, Object o2) {
-                ConfigurationInfo ci1 = (ConfigurationInfo) o1;
-                ConfigurationInfo ci2 = (ConfigurationInfo) o2;
-                return ci1.getConfigID().toString().compareTo(ci2.getConfigID().toString());
-            }
-        });
-        renderRequest.setAttribute("configurations", configInfo);
-        if (configInfo.size() == 0) {
+        Collections.sort(moduleDetails);
+        renderRequest.setAttribute("configurations", moduleDetails);
+        renderRequest.setAttribute("showWebInfo", Boolean.valueOf(getInitParameter(CONFIG_INIT_PARAM).equalsIgnoreCase(ConfigurationModuleType.WAR.getName())));
+        if (moduleDetails.size() == 0) {
             renderRequest.setAttribute("messageInstalled", "No modules found of this type<br
/><br />");
         } else {
             renderRequest.setAttribute("messageInstalled", "");
@@ -173,5 +181,59 @@
         maximizedView = null;
         kernel = null;
         super.destroy();
+    }
+
+    /**
+     * Convenience data holder for portlet that displays deployed modules.
+     * Includes context path information for web modules.
+     */
+    public static class ModuleDetails implements Comparable, Serializable {
+        private final Artifact configId;
+        private final ConfigurationModuleType type;
+        private final State state;
+        private URL urlFor;             // only relevant for webapps
+        private String contextPath;     // only relevant for webapps
+
+        public ModuleDetails(Artifact configId, ConfigurationModuleType type, State state)
{
+            this.configId = configId;
+            this.type = type;
+            this.state = state;
+        }
+
+        public int compareTo(Object o) {
+            if (o != null && o instanceof ModuleDetails){
+                return configId.compareTo(((ModuleDetails)o).configId);
+            } else {
+                return -1;
+            }
+        }
+
+        public Artifact getConfigId() {
+            return configId;
+        }
+
+        public State getState() {
+            return state;
+        }
+
+        public URL getUrlFor() {
+            return urlFor;
+        }
+
+        public String getContextPath() {
+            return contextPath;
+        }
+
+        public void setUrlFor(URL urlFor) {
+            this.urlFor = urlFor;
+        }
+
+        public void setContextPath(String contextPath) {
+            this.contextPath = contextPath;
+        }
+
+        public ConfigurationModuleType getType() {
+            return type;
+        }
     }
 }

Modified: geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/configmanager/normal.jsp
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/configmanager/normal.jsp?rev=398234&r1=398233&r2=398234&view=diff
==============================================================================
--- geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/configmanager/normal.jsp
(original)
+++ geronimo/branches/1.1/applications/console-standard/src/webapp/WEB-INF/view/configmanager/normal.jsp
Sat Apr 29 13:52:38 2006
@@ -6,10 +6,13 @@
 <br />
 <table width="100%">
     <tr class="DarkBackground">
-        <th align="left">&nbsp;Component Name</th><th>&nbsp;State</th><th
align="center" colspan="2">Commands</th>
+        <th align="left">&nbsp;Component Name</th>
+        <c:if test="${showWebInfo}"><th>URL</th></c:if>
+        <th>&nbsp;State</th>
+        <th align="center" colspan="2">Commands</th>
     </tr>
   <c:set var="backgroundClass" value='MediumBackground'/>
-  <c:forEach var="configInfo" items="${configurations}">
+  <c:forEach var="moduleDetails" items="${configurations}">
         <c:choose>
             <c:when test="${backgroundClass == 'MediumBackground'}" >
                 <c:set var="backgroundClass" value='LightBackground'/>
@@ -19,15 +22,18 @@
             </c:otherwise>
         </c:choose>
     <tr>
-        <td class="${backgroundClass}">&nbsp;${configInfo.configID}</td>
-        <td width="100" class="${backgroundClass}">&nbsp;${configInfo.state}</td>
+        <td class="${backgroundClass}">&nbsp;${moduleDetails.configId}</td>
+        <c:if test="${showWebInfo}">
+            <td class="${backgroundClass}">&nbsp;<c:if test="${moduleDetails.state.running}"><a
href="${moduleDetails.urlFor}">${moduleDetails.contextPath}</a></c:if></td>
+        </c:if>
+        <td width="100" class="${backgroundClass}">&nbsp;${moduleDetails.state}</td>
         <td width="100" class="${backgroundClass}">
-<c:if test="${configInfo.state.running}">&nbsp;<a href="<portlet:actionURL><portlet:param
name="configId" value="${configInfo.configID}"/><portlet:param name="action" value="stop"/></portlet:actionURL>">Stop</a></c:if>
-<c:if test="${configInfo.state.stopped && (configInfo.type.name ne 'CAR')}">&nbsp;<a
href="<portlet:actionURL><portlet:param name="configId" value="${configInfo.configID}"/><portlet:param
name="action" value="start"/></portlet:actionURL>">Start</a></c:if>
-<c:if test="${configInfo.state.failed}">&nbsp;<a href="<portlet:actionURL><portlet:param
name="configId" value="${configInfo.configID}"/><portlet:param name="action" value="stop"/></portlet:actionURL>">Stop</a></c:if>
+            <c:if test="${moduleDetails.state.running}">&nbsp;<a href="<portlet:actionURL><portlet:param
name="configId" value="${moduleDetails.configId}"/><portlet:param name="action" value="stop"/></portlet:actionURL>">Stop</a></c:if>
+            <c:if test="${moduleDetails.state.stopped && (moduleDetails.type.name
ne 'CAR')}">&nbsp;<a href="<portlet:actionURL><portlet:param name="configId"
value="${moduleDetails.configId}"/><portlet:param name="action" value="start"/></portlet:actionURL>">Start</a></c:if>
+            <c:if test="${moduleDetails.state.failed}">&nbsp;<a href="<portlet:actionURL><portlet:param
name="configId" value="${moduleDetails.configId}"/><portlet:param name="action" value="stop"/></portlet:actionURL>">Stop</a></c:if>
         </td>
         <td width="100" class="${backgroundClass}">
-            <a href="<portlet:actionURL><portlet:param name="configId" value="${configInfo.configID}"/><portlet:param
name="action" value="uninstall"/></portlet:actionURL>">Uninstall</a>
+            <a href="<portlet:actionURL><portlet:param name="configId" value="${moduleDetails.configId}"/><portlet:param
name="action" value="uninstall"/></portlet:actionURL>">Uninstall</a>
         </td>
     </tr>
   </c:forEach>



Mime
View raw message