geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r329605 - in /geronimo/trunk/modules: jetty/src/java/org/apache/geronimo/jetty/ management/src/java/org/apache/geronimo/management/geronimo/ system/src/java/org/apache/geronimo/system/main/ tomcat/src/java/org/apache/geronimo/tomcat/
Date Sun, 30 Oct 2005 19:46:15 GMT
Author: ammulder
Date: Sun Oct 30 11:46:07 2005
New Revision: 329605

URL: http://svn.apache.org/viewcvs?rev=329605&view=rev
Log:
Web apps now know what container they're from.
Startup output now uses that to print the correct URL even if multiple
  containers are available.

Modified:
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
    geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/WebContainer.java
    geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/WebModule.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java?rev=329605&r1=329604&r2=329605&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
Sun Oct 30 11:46:07 2005
@@ -36,11 +36,29 @@
 public class JettyContainerImpl implements JettyContainer, SoapHandler, GBeanLifecycle {
     private final Server server;
     private final Map webServices = new HashMap();
+    private final String objectName;
 
-    public JettyContainerImpl() {
+    public JettyContainerImpl(String objectName) {
+        this.objectName = objectName;
         server = new JettyServer();
     }
 
+    public String getObjectName() {
+        return objectName;
+    }
+
+    public boolean isStateManageable() {
+        return true;
+    }
+
+    public boolean isStatisticsProvider() {
+        return false; // todo: return true once stats are integrated
+    }
+
+    public boolean isEventProvider() {
+        return true;
+    }
+
     public void resetStatistics() {
         server.statsReset();
     }
@@ -205,9 +223,11 @@
         infoBuilder.addOperation("addRealm", new Class[]{UserRealm.class});
         infoBuilder.addOperation("removeRealm", new Class[]{UserRealm.class});
 
+        infoBuilder.addAttribute("objectName", String.class, false);
+
         infoBuilder.addInterface(SoapHandler.class);
         infoBuilder.addInterface(JettyContainer.class);
-        infoBuilder.setConstructor(new String[]{});
+        infoBuilder.setConstructor(new String[]{"objectName"});
 
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java?rev=329605&r1=329604&r2=329605&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
Sun Oct 30 11:46:07 2005
@@ -291,6 +291,10 @@
         return true;
     }
 
+    public String getContainerName() {
+        return jettyContainer.getObjectName();
+    }
+
     public Object enterContextScope(HttpRequest httpRequest, HttpResponse httpResponse) {
         Object[] context = new Object[contextLength];
         chain.before(context, httpRequest, httpResponse);

Modified: geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/WebContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/WebContainer.java?rev=329605&r1=329604&r2=329605&view=diff
==============================================================================
--- geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/WebContainer.java
(original)
+++ geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/WebContainer.java
Sun Oct 30 11:46:07 2005
@@ -16,11 +16,13 @@
  */
 package org.apache.geronimo.management.geronimo;
 
+import org.apache.geronimo.management.J2EEManagedObject;
+
 /**
  * The common configuration settings for a web container (currently, Tomcat or
  * Jetty).
  *
  * @version $Rev: 46019 $ $Date: 2004-09-14 05:56:06 -0400 (Tue, 14 Sep 2004) $
  */
-public interface WebContainer {
+public interface WebContainer extends J2EEManagedObject {
 }

Modified: geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/WebModule.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/WebModule.java?rev=329605&r1=329604&r2=329605&view=diff
==============================================================================
--- geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/WebModule.java
(original)
+++ geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/WebModule.java
Sun Oct 30 11:46:07 2005
@@ -26,4 +26,10 @@
      * Gets the web context for this web app.
      */
     public String getContextPath();
+
+    /**
+     * Gets the ObjectName of the WebContainer that's hosting this
+     * WebModule.
+     */
+    public String getContainerName();
 }

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java?rev=329605&r1=329604&r2=329605&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java
(original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/main/ProgressBarStartupMonitor.java
Sun Oct 30 11:46:07 2005
@@ -1,13 +1,7 @@
 package org.apache.geronimo.system.main;
 
 import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Collections;
+import java.util.*;
 import java.net.URI;
 import java.net.InetSocketAddress;
 import javax.management.ObjectName;
@@ -147,9 +141,9 @@
         out.println();
 
         List apps = new ArrayList();  // type = String (message)
-        List webs = new ArrayList();  // type = String (context path)
+        List webs = new ArrayList();  // type = WebAppInfo
         List ports = new ArrayList(); // type = AddressHolder
-        Map connectors = new HashMap();
+        Map containers = new HashMap();
         Map failed = new HashMap();   // key = ObjectName, value = String (message)
         String serverInfo = null;
         try {
@@ -161,7 +155,10 @@
                     apps.add("    "+decodeModule(name.getKeyProperty("j2eeType"))+": "+name.getKeyProperty("name"));
                 }
                 if(isWebModule(name)) {
-                    webs.add(kernel.getAttribute(name, "contextPath"));
+                    String webAppName = name.getCanonicalName();
+                    String context = (String) kernel.getAttribute(name, "contextPath");
+                    String containerName = (String) kernel.getAttribute(name, "containerName");
+                    webs.add(new WebAppInfo(containerName, webAppName, context));
                 }
 
                 int stateValue = kernel.getGBeanState(name);
@@ -228,12 +225,29 @@
                     }
                 }
             }
-            Set set = kernel.listGBeans(new GBeanQuery(null, "org.apache.geronimo.management.geronimo.WebConnector"));
+            // Look up a URL for each WebContainer in the server (Manager -< Container
-< Connector)
+            Set set = kernel.listGBeans(new GBeanQuery(null, "org.apache.geronimo.management.geronimo.WebManager"));
             for (Iterator it = set.iterator(); it.hasNext();) {
-                ObjectName name = (ObjectName) it.next();
-                String protocol = (String) kernel.getAttribute(name, "protocol");
-                String url = (String) kernel.getAttribute(name, "connectUrl");
-                connectors.put(protocol, url);
+                ObjectName mgrName = (ObjectName) it.next();
+                String[] cntNames = (String[]) kernel.getAttribute(mgrName, "containers");
+                for (int i = 0; i < cntNames.length; i++) {
+                    String cntName = cntNames[i];
+                    String[] cncNames = (String[]) kernel.invoke(mgrName, "getConnectorsForContainer",
new Object[]{cntName}, new String[]{"java.lang.String"});
+                    Map map = new HashMap();
+                    for (int j = 0; j < cncNames.length; j++) {
+                        ObjectName cncName = ObjectName.getInstance(cncNames[j]);
+                        String protocol = (String) kernel.getAttribute(cncName, "protocol");
+                        String url = (String) kernel.getAttribute(cncName, "connectUrl");
+                        map.put(protocol, url);
+                    }
+                    String urlPrefix = "";
+                    if((urlPrefix = (String) map.get("HTTP")) == null) {
+                        if((urlPrefix = (String) map.get("HTTPS")) == null) {
+                            urlPrefix = (String) map.get("AJP");
+                        }
+                    }
+                    containers.put(cntName, urlPrefix);
+                }
             }
         } catch (MalformedObjectNameException e) {
             e.printStackTrace();
@@ -244,12 +258,6 @@
         } catch (Exception e) { // required by Kernel.getAttribute
             e.printStackTrace();
         }
-        String urlPrefix = "";
-        if((urlPrefix = (String) connectors.get("HTTP")) == null) {
-            if((urlPrefix = (String) connectors.get("HTTPS")) == null) {
-                urlPrefix = (String) connectors.get("AJP");
-            }
-        }
 
         // Helpful output: list of ports we listen on
         if(ports.size() > 0) {
@@ -288,6 +296,7 @@
                 buf.append(holder.getName());
                 out.println(buf.toString());
             }
+            out.println();
         }
         // Helpful output: list of applications started
         if(apps.size() > 0) {
@@ -295,15 +304,17 @@
             for (int i = 0; i < apps.size(); i++) {
                 out.println((String)apps.get(i));
             }
+            out.println();
         }
         // Helpful output: Web URLs
         if(webs.size() > 0) {
             Collections.sort(webs);
             out.println("  Web Applications:");
             for (int i = 0; i < webs.size(); i++) {
-                String context = (String) webs.get(i);
-                out.println("    "+urlPrefix+context);
+                WebAppInfo app = (WebAppInfo) webs.get(i);
+                out.println("    "+containers.get(app.getContainerObjectName())+app.getContext());
             }
+            out.println();
         }
 
         // Helpful output: list of GBeans that did not start
@@ -319,6 +330,7 @@
                     out.println("    "+name+" "+state);
                 }
             }
+            out.println();
         }
 
         StringBuffer msg = new StringBuffer();
@@ -488,6 +500,58 @@
                 repaint();
             }
             wrapUp();
+        }
+    }
+
+    private static class WebAppInfo implements Comparable {
+        private String containerObjectName;
+        private String webAppObjectName;
+        private String context;
+
+        public WebAppInfo(String containerObjectName, String webAppObjectName, String context)
{
+            this.containerObjectName = containerObjectName;
+            this.webAppObjectName = webAppObjectName;
+            this.context = context;
+        }
+
+        public String getContainerObjectName() {
+            return containerObjectName;
+        }
+
+        public String getWebAppObjectName() {
+            return webAppObjectName;
+        }
+
+        public String getContext() {
+            return context;
+        }
+
+        public boolean equals(Object o) {
+            if (this == o) return true;
+            if (!(o instanceof WebAppInfo)) return false;
+
+            final WebAppInfo webAppInfo = (WebAppInfo) o;
+
+            if (!containerObjectName.equals(webAppInfo.containerObjectName)) return false;
+            if (!context.equals(webAppInfo.context)) return false;
+            if (!webAppObjectName.equals(webAppInfo.webAppObjectName)) return false;
+
+            return true;
+        }
+
+        public int hashCode() {
+            int result;
+            result = containerObjectName.hashCode();
+            result = 29 * result + webAppObjectName.hashCode();
+            result = 29 * result + context.hashCode();
+            return result;
+        }
+
+        public int compareTo(Object o) {
+            WebAppInfo other = (WebAppInfo) o;
+            int test = containerObjectName.compareTo(other.containerObjectName);
+            if(test != 0) return test;
+            return context.compareTo(other.context);
         }
     }
 }

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=329605&r1=329604&r2=329605&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
Sun Oct 30 11:46:07 2005
@@ -77,16 +77,18 @@
     private ClassLoader classLoader;
 
     private final Map webServices = new HashMap();
+    private final String objectName;
 
     // Required as it's referenced by deployed webapps
     public TomcatContainer() {
+        this.objectName = null; // is this OK??
         setCatalinaHome(DEFAULT_CATALINA_HOME);
     }
 
     /**
      * GBean constructor (invoked dynamically when the gbean is declared in a plan)
      */
-    public TomcatContainer(ClassLoader classLoader, String catalinaHome, ObjectRetriever
engineGBean, ServerInfo serverInfo) {
+    public TomcatContainer(ClassLoader classLoader, String catalinaHome, ObjectRetriever
engineGBean, ServerInfo serverInfo, String objectName) {
         if (catalinaHome == null)
             catalinaHome = DEFAULT_CATALINA_HOME;
 
@@ -103,6 +105,24 @@
         this.classLoader = classLoader;
 
         this.engine = (Engine)engineGBean.getInternalObject();
+
+        this.objectName = objectName;
+    }
+
+    public String getObjectName() {
+        return objectName;
+    }
+
+    public boolean isStateManageable() {
+        return true;
+    }
+
+    public boolean isStatisticsProvider() {
+        return false; // todo: return true once stats are integrated
+    }
+
+    public boolean isEventProvider() {
+        return true;
     }
 
     public void doFail() {
@@ -365,11 +385,13 @@
     static {
         GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("Tomcat Web Container", TomcatContainer.class);
 
-        infoFactory.setConstructor(new String[] { "classLoader", "catalinaHome", "EngineGBean",
"ServerInfo"});
+        infoFactory.setConstructor(new String[] { "classLoader", "catalinaHome", "EngineGBean",
"ServerInfo", "objectName"});
 
         infoFactory.addAttribute("classLoader", ClassLoader.class, false);
 
         infoFactory.addAttribute("catalinaHome", String.class, true);
+
+        infoFactory.addAttribute("objectName", String.class, false);
 
         infoFactory.addReference("EngineGBean", ObjectRetriever.class, NameFactory.GERONIMO_SERVICE);
 

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?rev=329605&r1=329604&r2=329605&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
Sun Oct 30 11:46:07 2005
@@ -234,6 +234,10 @@
         return true;
     }
 
+    public String getContainerName() {
+        return container.getObjectName();
+    }
+
     public String getServer() {
         return server.getObjectName();
     }



Mime
View raw message