You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ri...@apache.org on 2010/10/26 18:55:23 UTC

svn commit: r1027647 - in /geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7: WebAppContextWrapper.java handler/GeronimoWebAppContext.java

Author: rickmcguire
Date: Tue Oct 26 16:55:22 2010
New Revision: 1027647

URL: http://svn.apache.org/viewvc?rev=1027647&view=rev
Log:
additional fixes for the jetty 7.2.0 upgrade

Modified:
    geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/WebAppContextWrapper.java
    geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/GeronimoWebAppContext.java

Modified: geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/WebAppContextWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/WebAppContextWrapper.java?rev=1027647&r1=1027646&r2=1027647&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/WebAppContextWrapper.java (original)
+++ geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/WebAppContextWrapper.java Tue Oct 26 16:55:22 2010
@@ -243,11 +243,9 @@ public class WebAppContextWrapper implem
         setDisplayName(displayName);
         
         if (contextParamMap != null && contextParamMap.size() > 0) {
-            
-            for (Entry<String, String> entry : contextParamMap.entrySet()) {
-
-                webAppContext.getServletContext().setInitParameter(entry.getKey(), entry.getValue());
-            }
+            // setting of the parameters needs to be delayed until 
+            // doStart() is called. 
+            webAppContext.setContextParamMap(contextParamMap);
         }
 
         setListenerClassNames(listenerClassNames);
@@ -316,6 +314,13 @@ public class WebAppContextWrapper implem
         return (Servlet)holder.newInstance(className, webClassLoader, componentContext);
     }
 
+    public Object newFilterInstance(String className) throws InstantiationException, IllegalAccessException {
+        if (className == null) {
+            throw new InstantiationException("no class loaded");
+        }
+        return holder.newInstance(className, webClassLoader, componentContext);
+    }
+
     public void destroyInstance(Object o) throws Exception {
         Class clazz = o.getClass();
         if (holder != null) {
@@ -362,7 +367,7 @@ public class WebAppContextWrapper implem
         if (eventListeners != null) {
             Collection<EventListener> listeners = new ArrayList<EventListener>();
             for (String listenerClassName : eventListeners) {
-                EventListener listener = (EventListener) newInstance(listenerClassName);
+                EventListener listener = (EventListener) newFilterInstance(listenerClassName);
                 listeners.add(listener);
             }
             webAppContext.setEventListeners(listeners.toArray(new EventListener[listeners.size()]));

Modified: geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/GeronimoWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/GeronimoWebAppContext.java?rev=1027647&r1=1027646&r2=1027647&view=diff
==============================================================================
--- geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/GeronimoWebAppContext.java (original)
+++ geronimo/server/branches/2.2/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/GeronimoWebAppContext.java Tue Oct 26 16:55:22 2010
@@ -21,6 +21,8 @@
 package org.apache.geronimo.jetty7.handler;
 
 import java.io.IOException;
+import java.util.Map; 
+import java.util.Map.Entry;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -44,6 +46,7 @@ public class GeronimoWebAppContext exten
 
     private Handler handler;
     protected final IntegrationContext integrationContext;
+    protected Map<String, String> contextParamMap; 
 
 
     public GeronimoWebAppContext(SecurityHandler securityHandler, SessionHandler sessionHandler, ServletHandler servletHandler, ErrorHandler errorHandler, IntegrationContext integrationContext, ClassLoader classLoader) {
@@ -51,8 +54,20 @@ public class GeronimoWebAppContext exten
         this.integrationContext = integrationContext;
         setClassLoader(classLoader);
     }
+    
+    /**
+     * Set any context parameters that need to be set during 
+     * the doStart() phase of the initialization.  
+     * 
+     * @param contextParamMap
+     *               The parameter map;
+     */
+    public void setContextParamMap(Map<String, String> contextParamMap) {
+        this.contextParamMap = contextParamMap; 
+    }
 
-    public void setTwistyHandler(Handler handler) {
+    public void setTwistyHandler(Handler handler)  
+    {  
         this.handler = handler;
     }
 
@@ -62,6 +77,17 @@ public class GeronimoWebAppContext exten
 
     @Override
     protected void doStart() throws Exception {
+        // jetty 7.2.0 forces the setInitParameter() calls to be delayed until 
+        // the doStart() method is called.  Set these before allowing the superclass to 
+        // complete startup. 
+        if (contextParamMap != null && contextParamMap.size() > 0) {
+            
+            for (Entry<String, String> entry : contextParamMap.entrySet()) {
+
+                getServletContext().setInitParameter(entry.getKey(), entry.getValue());
+            }
+        }
+        
         javax.naming.Context context = integrationContext.setContext();
         boolean txActive = integrationContext.isTxActive();
         SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null);