incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r679169 - /incubator/sling/trunk/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/SlingServletResolver.java
Date Wed, 23 Jul 2008 19:44:21 GMT
Author: bdelacretaz
Date: Wed Jul 23 12:44:21 2008
New Revision: 679169

URL: http://svn.apache.org/viewvc?rev=679169&view=rev
Log:
SLING-580 - improve SlingServletResolver logging

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

Modified: incubator/sling/trunk/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/SlingServletResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/SlingServletResolver.java?rev=679169&r1=679168&r2=679169&view=diff
==============================================================================
--- incubator/sling/trunk/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/SlingServletResolver.java
(original)
+++ incubator/sling/trunk/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/SlingServletResolver.java
Wed Jul 23 12:44:21 2008
@@ -128,24 +128,38 @@
 
         Servlet servlet = null;
 
+        final String type = resource.getResourceType();
+        if(log.isDebugEnabled()) {
+        	log.debug("resolveServlet called for Resource {}", request.getResource());
+        }
+        
         // first check whether the type of a resource is the absolute
         // path of a servlet (or script)
-        String type = resource.getResourceType();
         if (type.charAt(0) == '/') {
             Resource res = request.getResourceResolver().getResource(type);
             if (res != null) {
                 servlet = res.adaptTo(Servlet.class);
             }
+            if(servlet!=null && log.isDebugEnabled()) {
+            	log.debug("Servlet {} found using absolute resource type {}", RequestUtil.getServletName(servlet),
type);
+            }
         }
 
         // the resource type is not absolute, so lets go for the deep search
         if (servlet == null) {
             ResourceCollector locationUtil = ResourceCollector.create(request);
             servlet = getServlet(locationUtil, request, resource);
+            
+            if(log.isDebugEnabled()) {
+            	log.debug("getServlet returns Servlet {}", RequestUtil.getServletName(servlet));
+            }
         }
 
         // last resort, use the core bundle default servlet
         if (servlet == null) {
+            if(log.isDebugEnabled()) {
+            	log.debug("No specific Servlet found, trying default");
+            }
             servlet = getDefaultServlet();
         }
 
@@ -379,13 +393,37 @@
     private Servlet getServlet(ResourceCollector locationUtil,
             SlingHttpServletRequest request, Resource resource) {
         Collection<Resource> candidates = locationUtil.getServlets(resource);
+        
+    	if(log.isDebugEnabled()) {
+    		if(candidates.isEmpty()) {
+        		log.debug("No Servlet candidates found");
+    		} else {
+        		log.debug("Ordered list of Servlet candidates follows");
+                for (Resource candidateResource : candidates) {
+                	log.debug("Servlet candidate: {}", candidateResource.getPath());
+                }
+    		}
+    	}
+    	
         for (Resource candidateResource : candidates) {
+        	if(log.isDebugEnabled()) {
+        		log.debug("Checking if candidate Resource {} adapts to Servlet and accepts request",

+        				candidateResource.getPath());
+        	}
             Servlet candidate = candidateResource.adaptTo(Servlet.class);
             if (candidate != null) {
                 boolean servletAcceptsRequest = !(candidate instanceof OptingServlet)
                     || ((OptingServlet) candidate).accepts(request);
                 if (servletAcceptsRequest) {
                     return candidate;
+                } else {
+                	if(log.isDebugEnabled()) {
+                		log.debug("Candidate {} does not accept request, ignored", candidateResource.getPath());
+                	}
+                }
+            } else {
+                if(log.isDebugEnabled()) {
+                	log.debug("Candidate {} does not adapt to a Servlet, ignored", candidateResource.getPath());

                 }
             }
         }



Mime
View raw message