incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r907970 - in /sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource: ServletResource.java ServletResourceProvider.java
Date Tue, 09 Feb 2010 08:47:57 GMT
Author: cziegeler
Date: Tue Feb  9 08:47:57 2010
New Revision: 907970

URL: http://svn.apache.org/viewvc?rev=907970&view=rev
Log:
Cleanup

Modified:
    sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResource.java
    sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResourceProvider.java

Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResource.java?rev=907970&r1=907969&r2=907970&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResource.java
(original)
+++ sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResource.java
Tue Feb  9 08:47:57 2010
@@ -18,12 +18,17 @@
  */
 package org.apache.sling.servlets.resolver.internal.resource;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.servlet.Servlet;
 
 import org.apache.sling.adapter.SlingAdaptable;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ValueMap;
+import org.apache.sling.api.wrappers.ValueMapDecorator;
 
 class ServletResource extends SlingAdaptable implements Resource {
 
@@ -70,17 +75,7 @@
         return path;
     }
 
-    @SuppressWarnings("unchecked")
-    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
-        if (type == Servlet.class) {
-            return (AdapterType) servlet; // unchecked cast
-        }
-
-        return super.adaptTo(type);
-    }
-
-    public String toString() {
-        // prepare the servlet name
+    private String getServletName() {
         String servletName = null;
         if (servlet.getServletConfig() != null) {
             servletName = servlet.getServletConfig().getServletName();
@@ -91,8 +86,28 @@
         if (servletName == null) {
             servletName = servlet.getClass().getName();
         }
+        return servletName;
+    }
 
-        return getClass().getSimpleName() + ", servlet=" + servletName
+    @SuppressWarnings("unchecked")
+    public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
+        if (type == Servlet.class) {
+            return (AdapterType) servlet; // unchecked cast
+        } else if ( type == ValueMap.class ) {
+            final Map<String, Object> props = new HashMap<String, Object>();
+            props.put("sling:resourceType", this.getResourceType());
+            props.put("sling:resourceSuperType", this.getResourceSuperType());
+            props.put("servletName", this.getServletName());
+            props.put("servletClass", this.servlet.getClass().getName());
+
+            return (AdapterType) new ValueMapDecorator(props); // unchecked cast
+        }
+
+        return super.adaptTo(type);
+    }
+
+    public String toString() {
+        return getClass().getSimpleName() + ", servlet=" + this.getServletName()
             + ", path=" + getPath();
     }
 

Modified: sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResourceProvider.java?rev=907970&r1=907969&r2=907970&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResourceProvider.java
(original)
+++ sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResourceProvider.java
Tue Feb  9 08:47:57 2010
@@ -42,7 +42,7 @@
     public void setServlet(Servlet servlet) {
         this.servlet = servlet;
     }
-    
+
     public Resource getResource(ResourceResolver resourceResolver,
             HttpServletRequest request, String path) {
         return getResource(resourceResolver, path);
@@ -72,12 +72,12 @@
     public String[] getSerlvetPaths() {
         return resourcePaths.toArray(new String[resourcePaths.size()]);
     }
-    
+
     /** Return suitable info for logging */
     @Override
     public String toString() {
-    	return getClass().getSimpleName() 
-    	+ ": servlet=" + servlet.getClass().getName() 
-    	+ ", paths=" + Arrays.asList(resourcePaths);
+    	return getClass().getSimpleName()
+    	+ ": servlet=" + servlet.getClass().getName()
+    	+ ", paths=" + Arrays.toString(getSerlvetPaths());
     }
 }



Mime
View raw message