incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r980158 - in /sling/trunk/bundles: scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResource.java
Date Wed, 28 Jul 2010 18:56:01 GMT
Author: fmeschbe
Date: Wed Jul 28 18:56:01 2010
New Revision: 980158

URL: http://svn.apache.org/viewvc?rev=980158&view=rev
Log:
SLING-1193 Adapt ServletResource and DefaultSlingScript to new Resource API

Modified:
    sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java
    sling/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/resource/ServletResource.java

Modified: sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java?rev=980158&r1=980157&r2=980158&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java
(original)
+++ sling/trunk/bundles/scripting/core/src/main/java/org/apache/sling/scripting/core/impl/DefaultSlingScript.java
Wed Jul 28 18:56:01 2010
@@ -61,6 +61,7 @@ import org.apache.sling.api.SlingHttpSer
 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.ResourceWrapper;
 import org.apache.sling.api.resource.SyntheticResource;
 import org.apache.sling.api.scripting.ScriptEvaluationException;
 import org.apache.sling.api.scripting.SlingBindings;
@@ -682,7 +683,7 @@ class DefaultSlingScript implements Slin
      * This is a lazy implementation of the script resource which
      * just returns the path, resource type and resource resolver directly.
      */
-    private static final class LazyScriptResource implements Resource {
+    private static final class LazyScriptResource extends ResourceWrapper {
 
         private final String path;
 
@@ -693,11 +694,24 @@ class DefaultSlingScript implements Slin
         private Resource delegatee;
 
         public LazyScriptResource(final String path, final String resourceType, final ResourceResolver
resolver) {
+            super(null);
             this.path = path;
             this.resourceType = resourceType;
             this.resolver = resolver;
         }
 
+        @Override
+        public Resource getResource() {
+            if (this.delegatee == null) {
+                this.delegatee = this.resolver.getResource(this.path);
+                if (this.delegatee == null) {
+                    this.delegatee = new SyntheticResource(resolver, this.path,
+                        this.resourceType);
+                }
+            }
+            return this.delegatee;
+        }
+
         /**
          * @see org.apache.sling.api.resource.Resource#getPath()
          */
@@ -718,36 +732,5 @@ class DefaultSlingScript implements Slin
         public ResourceResolver getResourceResolver() {
             return this.resolver;
         }
-
-        private Resource getResource() {
-            if ( this.delegatee == null ) {
-                this.delegatee = this.resolver.getResource(this.path);
-                if ( this.delegatee == null ) {
-                    this.delegatee = new SyntheticResource(resolver, this.path, this.resourceType);
-                }
-            }
-            return this.delegatee;
-        }
-
-        /**
-         * @see org.apache.sling.api.resource.Resource#getResourceMetadata()
-         */
-        public ResourceMetadata getResourceMetadata() {
-            return this.getResource().getResourceMetadata();
-        }
-
-        /**
-         * @see org.apache.sling.api.resource.Resource#getResourceSuperType()
-         */
-        public String getResourceSuperType() {
-            return this.getResource().getResourceSuperType();
-        }
-
-        /**
-         * @see org.apache.sling.api.adapter.Adaptable#adaptTo(java.lang.Class)
-         */
-        public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
-            return this.getResource().adaptTo(type);
-        }
     }
 }
\ No newline at end of file

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=980158&r1=980157&r2=980158&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
Wed Jul 28 18:56:01 2010
@@ -23,14 +23,14 @@ import java.util.Map;
 
 import javax.servlet.Servlet;
 
-import org.apache.sling.adapter.SlingAdaptable;
+import org.apache.sling.api.resource.AbstractResource;
 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 {
+class ServletResource extends AbstractResource implements Resource {
 
     private final ResourceResolver resourceResolver;
 



Mime
View raw message