geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r551692 - in /geronimo/server/trunk/modules: geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/ geronimo-tomcat6-builder/src/main/schema/ geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/ geronimo-tomcat6...
Date Thu, 28 Jun 2007 20:36:12 GMT
Author: jgenender
Date: Thu Jun 28 13:36:09 2007
New Revision: 551692

URL: http://svn.apache.org/viewvc?view=rev&rev=551692
Log:
GERONIMO-3184 - Add ability for Tomcat integration to implement Catalina Lifecycle Listeners

Added:
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/LifecycleListenerGBean.java
Modified:
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/schema/geronimo-tomcat-1.2.xsd
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/schema/geronimo-tomcat-config-1.0.xsd
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/EngineGBean.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?view=diff&rev=551692&r1=551691&r2=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Thu Jun 28 13:36:09 2007
@@ -63,6 +63,7 @@
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
 import org.apache.geronimo.security.jacc.ComponentPermissions;
+import org.apache.geronimo.tomcat.LifecycleListenerGBean;
 import org.apache.geronimo.tomcat.ManagerGBean;
 import org.apache.geronimo.tomcat.RealmGBean;
 import org.apache.geronimo.tomcat.TomcatWebAppContext;
@@ -339,6 +340,12 @@
                 String valveChain = tomcatWebApp.getValveChain().trim();
                 AbstractName valveName = earContext.getNaming().createChildName(moduleName,
valveChain, ValveGBean.J2EE_TYPE);
                 webModuleData.setReferencePattern("TomcatValveChain", valveName);
+            }
+            
+            if (tomcatWebApp.isSetListenerChain()) {
+                String listenerChain = tomcatWebApp.getListenerChain().trim();
+                AbstractName listenerName = earContext.getNaming().createChildName(moduleName,
listenerChain, LifecycleListenerGBean.J2EE_TYPE);
+                webModuleData.setReferencePattern("LifecycleListenerChain", listenerName);
             }
 
 //            if (tomcatWebApp.isSetCluster()) {

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/schema/geronimo-tomcat-1.2.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/schema/geronimo-tomcat-1.2.xsd?view=diff&rev=551692&r1=551691&r2=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/schema/geronimo-tomcat-1.2.xsd
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/schema/geronimo-tomcat-1.2.xsd
Thu Jun 28 13:36:09 2007
@@ -160,6 +160,14 @@
                     </xs:documentation>
                 </xs:annotation>
             </xs:element>
+            <xs:element name="listener-chain" type="xs:string" minOccurs="0">
+                <xs:annotation>
+                    <xs:documentation>
+                        The listener-chain provides the list of first element
+                        tomcat lifecycle listener chain for this web application.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:element>
             <xs:element name="tomcat-realm" type="xs:string" minOccurs="0">
                 <xs:annotation>
                     <xs:documentation>

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/schema/geronimo-tomcat-config-1.0.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/schema/geronimo-tomcat-config-1.0.xsd?view=diff&rev=551692&r1=551691&r2=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/schema/geronimo-tomcat-config-1.0.xsd
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/schema/geronimo-tomcat-config-1.0.xsd
Thu Jun 28 13:36:09 2007
@@ -85,6 +85,14 @@
                     </xs:documentation>
                 </xs:annotation>
             </xs:element>
+            <xs:element name="listener-chain" type="xs:string" minOccurs="0">
+                <xs:annotation>
+                    <xs:documentation>
+                        The listener-chain provides the list of first element
+                        tomcat lifecycle listener chain for this web application.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:element>
             <xs:element name="tomcat-realm" type="xs:string" minOccurs="0">
                 <xs:annotation>
                     <xs:documentation>

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/EngineGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/EngineGBean.java?view=diff&rev=551692&r1=551691&r2=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/EngineGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/EngineGBean.java
Thu Jun 28 13:36:09 2007
@@ -23,6 +23,7 @@
 import org.apache.catalina.Cluster;
 import org.apache.catalina.Engine;
 import org.apache.catalina.Host;
+import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Realm;
 import org.apache.catalina.Valve;
@@ -56,6 +57,7 @@
             Collection hosts,
             ObjectRetriever realmGBean,
             ValveGBean tomcatValveChain,
+            LifecycleListenerGBean listenerChain,
             CatalinaClusterGBean clusterGBean,
             ManagerGBean manager) throws Exception {
         super(); // TODO: make it an attribute
@@ -102,7 +104,7 @@
         if (manager != null)
             engine.setManager((Manager)manager.getInternalObject());
 
-        //Add the valve list
+        //Add the valve and listener lists
         if (engine instanceof StandardEngine){
             if (tomcatValveChain != null){
                 ValveGBean valveGBean = tomcatValveChain;
@@ -111,8 +113,16 @@
                     valveGBean = valveGBean.getNextValve();
                 }
             }
+            
+            if (listenerChain != null){
+                LifecycleListenerGBean listenerGBean = listenerChain;
+                while(listenerGBean != null){
+                    ((StandardEngine)engine).addLifecycleListener((LifecycleListener)listenerGBean.getInternalObject());
+                    listenerGBean = listenerGBean.getNextListener();
+                }
+            }
         }
-
+        
         //Add the hosts
         if (hosts instanceof ReferenceCollection) {
             ReferenceCollection refs = (ReferenceCollection)hosts;
@@ -191,6 +201,7 @@
         infoFactory.addReference("Hosts", ObjectRetriever.class, HostGBean.J2EE_TYPE);
         infoFactory.addReference("RealmGBean", ObjectRetriever.class, NameFactory.GERONIMO_SERVICE);
         infoFactory.addReference("TomcatValveChain", ValveGBean.class, ValveGBean.J2EE_TYPE);
+        infoFactory.addReference("LifecycleListenerChain", LifecycleListenerGBean.class,
LifecycleListenerGBean.J2EE_TYPE);
         infoFactory.addReference("CatalinaCluster", CatalinaClusterGBean.class, CatalinaClusterGBean.J2EE_TYPE);
         infoFactory.addReference("Manager", ManagerGBean.class, ManagerGBean.J2EE_TYPE);
         infoFactory.addOperation("getInternalObject");
@@ -201,6 +212,7 @@
                 "Hosts", 
                 "RealmGBean", 
                 "TomcatValveChain",
+                "LifecycleListenerChain",
                 "CatalinaCluster",
                 "Manager"});
         GBEAN_INFO = infoFactory.getBeanInfo();

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?view=diff&rev=551692&r1=551691&r2=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
Thu Jun 28 13:36:09 2007
@@ -29,6 +29,7 @@
 
 import org.apache.catalina.Container;
 import org.apache.catalina.LifecycleException;
+import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Loader;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Valve;
@@ -153,6 +154,14 @@
         if (valveChain != null) {
             for (Object valve : valveChain) {
                 addValve((Valve)valve);
+            }
+        }
+        
+        // Add User Defined Listeners
+        List listenerChain = ctx.getLifecycleListenerChain();
+        if (listenerChain != null) {
+            for (Object listener : listenerChain) {
+                addLifecycleListener((LifecycleListener)listener);
             }
         }
 

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/HostGBean.java?view=diff&rev=551692&r1=551691&r2=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
Thu Jun 28 13:36:09 2007
@@ -22,9 +22,11 @@
 
 import org.apache.catalina.Cluster;
 import org.apache.catalina.Host;
+import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Realm;
 import org.apache.catalina.Valve;
+import org.apache.catalina.core.StandardEngine;
 import org.apache.catalina.core.StandardHost;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -56,6 +58,7 @@
             ArrayList aliases,
             ObjectRetriever realmGBean,            
             ValveGBean tomcatValveChain,
+            LifecycleListenerGBean listenerChain,
             CatalinaClusterGBean clusterGBean,
             ManagerGBean manager) throws Exception {
         super(); // TODO: make it an attribute
@@ -98,6 +101,7 @@
 
         //Add the valve list
         if (host instanceof StandardHost){
+            
             if (tomcatValveChain != null){
                 ValveGBean valveGBean = tomcatValveChain;
                 while(valveGBean != null){
@@ -105,7 +109,16 @@
                     valveGBean = valveGBean.getNextValve();
                 }
             }
-        }
+            
+            if (listenerChain != null){
+                LifecycleListenerGBean listenerGBean = listenerChain;
+                while(listenerGBean != null){
+                    ((StandardHost)host).addLifecycleListener((LifecycleListener)listenerGBean.getInternalObject());
+                    listenerGBean = listenerGBean.getNextListener();
+                }
+            }
+            
+       }
 
         //Add clustering
         if (clusterGBean != null){
@@ -142,6 +155,7 @@
         infoFactory.addAttribute("aliases", ArrayList.class, true);
         infoFactory.addReference("RealmGBean", ObjectRetriever.class, NameFactory.GERONIMO_SERVICE);
         infoFactory.addReference("TomcatValveChain", ValveGBean.class, ValveGBean.J2EE_TYPE);
+        infoFactory.addReference("LifecycleListenerChain", LifecycleListenerGBean.class,
LifecycleListenerGBean.J2EE_TYPE);
         infoFactory.addReference("CatalinaCluster", CatalinaClusterGBean.class, CatalinaClusterGBean.J2EE_TYPE);
         infoFactory.addReference("Manager", ManagerGBean.class, ManagerGBean.J2EE_TYPE);
         infoFactory.addOperation("getInternalObject");
@@ -151,6 +165,7 @@
                 "aliases", 
                 "RealmGBean", 
                 "TomcatValveChain",
+                "LifecycleListenerChain",
                 "CatalinaCluster",
                 "Manager"});
         GBEAN_INFO = infoFactory.getBeanInfo();

Added: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/LifecycleListenerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/LifecycleListenerGBean.java?view=auto&rev=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/LifecycleListenerGBean.java
(added)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/LifecycleListenerGBean.java
Thu Jun 28 13:36:09 2007
@@ -0,0 +1,111 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You 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.tomcat;
+
+import java.util.Map;
+
+import org.apache.catalina.LifecycleListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+
+/**
+ * @version $Rev: 486195 $ $Date: 2006-12-12 08:42:02 -0700 (Tue, 12 Dec 2006) $
+ */
+public class LifecycleListenerGBean extends BaseGBean implements GBeanLifecycle, ObjectRetriever
{
+
+    private static final Log log = LogFactory.getLog(LifecycleListenerGBean.class);
+
+    public static final String J2EE_TYPE = "TomcatLifecycleListener";
+        
+    private final LifecycleListener listener;
+    private final LifecycleListenerGBean nextListener;
+    private final String className;
+ 
+    
+    public LifecycleListenerGBean(){      
+        listener = null;
+        nextListener = null;
+        className = null;
+    }
+    
+    public LifecycleListenerGBean(String className, Map initParams, LifecycleListenerGBean
nextListener) throws Exception{
+
+        //Validate
+        if (className == null){
+            throw new IllegalArgumentException("className cannot be null.");
+        }
+        
+        if (nextListener != null){
+            if (!(nextListener.getInternalObject() instanceof LifecycleListener)){
+                throw new IllegalArgumentException("The class given as the NextListener attribute
does not wrap an object of org.apache.catalina.LifecycleListener type.");                
+            }
+            this.nextListener = nextListener;
+        } else {
+            this.nextListener = null;
+        }
+        
+        this.className = className;
+        
+        //Create the Listener object
+        listener = (LifecycleListener)Class.forName(className).newInstance();
+
+        //Set the parameters
+        setParameters(listener, initParams);
+        
+    }
+    
+    public void doStart() throws Exception {
+        log.debug(className + " started.");
+    }
+
+    public void doStop() throws Exception {
+        log.debug(className + " stopped.");
+    }
+
+    public void doFail() {
+        log.warn(className + " failed.");
+    }
+
+    public Object getInternalObject() {
+        return listener;
+    }
+
+    public LifecycleListenerGBean getNextListener() {
+        return nextListener;
+    }
+    
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(LifecycleListenerGBean.class,
J2EE_TYPE);
+        infoFactory.addAttribute("className", String.class, true);
+        infoFactory.addAttribute("initParams", Map.class, true);
+        infoFactory.addReference("NextListener", LifecycleListenerGBean.class, J2EE_TYPE);
+        infoFactory.addOperation("getInternalObject");
+        infoFactory.addOperation("getNextListener");
+        infoFactory.setConstructor(new String[] { "className", "initParams", "NextListener"
});
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java?view=diff&rev=551692&r1=551691&r2=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
Thu Jun 28 13:36:09 2007
@@ -17,16 +17,19 @@
 package org.apache.geronimo.tomcat;
 
 import java.io.File;
+import java.net.URL;
+import java.net.URLStreamHandlerFactory;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
-import java.net.URLStreamHandlerFactory;
-import java.net.URL;
 
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
+import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Realm;
 import org.apache.catalina.connector.Connector;
+import org.apache.catalina.core.StandardEngine;
 import org.apache.catalina.realm.JAASRealm;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -81,6 +84,7 @@
     private final String[] applicationListeners;
     private final WebManager manager;
     private static boolean first = true;
+    private final LifecycleListenerGBean listenerChain;
 
     // Required as it's referenced by deployed webapps
     public TomcatContainer() {
@@ -88,12 +92,21 @@
         this.applicationListeners = null;
         setCatalinaHome(DEFAULT_CATALINA_HOME);
         manager = null;
+        listenerChain=null;
     }
 
     /**
      * GBean constructor (invoked dynamically when the gbean is declared in a plan)
      */
-    public TomcatContainer(ClassLoader classLoader, String catalinaHome, String[] applicationListeners,
ObjectRetriever engineGBean, ServerInfo serverInfo, String objectName, WebManager manager)
{
+    public TomcatContainer(
+            ClassLoader classLoader, 
+            String catalinaHome, 
+            String[] applicationListeners, 
+            ObjectRetriever engineGBean, 
+            LifecycleListenerGBean listenerChain,
+            ServerInfo serverInfo, 
+            String objectName, 
+            WebManager manager) {
         // Register a stream handler factory for the JNDI protocol
         URLStreamHandlerFactory streamHandlerFactory =
             new DirContextURLStreamHandlerFactory();
@@ -124,11 +137,12 @@
         if (engineGBean == null) {
             throw new IllegalArgumentException("engineGBean cannot be null.");
         }
+        
 
         this.classLoader = classLoader;
 
         this.engine = (Engine) engineGBean.getInternalObject();
-
+        this.listenerChain = listenerChain;
         this.objectName = objectName;
         this.applicationListeners = applicationListeners;
         this.manager = manager;
@@ -221,6 +235,14 @@
         // 6. Call addEngine() to attach this Engine to the set of defined
         // Engines for this object.
         embedded.addEngine(engine);
+        
+        if (listenerChain != null){
+            LifecycleListenerGBean listenerGBean = listenerChain;
+            while(listenerGBean != null){
+                embedded.addLifecycleListener((LifecycleListener)listenerGBean.getInternalObject());
+                listenerGBean = listenerGBean.getNextListener();
+            }
+        }
 
         // 9. Call start() to initiate normal operations of all the attached
         // components.
@@ -401,7 +423,15 @@
     static {
         GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Tomcat Web Container",
TomcatContainer.class);
 
-        infoFactory.setConstructor(new String[]{"classLoader", "catalinaHome", "applicationListeners",
"EngineGBean", "ServerInfo", "objectName", "WebManager"});
+        infoFactory.setConstructor(new String[]{
+                "classLoader", 
+                "catalinaHome", 
+                "applicationListeners", 
+                "EngineGBean", 
+                "LifecycleListenerChain",
+                "ServerInfo", 
+                "objectName", 
+                "WebManager"});
 
         infoFactory.addAttribute("classLoader", ClassLoader.class, false);
 
@@ -412,6 +442,7 @@
         infoFactory.addAttribute("objectName", String.class, false);
 
         infoFactory.addReference("EngineGBean", ObjectRetriever.class, NameFactory.GERONIMO_SERVICE);
+        infoFactory.addReference("LifecycleListenerChain", LifecycleListenerGBean.class,
LifecycleListenerGBean.J2EE_TYPE);
 
         infoFactory.addReference("ServerInfo", ServerInfo.class, "GBean");
         infoFactory.addReference("WebManager", WebManager.class);

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java?view=diff&rev=551692&r1=551691&r2=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
Thu Jun 28 13:36:09 2007
@@ -66,6 +66,8 @@
     public Realm getRealm();
 
     public List getValveChain();
+    
+    public List getLifecycleListenerChain();
 
     public CatalinaCluster getCluster();
 

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?view=diff&rev=551692&r1=551691&r2=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
Thu Jun 28 13:36:09 2007
@@ -35,11 +35,12 @@
 import javax.transaction.TransactionManager;
 import javax.transaction.UserTransaction;
 
+import org.apache.InstanceManager;
 import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Realm;
 import org.apache.catalina.Valve;
-import org.apache.InstanceManager;
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.ha.CatalinaCluster;
 import org.apache.commons.logging.Log;
@@ -49,10 +50,10 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.j2ee.RuntimeCustomizer;
 import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.j2ee.management.impl.InvalidObjectNameException;
-import org.apache.geronimo.j2ee.RuntimeCustomizer;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.ObjectNameUtil;
 import org.apache.geronimo.management.J2EEApplication;
@@ -62,14 +63,13 @@
 import org.apache.geronimo.management.geronimo.WebContainer;
 import org.apache.geronimo.management.geronimo.WebModule;
 import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
+import org.apache.geronimo.security.jacc.RunAsSource;
 import org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean;
 import org.apache.geronimo.tomcat.stats.ModuleStats;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
 import org.apache.geronimo.transaction.GeronimoUserTransaction;
 import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.geronimo.webservices.WebServiceContainerFactory;
-import org.apache.geronimo.security.credentialstore.CredentialStore;
-import org.apache.geronimo.security.jacc.RunAsSource;
 import org.apache.naming.resources.DirContextURLStreamHandler;
 
 /**
@@ -96,6 +96,8 @@
     private final Realm realm;
 
     private final List valveChain;
+    
+    private final List listenerChain;
 
     private final CatalinaCluster catalinaCluster;
 
@@ -160,6 +162,7 @@
             RunAsSource runAsSource,
             ObjectRetriever tomcatRealm,
             ValveGBean tomcatValveChain,
+            LifecycleListenerGBean lifecycleListenerChain,
             CatalinaClusterGBean cluster,
             ManagerGBean manager,
             boolean crossContext,
@@ -236,6 +239,19 @@
         } else {
             valveChain = null;
         }
+        
+        //Add the Lifecycle Listener list
+        if (lifecycleListenerChain != null){
+            ArrayList<LifecycleListener> chain = new ArrayList<LifecycleListener>();
+            LifecycleListenerGBean listenerGBean = lifecycleListenerChain;
+            while(listenerGBean != null){
+                chain.add((LifecycleListener)listenerGBean.getInternalObject());
+                listenerGBean = listenerGBean.getNextListener();
+            }
+            listenerChain = chain;
+        } else {
+            listenerChain = null;
+        }
 
         //Add the cluster
         if (cluster != null) {
@@ -430,6 +446,10 @@
         return valveChain;
     }
 
+    public List getLifecycleListenerChain() {
+        return listenerChain;
+    }
+
     public CatalinaCluster getCluster() {
         return catalinaCluster;
     }
@@ -584,6 +604,7 @@
         infoBuilder.addReference("RunAsSource", RunAsSource.class, NameFactory.JACC_MANAGER);
         infoBuilder.addReference("TomcatRealm", ObjectRetriever.class);
         infoBuilder.addReference("TomcatValveChain", ValveGBean.class);
+        infoBuilder.addReference("LifecycleListenerChain", LifecycleListenerGBean.class,
LifecycleListenerGBean.J2EE_TYPE);
         infoBuilder.addReference("Cluster", CatalinaClusterGBean.class, CatalinaClusterGBean.J2EE_TYPE);
         infoBuilder.addReference("Manager", ManagerGBean.class);
         infoBuilder.addAttribute("crossContext", boolean.class, true);
@@ -613,6 +634,7 @@
                 "RunAsSource",
                 "TomcatRealm",
                 "TomcatValveChain",
+                "LifecycleListenerChain",
                 "Cluster",
                 "Manager",
                 "crossContext",

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java?view=diff&rev=551692&r1=551691&r2=551692
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
Thu Jun 28 13:36:09 2007
@@ -84,6 +84,7 @@
                 valveChain,
                 null,
                 null,
+                null,
                 false,
                 false,
                 null,
@@ -165,7 +166,7 @@
         initParams.put("name", "localhost");
         initParams.put("appBase", "");
 
-        HostGBean host = new HostGBean("org.apache.catalina.core.StandardHost", initParams,
null, realm, null, null, null);
+        HostGBean host = new HostGBean("org.apache.catalina.core.StandardHost", initParams,
null, realm, null, null, null, null);
         //Default Engine
         initParams = Collections.singletonMap("name", "Geronimo");
 
@@ -176,11 +177,12 @@
                 realm,
                 null,
                 null,
+                null,
                 null);
         engine.doStart();
 
         ServerInfo serverInfo = new BasicServerInfo(".");
-        container = new TomcatContainer(cl, new File(BASEDIR, "target/var/catalina").toString(),
null, engine, serverInfo, null, null);
+        container = new TomcatContainer(cl, new File(BASEDIR, "target/var/catalina").toString(),
null, engine, null, serverInfo, null, null);
         container.doStart();
 
         connector = new ConnectorGBean("HTTP", null, "localhost", port++, container);



Mime
View raw message