geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r918287 - in /geronimo/server/trunk/plugins/jetty8: geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/ geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/ geronimo-jetty8/src/main/java/org/apache/geronimo/jet...
Date Wed, 03 Mar 2010 00:58:03 GMT
Author: gawor
Date: Wed Mar  3 00:58:03 2010
New Revision: 918287

URL: http://svn.apache.org/viewvc?rev=918287&view=rev
Log:
GERONIMO-5030: Make sure ServletContext is registered in service registry after the web app
context is fully initialized - take 2. Register gbean with lowest priority so that it starts
last and causes the ServletContext to be registered

Added:
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextManager.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java?rev=918287&r1=918286&r2=918287&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
Wed Mar  3 00:58:03 2010
@@ -18,12 +18,21 @@
 package org.apache.geronimo.jetty8.deployment;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.Serializable;
 import java.lang.String;
 import java.net.URL;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
 import java.util.jar.JarFile;
 
 import javax.management.ObjectName;
@@ -39,12 +48,32 @@
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
-import org.apache.geronimo.gbean.*;
-import org.apache.geronimo.gbean.annotation.*;
-import org.apache.geronimo.j2ee.deployment.*;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.apache.geronimo.j2ee.deployment.EARContext;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
+import org.apache.geronimo.j2ee.deployment.NamingBuilder;
+import org.apache.geronimo.j2ee.deployment.WebModule;
+import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.jetty8.*;
+import org.apache.geronimo.jetty8.DefaultServletHolderWrapper;
+import org.apache.geronimo.jetty8.FilterHolderWrapper;
+import org.apache.geronimo.jetty8.Host;
+import org.apache.geronimo.jetty8.JettyFilterMapping;
+import org.apache.geronimo.jetty8.JspServletHolderWrapper;
+import org.apache.geronimo.jetty8.ServletHolderWrapper;
+import org.apache.geronimo.jetty8.WebAppContextManager;
+import org.apache.geronimo.jetty8.WebAppContextWrapper;
 import org.apache.geronimo.jetty8.security.AuthConfigProviderHandlerFactory;
 import org.apache.geronimo.jetty8.security.BuiltInAuthMethod;
 import org.apache.geronimo.jetty8.security.JettySecurityHandlerFactory;
@@ -73,7 +102,26 @@
 import org.apache.geronimo.xbeans.geronimo.web.jetty.JettyWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.JettyWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.config.GerJettyDocument;
-import org.apache.geronimo.xbeans.javaee6.*;
+import org.apache.geronimo.xbeans.javaee6.DispatcherType;
+import org.apache.geronimo.xbeans.javaee6.ErrorPageType;
+import org.apache.geronimo.xbeans.javaee6.FilterMappingType;
+import org.apache.geronimo.xbeans.javaee6.FilterType;
+import org.apache.geronimo.xbeans.javaee6.FormLoginConfigType;
+import org.apache.geronimo.xbeans.javaee6.JspConfigType;
+import org.apache.geronimo.xbeans.javaee6.JspPropertyGroupType;
+import org.apache.geronimo.xbeans.javaee6.ListenerType;
+import org.apache.geronimo.xbeans.javaee6.LocaleEncodingMappingListType;
+import org.apache.geronimo.xbeans.javaee6.LocaleEncodingMappingType;
+import org.apache.geronimo.xbeans.javaee6.LoginConfigType;
+import org.apache.geronimo.xbeans.javaee6.MimeMappingType;
+import org.apache.geronimo.xbeans.javaee6.ParamValueType;
+import org.apache.geronimo.xbeans.javaee6.ServletMappingType;
+import org.apache.geronimo.xbeans.javaee6.ServletType;
+import org.apache.geronimo.xbeans.javaee6.TaglibType;
+import org.apache.geronimo.xbeans.javaee6.UrlPatternType;
+import org.apache.geronimo.xbeans.javaee6.WebAppDocument;
+import org.apache.geronimo.xbeans.javaee6.WebAppType;
+import org.apache.geronimo.xbeans.javaee6.WelcomeFileListType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.osgi.framework.Bundle;
@@ -420,10 +468,16 @@
         try {
             moduleContext.addGBean(webModuleData);
 
+            // configure WebAppContextManager with right priority so that it starts last
+            AbstractName contextManagerName = earContext.getNaming().createChildName(moduleName,
"WebAppContextManager", NameFactory.SERVICE_MODULE);            
+            GBeanData contextManagerGBean = new GBeanData(contextManagerName, WebAppContextManager.class);
+            contextManagerGBean.setPriority(100);
+            contextManagerGBean.setReferencePattern("webApp", moduleName);
+            moduleContext.addGBean(contextManagerGBean);
+            
             // configure hosts and virtual-hosts
             configureHosts(earContext, jettyWebApp, webModuleData);
 
-
             String contextPath = webModule.getContextRoot();
             if (contextPath == null) {
                 throw new DeploymentException("null contextPath");
@@ -504,7 +558,6 @@
 
             //be careful that the jsp servlet defaults don't override anything configured
in the app.
             if (jspServlet != null) {
-                //TODO rfc 66 make sure this has classSource set
                 GBeanData jspServletData = (GBeanData) module.getSharedContext().get(DEFAULT_JSP_SERVLET_KEY);
                 Set<String> jspMappings = (Set<String>) jspServletData.getAttribute("servletMappings");
                 jspMappings.removeAll(knownServletMappings);
@@ -1094,7 +1147,6 @@
                 servletData.setAttribute("servletClass", servletClassName);
             } else {
                 servletData = new GBeanData(pojoWebServiceTemplate);
-                //TODO rfc 66 set classSource!
                 servletData.setAbstractName(servletAbstractName);
                 //let the web service builder deal with configuring the gbean with the web
service stack
 //                Object portInfo = portMap.get(servletName);

Added: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextManager.java?rev=918287&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextManager.java
(added)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextManager.java
Wed Mar  3 00:58:03 2010
@@ -0,0 +1,49 @@
+/**
+ *  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.jetty8;
+
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+
+/**
+ * This gbean calls {@link WebAppContextWrapper#fullyStarted()} when it starts.
+ * This gbean is configured with lowest priority and therefore is started last. 
+ *   
+ * @version $Rev$ $Date$
+ */
+@GBean
+public class WebAppContextManager implements GBeanLifecycle {
+
+    private final WebAppContextWrapper webApp;
+    
+    public WebAppContextManager(@ParamReference(name = "webApp") WebAppContextWrapper webApp)
{
+        this.webApp = webApp;
+    }
+    
+    public void doFail() {
+    }
+
+    public void doStart() throws Exception {
+        webApp.fullyStarted();
+    }
+
+    public void doStop() throws Exception {
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java?rev=918287&r1=918286&r2=918287&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
Wed Mar  3 00:58:03 2010
@@ -303,14 +303,19 @@
         }
     }
 
+    public void fullyStarted() {
+        webAppContext.registerServletContext();
+    }
+    
     public void doStart() throws Exception {
         // reset the classsloader... jetty likes to set it to null when stopping
-        this.webAppContext.setClassLoader(webClassLoader);
+        webAppContext.setClassLoader(webClassLoader);
         jettyContainer.addContext(webAppContext);
         webAppContext.start();
     }
 
     public void doStop() throws Exception {
+        webAppContext.unregisterServletContext();
         webAppContext.stop();
         jettyContainer.removeContext(webAppContext);
         log.debug("WebAppContextWrapper stopped");

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java?rev=918287&r1=918286&r2=918287&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
Wed Mar  3 00:58:03 2010
@@ -63,6 +63,20 @@
         this.modulePath = modulePath;
     }
 
+    public void registerServletContext() {
+        // for OSGi Web Applications support register ServletContext in service registry
+        Bundle bundle = integrationContext.getBundle();
+        if (WebApplicationUtils.isWebApplicationBundle(bundle)) {
+            serviceRegistration = WebApplicationUtils.registerServletContext(bundle, getServletContext());
+        }
+    }
+    
+    public void unregisterServletContext() {
+        if (serviceRegistration != null) {
+            serviceRegistration.unregister();
+        }
+    }
+    
     @Override
     protected void doStart() throws Exception {
         javax.naming.Context context = integrationContext.setContext();
@@ -79,18 +93,10 @@
             integrationContext.restoreContext(context);
             integrationContext.completeTx(txActive, null);
         }
-        // for OSGi Web Applications support register ServletContext in service registry
-        Bundle bundle = integrationContext.getBundle();
-        if (WebApplicationUtils.isWebApplicationBundle(bundle)) {
-            serviceRegistration = WebApplicationUtils.registerServletContext(bundle, getServletContext());
-        }
     }
 
     @Override
     protected void doStop() throws Exception {
-        if (serviceRegistration != null) {
-            serviceRegistration.unregister();
-        }
         javax.naming.Context context = integrationContext.setContext();
         boolean txActive = integrationContext.isTxActive();
         SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null);



Mime
View raw message