geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r918095 - 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/...
Date Tue, 02 Mar 2010 16:04:57 GMT
Author: gawor
Date: Tue Mar  2 16:04:57 2010
New Revision: 918095

URL: http://svn.apache.org/viewvc?rev=918095&view=rev
Log:
GERONIMO-5030: Make sure ServletContext is registered in service registry after the web app
context is fully initialized. That is, start web app context after all dependent servlet gbeans
are started

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
    geronimo/server/trunk/plugins/jetty8/jetty8-deployer/pom.xml
    geronimo/server/trunk/plugins/jetty8/jetty8/pom.xml
    geronimo/server/trunk/plugins/jetty8/pom.xml

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=918095&r1=918094&r2=918095&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
Tue Mar  2 16:04:57 2010
@@ -449,6 +449,13 @@
                 webModuleData.setAttribute("displayName", webApp.getDisplayNameArray()[0].getStringValue());
             }
 
+            // setup context manager
+            AbstractName contextManagerName = 
+                moduleContext.getNaming().createChildName(moduleName, "WebAppContextManager",
NameFactory.SERVICE_MODULE);
+            GBeanData contextManager = new GBeanData(contextManagerName, WebAppContextManager.class);
+            contextManager.setReferencePattern("webApp", moduleName);
+            moduleContext.addGBean(contextManager);
+            
             // configure context parameters.
             configureContextParams(webApp, webModuleData);
 
@@ -490,7 +497,7 @@
             Map<String, Set<String>> servletMappings = new HashMap<String,
Set<String>>();
             if (jspServlet != null) {
                 configureTagLibs(module, webApp, webModuleData, servletMappings, knownJspMappings,
jspServlet.getServletName());
-                GBeanData jspServletData = configureDefaultServlet(jspServlet, earContext,
moduleName, knownJspMappings);
+                GBeanData jspServletData = configureDefaultServlet(jspServlet, earContext,
moduleName, knownJspMappings, contextManager);
                 knownServletMappings.addAll(knownJspMappings);
                 module.getSharedContext().put(DEFAULT_JSP_SERVLET_KEY, jspServletData);
             }
@@ -504,7 +511,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);
@@ -553,12 +559,12 @@
 
             //add default servlets
             if (defaultServlets != null) {
-                addDefaultServletsGBeans(earContext, moduleContext, moduleName, knownServletMappings);
+                addDefaultServletsGBeans(earContext, moduleContext, moduleName, knownServletMappings,
contextManager);
             }
 
             //set up servlet gbeans.
             ServletType[] servletTypes = webApp.getServletArray();
-            addServlets(moduleName, webModule, servletTypes, servletMappings, moduleContext);
+            addServlets(moduleName, webModule, servletTypes, servletMappings, moduleContext,
contextManager);
 
             if (jettyWebApp.isSetSecurityRealmName()) {
                 configureSecurityRealm(earContext, webApp, jettyWebApp, webModuleData);
@@ -621,14 +627,14 @@
         earContext.addSecurityContext(policyContextID, componentPermissions);
     }
 
-    private void addDefaultServletsGBeans(EARContext earContext, EARContext moduleContext,
AbstractName moduleName, Set knownServletMappings) throws GBeanNotFoundException, GBeanAlreadyExistsException
{
+    private void addDefaultServletsGBeans(EARContext earContext, EARContext moduleContext,
AbstractName moduleName, Set knownServletMappings, GBeanData contextManager) throws GBeanNotFoundException,
GBeanAlreadyExistsException {
         for (Object defaultServlet : defaultServlets) {
-            GBeanData servletGBeanData = configureDefaultServlet(defaultServlet, earContext,
moduleName, knownServletMappings);
+            GBeanData servletGBeanData = configureDefaultServlet(defaultServlet, earContext,
moduleName, knownServletMappings, contextManager);
             moduleContext.addGBean(servletGBeanData);
         }
     }
 
-    private GBeanData configureDefaultServlet(Object defaultServlet, EARContext earContext,
AbstractName moduleName, Set knownServletMappings) throws GBeanNotFoundException, GBeanAlreadyExistsException
{
+    private GBeanData configureDefaultServlet(Object defaultServlet, EARContext earContext,
AbstractName moduleName, Set knownServletMappings, GBeanData contextManager) throws GBeanNotFoundException,
GBeanAlreadyExistsException {
         GBeanData servletGBeanData = getGBeanData(kernel, defaultServlet);
         AbstractName defaultServletObjectName = earContext.getNaming().createChildName(moduleName,
(String) servletGBeanData.getAttribute("servletName"), NameFactory.SERVLET);
         servletGBeanData.setAbstractName(defaultServletObjectName);
@@ -636,6 +642,7 @@
         Set<String> defaultServletMappings = new HashSet<String>((Collection<String>)
servletGBeanData.getAttribute("servletMappings"));
         defaultServletMappings.removeAll(knownServletMappings);
         servletGBeanData.setAttribute("servletMappings", defaultServletMappings);
+        contextManager.addDependency(defaultServletObjectName);
         return servletGBeanData;
     }
 
@@ -1029,7 +1036,8 @@
                              Module module,
                              ServletType[] servletTypes,
                              Map<String, Set<String>> servletMappings,
-                             EARContext moduleContext) throws DeploymentException {
+                             EARContext moduleContext,
+                             GBeanData contextManager) throws DeploymentException {
 
         // this TreeSet will order the ServletTypes based on whether
         // they have a load-on-startup element and what its value is
@@ -1051,6 +1059,7 @@
         for (Object aLoadOrder : loadOrder) {
             ServletType servletType = (ServletType) aLoadOrder;
             previousServlet = addServlet(webModuleName, module, previousServlet, servletType,
servletMappings, moduleContext);
+            contextManager.addDependency(previousServlet);
         }
     }
 
@@ -1094,7 +1103,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);
@@ -1128,7 +1136,7 @@
         if (null != previousServlet) {
             servletData.addDependency(previousServlet);
         }
-
+        
         //TODO in init param setter, add classpath if jspFile is not null.
         servletData.setReferencePattern("JettyServletRegistration", webModuleName);
         servletData.setAttribute("servletName", 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=918095&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
Tue Mar  2 16:04:57 2010
@@ -0,0 +1,51 @@
+/**
+ *  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;
+
+/**
+ * Lifecycle manager for WebAppContextWrapper. The gbean starts the WebAppContextWrapper
+ * once all servlets associated with the context are started.
+ * 
+ * @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() {
+        webApp.doFail();
+    }
+
+    public void doStart() throws Exception {
+        webApp.doStart();
+    }
+
+    public void doStop() throws Exception {
+        webApp.doStop();
+    }
+
+}

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=918095&r1=918094&r2=918095&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
Tue Mar  2 16:04:57 2010
@@ -70,7 +70,7 @@
 
 @GBean(name="Jetty WebApplication Context",
 j2eeType=NameFactory.WEB_MODULE)
-public class WebAppContextWrapper implements GBeanLifecycle, JettyServletRegistration, WebModule
{
+public class WebAppContextWrapper implements JettyServletRegistration, WebModule {
     private static final Logger log = LoggerFactory.getLogger(WebAppContextWrapper.class);
     public static final String GBEAN_ATTR_SESSION_TIMEOUT = "sessionTimeoutSeconds";
     public static final String GBEAN_REF_SESSION_HANDLER_FACTORY = "SessionHandlerFactory";
@@ -302,15 +302,17 @@
             }
         }
     }
-
+        
     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();
+        webAppContext.registerServletContext();
     }
 
     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=918095&r1=918094&r2=918095&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
Tue Mar  2 16:04:57 2010
@@ -79,18 +79,24 @@
             integrationContext.restoreContext(context);
             integrationContext.completeTx(txActive, null);
         }
+    }
+
+    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());
         }
     }
-
-    @Override
-    protected void doStop() throws Exception {
+    
+    public void unregisterServletContext() {
         if (serviceRegistration != null) {
             serviceRegistration.unregister();
         }
+    }
+    
+    @Override
+    protected void doStop() throws Exception {
         javax.naming.Context context = integrationContext.setContext();
         boolean txActive = integrationContext.isTxActive();
         SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null);

Modified: geronimo/server/trunk/plugins/jetty8/jetty8-deployer/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/jetty8-deployer/pom.xml?rev=918095&r1=918094&r2=918095&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/jetty8-deployer/pom.xml (original)
+++ geronimo/server/trunk/plugins/jetty8/jetty8-deployer/pom.xml Tue Mar  2 16:04:57 2010
@@ -30,7 +30,7 @@
     
     <groupId>org.apache.geronimo.configs</groupId>
     <artifactId>jetty8-deployer</artifactId>
-    <name>Geronimo Plugins, Jetty :: Deployer</name>
+    <name>Geronimo Plugins, Jetty 8 :: Deployer</name>
     <packaging>car</packaging>
 
     <description>Geronimo deployer for Jetty 8 Web Server integration.</description>

Modified: geronimo/server/trunk/plugins/jetty8/jetty8/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/jetty8/pom.xml?rev=918095&r1=918094&r2=918095&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/jetty8/pom.xml (original)
+++ geronimo/server/trunk/plugins/jetty8/jetty8/pom.xml Tue Mar  2 16:04:57 2010
@@ -30,7 +30,7 @@
 
     <groupId>org.apache.geronimo.configs</groupId>
     <artifactId>jetty8</artifactId>
-    <name>Geronimo Plugins, Jetty :: Jetty 8</name>
+    <name>Geronimo Plugins, Jetty 8 :: Jetty 8</name>
     <packaging>car</packaging>
 
     <description>Geronimo Jetty Web Server integration.</description>

Modified: geronimo/server/trunk/plugins/jetty8/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/pom.xml?rev=918095&r1=918094&r2=918095&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/pom.xml (original)
+++ geronimo/server/trunk/plugins/jetty8/pom.xml Tue Mar  2 16:04:57 2010
@@ -25,7 +25,7 @@
     </parent>
 
     <artifactId>jetty8</artifactId>
-    <name>Geronimo Plugins, jetty8</name>
+    <name>Geronimo Plugins, Jetty 8</name>
     <packaging>pom</packaging>
 
     <description>



Mime
View raw message