incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r611797 - /incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/defaults/DefaultServlet.java
Date Mon, 14 Jan 2008 14:05:14 GMT
Author: fmeschbe
Date: Mon Jan 14 06:05:13 2008
New Revision: 611797

URL: http://svn.apache.org/viewvc?rev=611797&view=rev
Log:
If the request has no extension and the resource adapts to a Servlet
call the servlet instead. Otherwise continue dumping the properties.

This functionality may be used to directly address scripts (and 
servlets) like http://host/some/path/index.jsp.

Modified:
    incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/defaults/DefaultServlet.java

Modified: incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/defaults/DefaultServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/defaults/DefaultServlet.java?rev=611797&r1=611796&r2=611797&view=diff
==============================================================================
--- incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/defaults/DefaultServlet.java
(original)
+++ incubator/sling/whiteboard/fmeschbe/resource/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/defaults/DefaultServlet.java
Mon Jan 14 06:05:13 2008
@@ -28,6 +28,8 @@
 import java.util.Properties;
 import java.util.TreeMap;
 
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.beanutils.BeanMap;
@@ -40,15 +42,15 @@
 /**
  * The <code>DefaultServlet</code> is a very simple default resource handler.
  * <p>
- * The default servlet is not registered to handle any concrete resource
- * type. Rather it is used internally on demand.
- *
+ * The default servlet is not registered to handle any concrete resource type.
+ * Rather it is used internally on demand.
  */
 public class DefaultServlet extends SlingSafeMethodsServlet {
 
     @Override
     protected void doGet(SlingHttpServletRequest request,
-            SlingHttpServletResponse response) throws IOException {
+            SlingHttpServletResponse response) throws ServletException,
+            IOException {
 
         Resource resource = request.getResource();
 
@@ -58,8 +60,18 @@
             return;
         }
 
-        // format response according to extension (use Mime mapping instead)
         String extension = request.getRequestPathInfo().getExtension();
+
+        // check whether we have a directly addressed script
+        if (extension == null) {
+            Servlet resourceServlet = resource.adaptTo(Servlet.class);
+            if (resourceServlet != null) {
+                resourceServlet.service(request, response);
+                return;
+            }
+        }
+
+        // format response according to extension (use Mime mapping instead)
         if ("html".equals(extension) || "htm".equals(extension)) {
             this.renderContentHtml(resource, response);
         } else if ("xml".equals(extension)) {
@@ -223,7 +235,7 @@
 
     @SuppressWarnings("unchecked")
     private Map<Object, Object> asMap(Resource resource) {
-        
+
         Object object = resource.adaptTo(Object.class);
         if (object != null) {
             if (object instanceof Map) {



Mime
View raw message