incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r610055 - /incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/SlingServletResolver.java
Date Tue, 08 Jan 2008 16:27:12 GMT
Author: cziegeler
Date: Tue Jan  8 08:27:11 2008
New Revision: 610055

URL: http://svn.apache.org/viewvc?rev=610055&view=rev
Log:
Quick fix to always register servlets: if servlets and the servlet context are registered
before activate is called, the servlets were either never registered or an npe occured during
registration.

Modified:
    incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/SlingServletResolver.java

Modified: incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/SlingServletResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/SlingServletResolver.java?rev=610055&r1=610054&r2=610055&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/SlingServletResolver.java
(original)
+++ incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/SlingServletResolver.java
Tue Jan  8 08:27:11 2008
@@ -18,9 +18,13 @@
  */
 package org.apache.sling.servlet.resolver;
 
-import static org.apache.sling.api.SlingConstants.*;
-import static org.apache.sling.core.CoreConstants.*;
-import static org.apache.sling.servlet.resolver.ServletResolverConstants.*;
+import static org.apache.sling.api.SlingConstants.ERROR_MESSAGE;
+import static org.apache.sling.api.SlingConstants.ERROR_REQUEST_URI;
+import static org.apache.sling.api.SlingConstants.ERROR_SERVLET_NAME;
+import static org.apache.sling.api.SlingConstants.ERROR_STATUS;
+import static org.apache.sling.core.CoreConstants.SLING_CURRENT_SERVLET_NAME;
+import static org.apache.sling.servlet.resolver.ServletResolverConstants.DEFAULT_SERVLET_NAME;
+import static org.apache.sling.servlet.resolver.ServletResolverConstants.SLING_RESOURCE_TYPES;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -339,6 +343,16 @@
                 }
             }
         }
+        List<ServiceReference> refs = null;
+        synchronized (this) {
+            if ( this.servletContext != null ) {
+                refs = this.pendingServlets;
+                this.pendingServlets = new ArrayList<ServiceReference>();
+            }
+        }
+        if ( refs != null ) {
+            this.createAllServlets(this.servletContext, refs);
+        }
     }
 
     protected synchronized void bindServlet(ServiceReference reference) {
@@ -366,8 +380,12 @@
 
             if (this.servletContext == null) {
 
-                refs = pendingServlets;
-                pendingServlets = new ArrayList<ServiceReference>();
+                if ( this.context != null ) {
+                    refs = pendingServlets;
+                    pendingServlets = new ArrayList<ServiceReference>();
+                } else {
+                    refs = null;
+                }
                 destroy = false;
 
             } else {
@@ -384,7 +402,9 @@
             destroyAllServlets(refs);
         }
 
-        createAllServlets(this.servletContext, refs);
+        if ( refs != null ) {
+            createAllServlets(this.servletContext, refs);
+        }
     }
 
     protected void unbindServletContext(ServletContext oldServletContext) {



Mime
View raw message