geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r357407 - in /geronimo/trunk: configs/tomcat/src/plan/ modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/ modules/tomcat/src/java/org/apache/geronimo/tomcat/ modules/tomcat/src/test/org/apache/geronimo/tomcat/
Date Sun, 18 Dec 2005 00:20:12 GMT
Author: jgenender
Date: Sat Dec 17 16:20:04 2005
New Revision: 357407

URL: http://svn.apache.org/viewcvs?rev=357407&view=rev
Log:
Fixed race condition in Tomcat by specifying the defaultHost as a GBean in the Engine

Modified:
    geronimo/trunk/configs/tomcat/src/plan/plan.xml
    geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/EngineGBean.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java
    geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
    geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/ContainerTest.java

Modified: geronimo/trunk/configs/tomcat/src/plan/plan.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/configs/tomcat/src/plan/plan.xml?rev=357407&r1=357406&r2=357407&view=diff
==============================================================================
--- geronimo/trunk/configs/tomcat/src/plan/plan.xml (original)
+++ geronimo/trunk/configs/tomcat/src/plan/plan.xml Sat Dec 17 16:20:04 2005
@@ -118,8 +118,10 @@
         <attribute name="className">org.apache.geronimo.tomcat.TomcatEngine</attribute>
         <attribute name="initParams">
             name=Geronimo
-            defaultHost=${PlanServerHostname}
         </attribute>
+        <reference name="DefaultHost">
+            <name>TomcatHost</name>
+        </reference>
         <references name="Hosts">
             <pattern>
                 <gbean-name>geronimo.server:j2eeType=Host,*</gbean-name>

Modified: geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?rev=357407&r1=357406&r2=357407&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
(original)
+++ geronimo/trunk/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
Sat Dec 17 16:20:04 2005
@@ -419,10 +419,10 @@
         // Default Engine
         initParams.clear();
         initParams.put("name", "Geronimo");
-        initParams.put("defaultHost", "localhost");
         engine = new GBeanData(engineName, EngineGBean.GBEAN_INFO);
         engine.setAttribute("className", "org.apache.geronimo.tomcat.TomcatEngine");
         engine.setAttribute("initParams", initParams);
+        engine.setReferencePattern("DefaultHost", hostName);
         engine.setReferencePattern("RealmGBean", realmName);
         engine.setReferencePattern("Hosts", hostName);
         start(engine);

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/EngineGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/EngineGBean.java?rev=357407&r1=357406&r2=357407&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/EngineGBean.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/EngineGBean.java Sat
Dec 17 16:20:04 2005
@@ -51,6 +51,7 @@
 
     public EngineGBean(String className,
             Map initParams,
+            HostGBean defaultHost,
             Collection hosts,
             ObjectRetriever realmGBean,
             ValveGBean tomcatValveChain,
@@ -63,23 +64,34 @@
         }
 
         if (initParams == null){
-            throw new IllegalArgumentException("Must have 'name' and 'defaultHost' values
in initParams.");
+            throw new IllegalArgumentException("Must have 'name' value in initParams.");
+        }
+        
+        //Be sure the defaulthost has been declared.
+        if (defaultHost == null){
+            throw new IllegalArgumentException("Must have a 'defaultHost' attribute.");
         }
 
         //Be sure the name has been declared.
         if (!initParams.containsKey(NAME)){
             throw new IllegalArgumentException("Must have a 'name' value initParams.");
         }
-
-        //Be sure the defaulthost has been declared.
-        if (!initParams.containsKey(DEFAULTHOST)){
-            throw new IllegalArgumentException("Must have a 'defaultHost' value initParams.");
+        
+        //Deprecate the defaultHost initParam
+        if (initParams.containsKey(DEFAULTHOST)){
+            log.warn("The " + DEFAULTHOST + " initParams value is no longer used and will
be ignored.");
+            initParams.remove(DEFAULTHOST);
         }
 
         engine = (Engine)Class.forName(className).newInstance();
 
         //Set the parameters
         setParameters(engine, initParams);
+        
+        //Set the default Host
+        final String defaultHostName = ((Host)defaultHost.getInternalObject()).getName();
+        engine.setDefaultHost(defaultHostName);
+        addHost(defaultHost);
 
         if (realmGBean != null){
             engine.setRealm((Realm)realmGBean.getInternalObject());
@@ -106,20 +118,26 @@
             public void memberAdded(ReferenceCollectionEvent event) {
                 Object o = event.getMember();
                 ObjectRetriever objectRetriever = (ObjectRetriever) o;
-                addHost(objectRetriever);
+                String hostName = ((Host)objectRetriever.getInternalObject()).getName();
+                if (!hostName.equals(defaultHostName))
+                    addHost(objectRetriever);
             }
 
             public void memberRemoved(ReferenceCollectionEvent event) {
                 Object o = event.getMember();
                 ObjectRetriever objectRetriever = (ObjectRetriever) o;
-                removeHost(objectRetriever);
+                String hostName = ((Host)objectRetriever.getInternalObject()).getName();
+                if (!hostName.equals(defaultHostName))
+                    removeHost(objectRetriever);
             }
         });
+        
         Iterator iterator = refs.iterator();
         while (iterator.hasNext()){
             ObjectRetriever objRetriever = (ObjectRetriever)iterator.next();
-            addHost(objRetriever);
-
+            String hostName = ((Host)objRetriever.getInternalObject()).getName();
+            if (!hostName.equals(defaultHostName))
+                addHost(objRetriever);
         }
         
         //Add clustering
@@ -165,6 +183,7 @@
         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("TomcatEngine", EngineGBean.class);
         infoFactory.addAttribute("className", String.class, true);
         infoFactory.addAttribute("initParams", Map.class, true);
+        infoFactory.addReference("DefaultHost", HostGBean.class, HostGBean.J2EE_TYPE);
         infoFactory.addReference("Hosts", ObjectRetriever.class, HostGBean.J2EE_TYPE);
         infoFactory.addReference("RealmGBean", ObjectRetriever.class, NameFactory.GERONIMO_SERVICE);
         infoFactory.addReference("TomcatValveChain", ValveGBean.class, ValveGBean.J2EE_TYPE);
@@ -174,6 +193,7 @@
         infoFactory.setConstructor(new String[] { 
                 "className", 
                 "initParams", 
+                "DefaultHost",
                 "Hosts", 
                 "RealmGBean", 
                 "TomcatValveChain",

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java?rev=357407&r1=357406&r2=357407&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java Sat Dec
17 16:20:04 2005
@@ -45,6 +45,10 @@
     private static final String NAME = "name";
     
     private final Host host;
+    
+    public HostGBean(){
+        host = null;
+    }
 
     public HostGBean(String className, 
             Map initParams, 

Modified: geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java?rev=357407&r1=357406&r2=357407&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
(original)
+++ geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
Sat Dec 17 16:20:04 2005
@@ -359,10 +359,10 @@
         //Default Engine
         initParams.clear();
         initParams.put("name", "Geronimo");
-        initParams.put("defaultHost", "localhost");
         engine = new GBeanData(engineName, EngineGBean.GBEAN_INFO);
         engine.setAttribute("className", "org.apache.geronimo.tomcat.TomcatEngine");
         engine.setAttribute("initParams", initParams);
+        engine.setReferencePattern("DefaultHost", hostName);
         if (realmClass != null)
             engine.setReferencePattern("RealmGBean", realmName);
         engine.setReferencePattern("Hosts", hostName);

Modified: geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/ContainerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/ContainerTest.java?rev=357407&r1=357406&r2=357407&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/ContainerTest.java (original)
+++ geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/ContainerTest.java Sat
Dec 17 16:20:04 2005
@@ -277,9 +277,9 @@
 
         initParams.clear();
         initParams.put("name", "Geronimo");
-        initParams.put("defaultHost", "localhost");
         engine = new GBeanData(engineName, EngineGBean.GBEAN_INFO);
         engine.setAttribute("className", "org.apache.geronimo.tomcat.TomcatEngine");
+        engine.setReferencePattern("DefaultHost", hostName);
         engine.setAttribute("initParams", initParams);
         engine.setReferencePattern("Hosts", hostName);
         start(engine);



Mime
View raw message