geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r396767 - in /geronimo/branches/1.1: configs/activemq-broker/src/plan/ configs/jetty/src/plan/ configs/tomcat/src/plan/ modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/ modules/deployment/src/java/org/apache/geroni...
Date Tue, 25 Apr 2006 04:07:56 GMT
Author: ammulder
Date: Mon Apr 24 21:07:54 2006
New Revision: 396767

URL: http://svn.apache.org/viewcvs?rev=396767&view=rev
Log:
Consolidate all the code for web URLs into where it ought to be --
  the WebModule and WebContainer.

Added:
    geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/NetworkContainer.java
Modified:
    geronimo/branches/1.1/configs/activemq-broker/src/plan/plan.xml
    geronimo/branches/1.1/configs/jetty/src/plan/plan.xml
    geronimo/branches/1.1/configs/tomcat/src/plan/plan.xml
    geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
    geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
    geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
    geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyManagerImpl.java
    geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
    geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/JMSBroker.java
    geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebContainer.java
    geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebManager.java
    geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebModule.java
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/StartupMonitorUtil.java
    geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
    geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
    geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java

Modified: geronimo/branches/1.1/configs/activemq-broker/src/plan/plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/configs/activemq-broker/src/plan/plan.xml?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/configs/activemq-broker/src/plan/plan.xml (original)
+++ geronimo/branches/1.1/configs/activemq-broker/src/plan/plan.xml Mon Apr 24 21:07:54 2006
@@ -23,13 +23,16 @@
 
 
     <!-- management -->
-    <gbean name="ActiveMQ" class="org.activemq.gbean.management.ActiveMQManagerGBean"
/>
+    <gbean name="ActiveMQManager" class="org.activemq.gbean.management.ActiveMQManagerGBean"
/>
 
     <!-- message broker -->
     <gbean name="ActiveMQ" class="org.activemq.gbean.ActiveMQContainerGBean">
         <attribute name="brokerName">possibly-unique-broker</attribute>
         <reference name="persistenceAdapter">
             <name>ActiveMQ.cache</name>
+        </reference>
+        <reference name="JMSManager">
+            <name>ActiveMQManager</name>
         </reference>
     </gbean>
 

Modified: geronimo/branches/1.1/configs/jetty/src/plan/plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/configs/jetty/src/plan/plan.xml?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/configs/jetty/src/plan/plan.xml (original)
+++ geronimo/branches/1.1/configs/jetty/src/plan/plan.xml Mon Apr 24 21:07:54 2006
@@ -48,6 +48,9 @@
 
     <!-- default WAR container using Jetty -->
     <gbean name="JettyWebContainer" class="org.apache.geronimo.jetty.JettyContainerImpl">
+      <reference name="WebManager">
+        <name>JettyWebManager</name>
+      </reference>
     </gbean>
 
     <gbean name="JettyRequestLog" class="org.apache.geronimo.jetty.requestlog.NCSARequestLog">

Modified: geronimo/branches/1.1/configs/tomcat/src/plan/plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/configs/tomcat/src/plan/plan.xml?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/configs/tomcat/src/plan/plan.xml (original)
+++ geronimo/branches/1.1/configs/tomcat/src/plan/plan.xml Mon Apr 24 21:07:54 2006
@@ -51,6 +51,9 @@
         <reference name="ServerInfo">
             <name>ServerInfo</name>
         </reference>
+        <reference name="WebManager">
+            <name>TomcatWebManager</name>
+        </reference>
     </gbean>
 
     <gbean name="TomcatWebConnector" class="org.apache.geronimo.tomcat.ConnectorGBean">

Modified: geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
(original)
+++ geronimo/branches/1.1/modules/deploy-jsr88/src/java/org/apache/geronimo/deployment/plugin/local/CommandSupport.java
Mon Apr 24 21:07:54 2006
@@ -17,14 +17,16 @@
 
 package org.apache.geronimo.deployment.plugin.local;
 
-import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
-import org.apache.geronimo.deployment.plugin.jmx.CommandContext;
-import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.kernel.InternalKernelException;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.config.ConfigurationModuleType;
-
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import javax.enterprise.deploy.shared.ActionType;
 import javax.enterprise.deploy.shared.CommandType;
 import javax.enterprise.deploy.shared.ModuleType;
@@ -36,17 +38,13 @@
 import javax.enterprise.deploy.spi.status.ProgressEvent;
 import javax.enterprise.deploy.spi.status.ProgressListener;
 import javax.enterprise.deploy.spi.status.ProgressObject;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import org.apache.geronimo.deployment.plugin.TargetModuleIDImpl;
+import org.apache.geronimo.deployment.plugin.jmx.CommandContext;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.kernel.InternalKernelException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
 
 /**
  * @version $Rev$ $Date$
@@ -285,13 +283,6 @@
      */
     public static void addWebURLs(Kernel kernel, List moduleIDs) {
         Set webApps = null;
-        Map containers;
-        try {
-            containers = mapContainersToURLs(kernel);
-        } catch (Exception e) {
-            e.printStackTrace();
-            containers = Collections.EMPTY_MAP;
-        }
         for (int i = 0; i < moduleIDs.size(); i++) {
             TargetModuleIDImpl id = (TargetModuleIDImpl) moduleIDs.get(i);
             if(id.getType() != null && id.getType().getValue() == ModuleType.WAR.getValue())
{
@@ -302,9 +293,7 @@
                     AbstractName name = (AbstractName) it.next();
                     if(name.getName().get("name").equals(id.getModuleID())) {
                         try {
-                            String container = (String) kernel.getAttribute(name, "containerName");
-                            String context = (String) kernel.getAttribute(name, "contextPath");
-                            id.setWebURL(containers.get(container)+context);
+                            id.setWebURL(kernel.getAttribute(name, "URLFor").toString());
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
@@ -355,26 +344,5 @@
             kids.add(childName);
         }
         return kids;
-    }
-
-    /**
-     * Generates a Map where the keys are web container object names (as Strings)
-     * and the values are URLs (as Strings) to connect to a web app running in
-     * the matching container (though the web app context needs to be added to
-     * the end to be complete).
-     *
-     * NOTE: same as a method in geronimo-system WebAppUtil, but neither
-     *       module should obviously be dependent on the other and it's not
-     *       clear that this belongs in geronimo-common
-     */
-    public static Map mapContainersToURLs(Kernel kernel) throws Exception {
-        Map containers = new HashMap();
-        Set set = kernel.listGBeans(new AbstractNameQuery("org.apache.geronimo.management.geronimo.WebManager"));
-        for (Iterator it = set.iterator(); it.hasNext();) {
-            AbstractName manager = (AbstractName) it.next();
-            Map results = (Map)kernel.invoke(manager, "mapContainersToURLs");
-            containers.putAll(results);
-        }
-        return containers;
     }
 }

Modified: geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
(original)
+++ geronimo/branches/1.1/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
Mon Apr 24 21:07:54 2006
@@ -173,47 +173,11 @@
                 return null;
             }
             AbstractName module = (AbstractName) names.iterator().next();
-
-            String containerName = (String) kernel.getAttribute(module, "containerName");
-            String contextPath = (String) kernel.getAttribute(module, "contextPath");
-            String urlPrefix = getURLFor(containerName);
-            return urlPrefix + contextPath + "/upload";
+            return kernel.getAttribute(module, "URLFor") + "/upload";
         } catch (Exception e) {
             log.error("Unable to look up remote deploy upload URL", e);
             return null;
         }
-    }
-
-    /**
-     * Given a web container ObjectName, constructs a URL to point to it.
-     * Currently favors HTTP then HTTPS and ignores AJP (since AJP
-     * means it goes through a web server listening on an unknown port).
-     */
-    private String getURLFor(String containerName) throws Exception {
-        Set set = kernel.listGBeans(new AbstractNameQuery("org.apache.geronimo.management.geronimo.WebManager"));
-        for (Iterator it = set.iterator(); it.hasNext();) {
-            AbstractName mgrName = (AbstractName) it.next();
-            String[] cntNames = (String[]) kernel.getAttribute(mgrName, "containers");
-            for (int i = 0; i < cntNames.length; i++) {
-                String cntName = cntNames[i];
-                if (cntName.equals(containerName)) {
-                    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) {
-                        urlPrefix = (String) map.get("HTTPS");
-                    }
-                    return urlPrefix;
-                }
-            }
-        }
-        return null;
     }
 
     public List deploy(boolean inPlace,

Modified: geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
(original)
+++ geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyContainerImpl.java
Mon Apr 24 21:07:54 2006
@@ -25,6 +25,8 @@
 import org.apache.geronimo.webservices.SoapHandler;
 import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.geronimo.management.StatisticsProvider;
+import org.apache.geronimo.management.geronimo.WebManager;
+import org.apache.geronimo.management.geronimo.NetworkConnector;
 import org.mortbay.http.HttpContext;
 import org.mortbay.http.HttpListener;
 import org.mortbay.http.RequestLog;
@@ -40,12 +42,14 @@
     private final Server server;
     private final Map webServices = new HashMap();
     private final String objectName;
+    private final WebManager manager;
     private JettyWebContainerStatsImpl stats;
 
-    public JettyContainerImpl(String objectName) {
+    public JettyContainerImpl(String objectName, WebManager manager) {
         this.objectName = objectName;
         server = new JettyServer();
         stats = new JettyWebContainerStatsImpl();
+        this.manager = manager;
     }
 
     public String getObjectName() {
@@ -64,6 +68,14 @@
         return true;
     }
 
+    public NetworkConnector[] getConnectors() {
+        return manager.getConnectorsForContainer(this);
+    }
+
+    public NetworkConnector[] getConnectors(String protocol) {
+        return manager.getConnectorsForContainer(this, protocol);
+    }
+
     public void resetStatistics() {
         server.statsReset();
     }
@@ -212,11 +224,12 @@
         infoBuilder.addOperation("removeRealm", new Class[]{UserRealm.class});
 
         infoBuilder.addAttribute("objectName", String.class, false);
+        infoBuilder.addReference("WebManager", WebManager.class);
 
         infoBuilder.addInterface(SoapHandler.class);
         infoBuilder.addInterface(JettyContainer.class);
         infoBuilder.addInterface(StatisticsProvider.class);
-        infoBuilder.setConstructor(new String[]{"objectName"});
+        infoBuilder.setConstructor(new String[]{"objectName", "WebManager"});
 
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }

Modified: geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyManagerImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyManagerImpl.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyManagerImpl.java
(original)
+++ geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyManagerImpl.java
Mon Apr 24 21:07:54 2006
@@ -17,10 +17,8 @@
 package org.apache.geronimo.jetty;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -278,30 +276,6 @@
         } catch (Exception e) {
             throw (IllegalArgumentException) new IllegalArgumentException("Unable to look
up connectors for Jetty container '"+containerName+"'").initCause(e);
         }
-    }
-
-    public Map mapContainersToURLs() {
-        WebContainer[] webContainers = (WebContainer[]) getContainers();
-        Map results = new HashMap();
-        for (int i = 0; i < webContainers.length; i++) {
-            WebContainer container = webContainers[i];
-            WebConnector[] connectors = (WebConnector[]) getConnectorsForContainer(container);
-            Map map = new HashMap();
-            for (int j = 0; j < connectors.length; j++) {
-                WebConnector connector = connectors[j];
-                String protocol = connector.getProtocol();
-                String url = connector.getConnectUrl();
-                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");
-                }
-            }
-            results.put(kernel.getAbstractNameFor(container).getObjectName().getCanonicalName(),
urlPrefix);
-        }
-        return results;
     }
 
     public static final GBeanInfo GBEAN_INFO;

Modified: geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
(original)
+++ geronimo/branches/1.1/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
Mon Apr 24 21:07:54 2006
@@ -37,6 +37,9 @@
 import org.apache.geronimo.management.J2EEApplication;
 import org.apache.geronimo.management.J2EEServer;
 import org.apache.geronimo.management.geronimo.WebModule;
+import org.apache.geronimo.management.geronimo.WebContainer;
+import org.apache.geronimo.management.geronimo.NetworkConnector;
+import org.apache.geronimo.management.geronimo.WebConnector;
 import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
 import org.apache.geronimo.naming.reference.ClassLoaderAwareReference;
 import org.apache.geronimo.naming.reference.KernelAwareReference;
@@ -60,6 +63,7 @@
 import javax.naming.Context;
 import java.io.IOException;
 import java.net.URL;
+import java.net.MalformedURLException;
 import java.security.PermissionCollection;
 import java.util.Collection;
 import java.util.EventListener;
@@ -68,6 +72,7 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.HashMap;
 
 /**
  * Wrapper for a WebApplicationContext that sets up its J2EE environment.
@@ -160,42 +165,42 @@
     }
 
     public JettyWebAppContext(String objectName,
-            String originalSpecDD,
-            String[] virtualHosts,
-            String sessionManager,
-            Map componentContext,
-            OnlineUserTransaction userTransaction,
-            ClassLoader classLoader,
-            URL configurationBaseUrl,
-            Set unshareableResources,
-            Set applicationManagedSecurityResources,
-
-            String displayName,
-            Map contextParamMap,
-            Collection listenerClassNames,
-            boolean distributable,
-            Map mimeMap,
-            String[] welcomeFiles,
-            Map localeEncodingMapping,
-            Map errorPages,
-            Authenticator authenticator,
-            String realmName,
-            Map tagLibMap,
-            int sessionTimeoutSeconds,
-
-            String policyContextID,
-            String securityRealmName,
-            DefaultPrincipal defaultPrincipal,
-            PermissionCollection checkedPermissions,
-            PermissionCollection excludedPermissions,
-
-            TransactionContextManager transactionContextManager,
-            TrackedConnectionAssociator trackedConnectionAssociator,
-            JettyContainer jettyContainer,
-            RoleDesignateSource roleDesignateSource,
-            J2EEServer server,
-            J2EEApplication application,
-            Kernel kernel) throws Exception, IllegalAccessException, InstantiationException,
ClassNotFoundException {
+                              String originalSpecDD,
+                              String[] virtualHosts,
+                              String sessionManager,
+                              Map componentContext,
+                              OnlineUserTransaction userTransaction,
+                              ClassLoader classLoader,
+                              URL configurationBaseUrl,
+                              Set unshareableResources,
+                              Set applicationManagedSecurityResources,
+
+                              String displayName,
+                              Map contextParamMap,
+                              Collection listenerClassNames,
+                              boolean distributable,
+                              Map mimeMap,
+                              String[] welcomeFiles,
+                              Map localeEncodingMapping,
+                              Map errorPages,
+                              Authenticator authenticator,
+                              String realmName,
+                              Map tagLibMap,
+                              int sessionTimeoutSeconds,
+
+                              String policyContextID,
+                              String securityRealmName,
+                              DefaultPrincipal defaultPrincipal,
+                              PermissionCollection checkedPermissions,
+                              PermissionCollection excludedPermissions,
+
+                              TransactionContextManager transactionContextManager,
+                              TrackedConnectionAssociator trackedConnectionAssociator,
+                              JettyContainer jettyContainer,
+                              RoleDesignateSource roleDesignateSource,
+                              J2EEServer server,
+                              J2EEApplication application,
+                              Kernel kernel) throws Exception, IllegalAccessException, InstantiationException,
ClassNotFoundException {
 
         assert componentContext != null;
         assert userTransaction != null;
@@ -323,8 +328,32 @@
         }
     }
 
-    public String getContainerName() {
-        return jettyContainer.getObjectName();
+    public WebContainer getContainer() {
+        return jettyContainer;
+    }
+
+    public URL getURLFor() {
+        WebConnector[] connectors = (WebConnector[]) jettyContainer.getConnectors();
+        Map map = new HashMap();
+        for (int i = 0; i < connectors.length; i++) {
+            WebConnector connector = connectors[i];
+            map.put(connector.getProtocol(), connector.getConnectUrl());
+        }
+        String urlPrefix;
+        if((urlPrefix = (String) map.get("HTTP")) == null) {
+            if((urlPrefix = (String) map.get("HTTPS")) == null) {
+                urlPrefix = (String) map.get("AJP");
+            }
+        }
+        if(urlPrefix == null) {
+            return null;
+        }
+        try {
+            return new URL(urlPrefix + getContextPath());
+        } catch (MalformedURLException e) {
+            log.error("Bad URL to connect to web app", e);
+            return null;
+        }
     }
 
     public Object enterContextScope(HttpRequest httpRequest, HttpResponse httpResponse) {

Modified: geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/JMSBroker.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/JMSBroker.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/JMSBroker.java
(original)
+++ geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/JMSBroker.java
Mon Apr 24 21:07:54 2006
@@ -16,12 +16,10 @@
  */
 package org.apache.geronimo.management.geronimo;
 
-import org.apache.geronimo.management.J2EEManagedObject;
-
 /**
  * Represents a JMS broker
  *
  * @version $Rev$ $Date$
  */
-public interface JMSBroker extends J2EEManagedObject {
+public interface JMSBroker extends NetworkContainer {
 }

Added: geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/NetworkContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/NetworkContainer.java?rev=396767&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/NetworkContainer.java
(added)
+++ geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/NetworkContainer.java
Mon Apr 24 21:07:54 2006
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.management.geronimo;
+
+import org.apache.geronimo.management.J2EEManagedObject;
+
+/**
+ * Basic operations for a network container.
+ *
+ * @version $Rev: 355877 $ $Date: 2005-12-10 21:48:27 -0500 (Sat, 10 Dec 2005) $
+ */
+public interface NetworkContainer extends J2EEManagedObject {
+    /**
+     * Gets any existing connectors for this network container for the
+     * specified protocol.
+     *
+     * @param protocol A protocol as returned by getSupportedProtocols
+     */
+    public NetworkConnector[] getConnectors(String protocol);
+
+    /**
+     * Gets any existing connectors associated with this network container.
+     */
+    public NetworkConnector[] getConnectors();
+}

Modified: geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebContainer.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebContainer.java
(original)
+++ geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebContainer.java
Mon Apr 24 21:07:54 2006
@@ -16,13 +16,11 @@
  */
 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$ $Date$
  */
-public interface WebContainer extends J2EEManagedObject {
+public interface WebContainer extends NetworkContainer {
 }

Modified: geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebManager.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebManager.java
(original)
+++ geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebManager.java
Mon Apr 24 21:07:54 2006
@@ -52,12 +52,4 @@
      *
      */
     public WebAccessLog getAccessLog(WebContainer container);
-
-    /**
-     * Generates a Map where the keys are web container object names (as Strings)
-     * and the values are URLs (as Strings) to connect to a web app running in
-     * the matching container (though the web app context needs to be added to
-     * the end to be complete).
-     */
-    public Map mapContainersToURLs();
 }

Modified: geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebModule.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebModule.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebModule.java
(original)
+++ geronimo/branches/1.1/modules/management/src/java/org/apache/geronimo/management/geronimo/WebModule.java
Mon Apr 24 21:07:54 2006
@@ -33,7 +33,14 @@
      * Gets the ObjectName of the WebContainer that's hosting this
      * WebModule.
      */
-    public String getContainerName();
+    public WebContainer getContainer();
+
+    /**
+     * Gets a URL that can be used to access this web application.  Prefers
+     * HTTP if available, then HTTPS, then AJP, depending on what the hosting
+     * web container makes available.
+     */
+    public URL getURLFor();
 
     /**
      * Gets a name for this WAR file that can be used to identify the WAR to a

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/StartupMonitorUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/StartupMonitorUtil.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/StartupMonitorUtil.java
(original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/main/StartupMonitorUtil.java
Mon Apr 24 21:07:54 2006
@@ -46,7 +46,6 @@
         List apps = new ArrayList();  // type = String (message)
         List webs = new ArrayList();  // type = WebAppInfo
         List ports = new ArrayList(); // type = AddressHolder
-        Map containers = new HashMap();
         Map failed = new HashMap();   // key = AbstractName, value = String (message)
         String serverInfo = null;
         try {
@@ -58,9 +57,7 @@
                     apps.add("    " + decodeModule(name.getNameProperty("j2eeType")) + ":
" + name.getNameProperty("name"));
                 }
                 if (isWebModule(name)) {
-                    String context = (String) kernel.getAttribute(name, "contextPath");
-                    String containerName = (String) kernel.getAttribute(name, "containerName");
-                    webs.add(new WebAppInfo(containerName, name, context));
+                    webs.add(kernel.getAttribute(name, "URLFor").toString());
                 }
 
                 int stateValue = kernel.getGBeanState(name);
@@ -127,8 +124,6 @@
                     }
                 }
             }
-            // Look up a URL for each WebContainer in the server (Manager -< Container
-< Connector)
-            containers = WebAppUtil.mapContainersToURLs(kernel);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -188,8 +183,7 @@
             Collections.sort(webs);
             out.println("  Web Applications:");
             for (int i = 0; i < webs.size(); i++) {
-                WebAppInfo app = (WebAppInfo) webs.get(i);
-                out.println("    " + containers.get(app.getContainerObjectName()) + app.getContext());
+                out.println("    " + webs.get(i));
             }
             out.println();
         }
@@ -296,56 +290,6 @@
             AddressHolder other = (AddressHolder) o;
             int value = address.getPort() - other.address.getPort();
             return value == 0 ? address.getAddress().toString().compareTo(other.address.getAddress().toString())
: value;
-        }
-    }
-
-    private static class WebAppInfo implements Comparable {
-        private String containerObjectName;
-        private AbstractName webAppAbstractName;
-        private String context;
-
-        public WebAppInfo(String containerObjectName, AbstractName webAppAbstractName, String
context) {
-            this.containerObjectName = containerObjectName;
-            this.webAppAbstractName = webAppAbstractName;
-            this.context = context;
-        }
-
-        public String getContainerObjectName() {
-            return containerObjectName;
-        }
-
-        public AbstractName getWebAppAbstractName() {
-            return webAppAbstractName;
-        }
-
-        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;
-            return webAppAbstractName.equals(webAppInfo.webAppAbstractName);
-        }
-
-        public int hashCode() {
-            int result;
-            result = containerObjectName.hashCode();
-            result = 29 * result + webAppAbstractName.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/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
(original)
+++ geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
Mon Apr 24 21:07:54 2006
@@ -17,12 +17,8 @@
 package org.apache.geronimo.tomcat;
 
 import java.io.File;
-import java.io.FileFilter;
-import java.net.URL;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
-
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
@@ -35,6 +31,8 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.management.geronimo.NetworkConnector;
+import org.apache.geronimo.management.geronimo.WebManager;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.tomcat.realm.TomcatGeronimoRealm;
 import org.apache.geronimo.tomcat.realm.TomcatJAASRealm;
@@ -76,17 +74,19 @@
 
     private final Map webServices = new HashMap();
     private final String objectName;
+    private final WebManager manager;
 
     // Required as it's referenced by deployed webapps
     public TomcatContainer() {
         this.objectName = null; // is this OK??
         setCatalinaHome(DEFAULT_CATALINA_HOME);
+        manager = null;
     }
 
     /**
      * GBean constructor (invoked dynamically when the gbean is declared in a plan)
      */
-    public TomcatContainer(ClassLoader classLoader, String catalinaHome, ObjectRetriever
engineGBean, ServerInfo serverInfo, String objectName) {
+    public TomcatContainer(ClassLoader classLoader, String catalinaHome, ObjectRetriever
engineGBean, ServerInfo serverInfo, String objectName, WebManager manager) {
         if (catalinaHome == null)
             catalinaHome = DEFAULT_CATALINA_HOME;
 
@@ -105,6 +105,7 @@
         this.engine = (Engine) engineGBean.getInternalObject();
 
         this.objectName = objectName;
+        this.manager = manager;
     }
 
     public String getObjectName() {
@@ -123,6 +124,14 @@
         return true;
     }
 
+    public NetworkConnector[] getConnectors() {
+        return manager.getConnectorsForContainer(this);
+    }
+
+    public NetworkConnector[] getConnectors(String protocol) {
+        return manager.getConnectorsForContainer(this, protocol);
+    }
+
     public void doFail() {
         try {
             doStop();
@@ -349,7 +358,7 @@
     static {
         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Tomcat Web Container",
TomcatContainer.class);
 
-        infoFactory.setConstructor(new String[]{"classLoader", "catalinaHome", "EngineGBean",
"ServerInfo", "objectName"});
+        infoFactory.setConstructor(new String[]{"classLoader", "catalinaHome", "EngineGBean",
"ServerInfo", "objectName", "WebManager"});
 
         infoFactory.addAttribute("classLoader", ClassLoader.class, false);
 
@@ -360,6 +369,7 @@
         infoFactory.addReference("EngineGBean", ObjectRetriever.class, NameFactory.GERONIMO_SERVICE);
 
         infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
+        infoFactory.addReference("WebManager", WebManager.class);
 
         infoFactory.addOperation("addContext", new Class[]{TomcatContext.class});
         infoFactory.addOperation("removeContext", new Class[]{TomcatContext.class});

Modified: geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
(original)
+++ geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
Mon Apr 24 21:07:54 2006
@@ -16,6 +16,10 @@
  */
 package org.apache.geronimo.tomcat;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.AbstractName;
@@ -24,26 +28,19 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.ReferencePatterns;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.proxy.ProxyManager;
 import org.apache.geronimo.kernel.config.ConfigurationUtil;
 import org.apache.geronimo.kernel.config.EditableConfigurationManager;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.management.geronimo.WebManager;
+import org.apache.geronimo.kernel.proxy.ProxyManager;
 import org.apache.geronimo.management.geronimo.NetworkConnector;
-import org.apache.geronimo.management.geronimo.WebContainer;
-import org.apache.geronimo.management.geronimo.WebConnector;
 import org.apache.geronimo.management.geronimo.WebAccessLog;
+import org.apache.geronimo.management.geronimo.WebConnector;
+import org.apache.geronimo.management.geronimo.WebContainer;
+import org.apache.geronimo.management.geronimo.WebManager;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
 
 /**
  * Tomcat implementation of the WebManager management API.  Knows how to
@@ -289,30 +286,6 @@
         } catch (Exception e) {
             throw (IllegalArgumentException) new IllegalArgumentException("Unable to look
up connectors for Tomcat container '"+containerName).initCause(e);
         }
-    }
-
-    public Map mapContainersToURLs() {
-        WebContainer[] webContainers = (WebContainer[]) getContainers();
-        Map results = new HashMap();
-        for (int i = 0; i < webContainers.length; i++) {
-            WebContainer container = webContainers[i];
-            WebConnector[] connectors = (WebConnector[]) getConnectorsForContainer(container);
-            Map map = new HashMap();
-            for (int j = 0; j < connectors.length; j++) {
-                WebConnector connector = connectors[j];
-                String protocol = connector.getProtocol();
-                String url = connector.getConnectUrl();
-                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");
-                }
-            }
-            results.put(kernel.getAbstractNameFor(container).getObjectName().getCanonicalName(),
urlPrefix);
-        }
-        return results;
     }
 
     public static final GBeanInfo GBEAN_INFO;

Modified: geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?rev=396767&r1=396766&r2=396767&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
(original)
+++ geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
Mon Apr 24 21:07:54 2006
@@ -35,6 +35,8 @@
 import org.apache.geronimo.management.J2EEApplication;
 import org.apache.geronimo.management.J2EEServer;
 import org.apache.geronimo.management.geronimo.WebModule;
+import org.apache.geronimo.management.geronimo.WebContainer;
+import org.apache.geronimo.management.geronimo.WebConnector;
 import org.apache.geronimo.security.jacc.RoleDesignateSource;
 import org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
@@ -46,11 +48,13 @@
 import javax.management.MalformedObjectNameException;
 import java.net.URI;
 import java.net.URL;
+import java.net.MalformedURLException;
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.HashMap;
 
 /**
  * Wrapper for a WebApplicationContext that sets up its J2EE environment.
@@ -76,9 +80,9 @@
     private final Realm realm;
 
     private final List valveChain;
-    
+
     private final CatalinaCluster catalinaCluster;
-    
+
     private final Manager manager;
 
     private final boolean crossContext;
@@ -196,16 +200,16 @@
         } else {
             valveChain = null;
         }
-        
+
         //Add the cluster
         if (cluster != null)
-           catalinaCluster = (CatalinaCluster)cluster.getInternalObject(); 
+           catalinaCluster = (CatalinaCluster)cluster.getInternalObject();
         else
             catalinaCluster = null;
 
         //Add the manager
         if (manager != null)
-           this.manager = (Manager)manager.getInternalObject(); 
+           this.manager = (Manager)manager.getInternalObject();
         else
             this.manager = null;
 
@@ -262,8 +266,8 @@
         }
     }
 
-    public String getContainerName() {
-        return container.getObjectName();
+    public WebContainer getContainer() {
+        return container;
     }
 
     public String getServer() {
@@ -310,6 +314,30 @@
         this.context = context;
     }
 
+    public URL getURLFor() {
+        WebConnector[] connectors = (WebConnector[]) container.getConnectors();
+        Map map = new HashMap();
+        for (int i = 0; i < connectors.length; i++) {
+            WebConnector connector = connectors[i];
+            map.put(connector.getProtocol(), connector.getConnectUrl());
+        }
+        String urlPrefix;
+        if((urlPrefix = (String) map.get("HTTP")) == null) {
+            if((urlPrefix = (String) map.get("HTTPS")) == null) {
+                urlPrefix = (String) map.get("AJP");
+            }
+        }
+        if(urlPrefix == null) {
+            return null;
+        }
+        try {
+            return new URL(urlPrefix + getContextPath());
+        } catch (MalformedURLException e) {
+            log.error("Bad URL to connect to web app", e);
+            return null;
+        }
+    }
+
     public String getContextPath() {
         return path;
     }
@@ -346,11 +374,11 @@
     public CatalinaCluster getCluster() {
         return catalinaCluster;
     }
-    
+
     public Manager getManager() {
         return manager;
     }
-    
+
     public boolean isCrossContext() {
         return crossContext;
     }



Mime
View raw message