incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r920872 - in /sling/trunk/bundles: api/src/main/java/org/apache/sling/api/resource/ jcr/resource/ jcr/resource/src/main/java/org/apache/sling/jcr/resource/ jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ jcr/resource/src/...
Date Tue, 09 Mar 2010 13:38:35 GMT
Author: cziegeler
Date: Tue Mar  9 13:38:34 2010
New Revision: 920872

URL: http://svn.apache.org/viewvc?rev=920872&view=rev
Log:
SLING-1430 - RemoveJcrResourceTypeProvider
SLING-1429 - Add support for ResourceDecorator interface

Added:
    sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceDecorator.java   (with props)
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceDecoratorTracker.java   (with props)
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceIteratorDecorator.java   (with props)
Removed:
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/JcrResourceTypeProvider.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImplTest.java
Modified:
    sling/trunk/bundles/jcr/resource/pom.xml
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrPropertyResource.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
    sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderEntry.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIteratorTest.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceTest.java
    sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java

Added: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceDecorator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceDecorator.java?rev=920872&view=auto
==============================================================================
--- sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceDecorator.java (added)
+++ sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceDecorator.java Tue Mar  9 13:38:34 2010
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.api.resource;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Optional services to decorate {@link Resource}s returned by
+ * the {@link ResourceResolver}.
+ * Use cases for a decorator are
+ * - overwrite resource type/resource super type (for example
+ *   based on the resource path)
+ * - add metadata
+ *
+ * @since 2.1
+ */
+public interface ResourceDecorator {
+
+    /**
+     * Decorate a resource.
+     * If the service decorates the resource it should return
+     * the new resource. IF the servie does not want to decorate
+     * the resource, it should return the original resource.
+     * Returning <code>null</code> is considered the same as
+     * returning the original resource.
+     * @param resource The resource to decorate
+     * @return The decorated resource or the original resource.
+     */
+    Resource decorate(Resource resource);
+
+    /**
+     * Decorate a resource.
+     * If the service decorates the resource it should return
+     * the new resource. IF the servie does not want to decorate
+     * the resource, it should return the original resource.
+     * Returning <code>null</code> is considered the same as
+     * returning the original resource.
+     * @param resource The resource to decorate
+     * @param request The current request.
+     * @return The decorated resource or the original resource.
+     */
+    Resource decorate(Resource resource, HttpServletRequest request);
+}

Propchange: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceDecorator.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ResourceDecorator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/bundles/jcr/resource/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/pom.xml?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/pom.xml (original)
+++ sling/trunk/bundles/jcr/resource/pom.xml Tue Mar  9 13:38:34 2010
@@ -52,6 +52,14 @@
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-scr-plugin</artifactId>
+                <version>1.4.2</version>
+                    <dependencies>
+                        <dependency>
+                            <groupId>org.slf4j</groupId>
+                            <artifactId>slf4j-simple</artifactId>
+                            <version>1.5.2</version>
+                        </dependency>
+                    </dependencies>
             </plugin>
             <plugin>
                 <groupId>org.apache.felix</groupId>

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java Tue Mar  9 13:38:34 2010
@@ -184,8 +184,10 @@ public class JcrResourceResolver extends
 
                     // external redirect
                     log.debug("resolve: Returning external redirect");
-                    return new RedirectResource(this, absPath, mappedPath[0],
-                        mapEntry.getStatus());
+                    return this.factory.getResourceDecoratorTracker().decorate(
+                            new RedirectResource(this, absPath, mappedPath[0],
+                                   mapEntry.getStatus()),
+                             request);
                 }
             }
 
@@ -279,7 +281,7 @@ public class JcrResourceResolver extends
             log.debug("resolve: Path {} resolves to Resource {}", absPath, res);
         }
 
-        return res;
+        return this.factory.getResourceDecoratorTracker().decorate(res, request);
     }
 
     /**
@@ -476,7 +478,11 @@ public class JcrResourceResolver extends
         // if the path is absolute, normalize . and .. segements and get res
         if (path.startsWith("/")) {
             path = ResourceUtil.normalize(path);
-            return (path != null) ? getResourceInternal(path) : null;
+            final Resource result = (path != null) ? getResourceInternal(path) : null;
+            if ( result != null ) {
+                return this.factory.getResourceDecoratorTracker().decorate(result, null);
+            }
+            return null;
         }
 
         // otherwise we have to apply the search path
@@ -510,7 +516,8 @@ public class JcrResourceResolver extends
      */
     public Iterator<Resource> listChildren(Resource parent) {
         checkClosed();
-        return rootProvider.listChildren(parent);
+        return new ResourceIteratorDecorator(this.factory.getResourceDecoratorTracker(),
+                rootProvider.listChildren(parent));
     }
 
     // ---------- Querying resources
@@ -524,8 +531,9 @@ public class JcrResourceResolver extends
         try {
             QueryResult res = JcrResourceUtil.query(getSession(), query,
                 language);
-            return new JcrNodeResourceIterator(this, res.getNodes(),
-                rootProvider.getResourceTypeProviders(), factory.getDynamicClassLoader());
+            return new ResourceIteratorDecorator(this.factory.getResourceDecoratorTracker(),
+                    new JcrNodeResourceIterator(this, res.getNodes(),
+                     factory.getDynamicClassLoader()));
         } catch (javax.jcr.query.InvalidQueryException iqe) {
             throw new QuerySyntaxException(iqe.getMessage(), query, language,
                 iqe);

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverFactoryImpl.java Tue Mar  9 13:38:34 2010
@@ -19,13 +19,11 @@
 package org.apache.sling.jcr.resource.internal;
 
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
 import java.util.Dictionary;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.regex.Pattern;
 
 import javax.jcr.Session;
@@ -33,13 +31,13 @@ import javax.jcr.Session;
 import org.apache.commons.collections.BidiMap;
 import org.apache.commons.collections.bidimap.TreeBidiMap;
 import org.apache.sling.api.SlingConstants;
+import org.apache.sling.api.resource.ResourceDecorator;
 import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
 import org.apache.sling.commons.osgi.OsgiUtil;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.jcr.resource.JcrResourceResolverFactory;
-import org.apache.sling.jcr.resource.JcrResourceTypeProvider;
 import org.apache.sling.jcr.resource.internal.helper.MapEntries;
 import org.apache.sling.jcr.resource.internal.helper.Mapping;
 import org.apache.sling.jcr.resource.internal.helper.ResourceProviderEntry;
@@ -65,7 +63,7 @@ import org.slf4j.LoggerFactory;
  * </ul>
  *
  * @scr.component immediate="true" label="%resource.resolver.name"
- *                description="%resource.resolver.description"
+ *                description="%resource.resolver.description" specVersion="1.1"
  * @scr.property name="service.description"
  *                value="Sling JcrResourceResolverFactory Implementation"
  * @scr.property name="service.vendor" value="The Apache Software Foundation"
@@ -73,8 +71,8 @@ import org.slf4j.LoggerFactory;
  * @scr.reference name="ResourceProvider"
  *                interface="org.apache.sling.api.resource.ResourceProvider"
  *                cardinality="0..n" policy="dynamic"
- * @scr.reference name="JcrResourceTypeProvider"
- *                interface="org.apache.sling.jcr.resource.JcrResourceTypeProvider"
+ * @scr.reference name="ResourceDecorator"
+ *                interface="org.apache.sling.api.resource.ResourceDecorator"
  *                cardinality="0..n" policy="dynamic"
  */
 public class JcrResourceResolverFactoryImpl implements
@@ -159,27 +157,13 @@ public class JcrResourceResolverFactoryI
     private SlingRepository repository;
 
     /**
-     * The (optional) resource type providers, working copy.
-     */
-    protected final List<JcrResourceTypeProviderEntry> jcrResourceTypeProviders = new ArrayList<JcrResourceTypeProviderEntry>();
-
-    /**
-     * An array of the above, updates when changes are created.
-     */
-    private JcrResourceTypeProvider[] jcrResourceTypeProvidersArray;
-
-    /**
      * List of ResourceProvider services bound before activation of the
      * component.
      */
     private final List<ServiceReference> delayedResourceProviders = new LinkedList<ServiceReference>();
 
-    /**
-     * List of JcrResourceTypeProvider services bound before activation of the
-     * component.
-     */
-    protected List<ServiceReference> delayedJcrResourceTypeProviders = new LinkedList<ServiceReference>();
-
+    /** Tracker for the resource decorators. */
+    private final ResourceDecoratorTracker resourceDecoratorTracker = new ResourceDecoratorTracker();
 
     protected ComponentContext componentContext;
 
@@ -222,6 +206,10 @@ public class JcrResourceResolverFactoryI
 
     }
 
+    public ResourceDecoratorTracker getResourceDecoratorTracker() {
+        return this.resourceDecoratorTracker;
+    }
+
     // ---------- JcrResourceResolverFactory -----------------------------------
 
     /**
@@ -230,16 +218,12 @@ public class JcrResourceResolverFactoryI
      */
     public ResourceResolver getResourceResolver(Session session) {
         JcrResourceProviderEntry sessionRoot = new JcrResourceProviderEntry(
-            session, rootProviderEntry, getJcrResourceTypeProviders(),
+            session, rootProviderEntry,
             this.getDynamicClassLoader());
 
         return new JcrResourceResolver(sessionRoot, this, mapEntries);
     }
 
-    protected JcrResourceTypeProvider[] getJcrResourceTypeProviders() {
-        return jcrResourceTypeProvidersArray;
-    }
-
     // ---------- Implementation helpers --------------------------------------
 
     /** Get the dynamic class loader if available */
@@ -307,7 +291,7 @@ public class JcrResourceResolverFactoryI
     // ---------- SCR Integration ---------------------------------------------
 
     /** Activates this component, called by SCR before registering as a service */
-    protected void activate(ComponentContext componentContext) {
+    protected void activate(final ComponentContext componentContext) {
         // setup tracker first as this is used in the bind/unbind methods
         this.eventAdminTracker = new ServiceTracker(componentContext.getBundleContext(),
                 EventAdmin.class.getName(), null);
@@ -375,7 +359,6 @@ public class JcrResourceResolverFactoryI
             bindResourceProvider(reference);
         }
         delayedResourceProviders.clear();
-        this.processDelayedJcrResourceTypeProviders();
 
         // set up the map entries from configuration
         try {
@@ -407,7 +390,7 @@ public class JcrResourceResolverFactoryI
     private JcrResourceResolverWebConsolePlugin plugin;
 
     /** Deativates this component, called by SCR to take out of service */
-    protected void deactivate(ComponentContext componentContext) {
+    protected void deactivate(final ComponentContext componentContext) {
         if (plugin != null) {
             plugin.dispose();
             plugin = null;
@@ -426,49 +409,7 @@ public class JcrResourceResolverFactoryI
             this.resourceListener = null;
         }
         this.componentContext = null;
-    }
-
-    protected void processDelayedJcrResourceTypeProviders() {
-        synchronized (this.jcrResourceTypeProviders) {
-            for (ServiceReference reference : delayedJcrResourceTypeProviders) {
-                this.addJcrResourceTypeProvider(reference);
-            }
-            delayedJcrResourceTypeProviders.clear();
-            updateJcrResourceTypeProvidersArray();
-
-        }
-    }
-
-    protected void addJcrResourceTypeProvider(final ServiceReference reference) {
-        final Long id = (Long) reference.getProperty(Constants.SERVICE_ID);
-        long ranking = -1;
-        if (reference.getProperty(Constants.SERVICE_RANKING) != null) {
-            ranking = (Long) reference.getProperty(Constants.SERVICE_RANKING);
-        }
-        this.jcrResourceTypeProviders.add(new JcrResourceTypeProviderEntry(id,
-            ranking,
-            (JcrResourceTypeProvider) this.componentContext.locateService(
-                "JcrResourceTypeProvider", reference)));
-        Collections.sort(this.jcrResourceTypeProviders,
-            new Comparator<JcrResourceTypeProviderEntry>() {
-
-                public int compare(JcrResourceTypeProviderEntry o1,
-                        JcrResourceTypeProviderEntry o2) {
-                    if (o1.ranking < o2.ranking) {
-                        return 1;
-                    } else if (o1.ranking > o2.ranking) {
-                        return -1;
-                    } else {
-                        if (o1.serviceId < o2.serviceId) {
-                            return -1;
-                        } else if (o1.serviceId > o2.serviceId) {
-                            return 1;
-                        }
-                    }
-                    return 0;
-                }
-            });
-
+        this.resourceDecoratorTracker.close();
     }
 
     protected void bindResourceProvider(ServiceReference reference) {
@@ -568,48 +509,12 @@ public class JcrResourceResolverFactoryI
         log.debug("unbindResourceProvider: Unbound {}", serviceName);
     }
 
-    protected void bindJcrResourceTypeProvider(ServiceReference reference) {
-        synchronized (this.jcrResourceTypeProviders) {
-            if (componentContext == null) {
-                delayedJcrResourceTypeProviders.add(reference);
-            } else {
-                this.addJcrResourceTypeProvider(reference);
-                updateJcrResourceTypeProvidersArray();
-            }
-        }
+    protected void bindResourceDecorator(final ResourceDecorator decorator, final Map<String, Object> props) {
+        this.resourceDecoratorTracker.bindResourceDecorator(decorator, props);
     }
 
-    protected void unbindJcrResourceTypeProvider(ServiceReference reference) {
-        synchronized (this.jcrResourceTypeProviders) {
-            delayedJcrResourceTypeProviders.remove(reference);
-            final long id = (Long) reference.getProperty(Constants.SERVICE_ID);
-            final Iterator<JcrResourceTypeProviderEntry> i = this.jcrResourceTypeProviders.iterator();
-            while (i.hasNext()) {
-                final JcrResourceTypeProviderEntry current = i.next();
-                if (current.serviceId == id) {
-                    i.remove();
-                }
-            }
-            updateJcrResourceTypeProvidersArray();
-        }
-    }
-
-    /**
-     * Updates the JcrResourceTypeProviders array, this method is not thread safe and should only be
-     * called from a synchronized block.
-     */
-    protected void updateJcrResourceTypeProvidersArray() {
-        JcrResourceTypeProvider[] providers = null;
-        if (this.jcrResourceTypeProviders.size() > 0) {
-            providers = new JcrResourceTypeProvider[this.jcrResourceTypeProviders.size()];
-            int index = 0;
-            final Iterator<JcrResourceTypeProviderEntry> i = this.jcrResourceTypeProviders.iterator();
-            while (i.hasNext()) {
-                providers[index] = i.next().provider;
-                index++;
-            }
-        }
-        jcrResourceTypeProvidersArray = providers;
+    protected void unbindResourceDecorator(final ResourceDecorator decorator, final Map<String, Object> props) {
+        this.resourceDecoratorTracker.unbindResourceDecorator(decorator, props);
     }
 
     // ---------- internal helper ----------------------------------------------
@@ -619,21 +524,6 @@ public class JcrResourceResolverFactoryI
         return repository;
     }
 
-    protected static final class JcrResourceTypeProviderEntry {
-        final long serviceId;
-
-        final long ranking;
-
-        final JcrResourceTypeProvider provider;
-
-        public JcrResourceTypeProviderEntry(final long id, final long ranking,
-                final JcrResourceTypeProvider p) {
-            this.serviceId = id;
-            this.ranking = ranking;
-            this.provider = p;
-        }
-    }
-
     private String getServiceName(ServiceReference reference) {
         if (log.isDebugEnabled()) {
             StringBuilder snBuilder = new StringBuilder(64);

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolverWebConsolePlugin.java Tue Mar  9 13:38:34 2010
@@ -67,7 +67,7 @@ public class JcrResourceResolverWebConso
 
         Dictionary<String, Object> props = new Hashtable<String, Object>();
         props.put(Constants.SERVICE_DESCRIPTION,
-            "JCRResourceResolver2 Web Console Plugin");
+            "JCRResourceResolver Web Console Plugin");
         props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
         props.put(Constants.SERVICE_PID, getClass().getName());
         props.put(WebConsoleConstants.PLUGIN_LABEL, getLabel());

Added: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceDecoratorTracker.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceDecoratorTracker.java?rev=920872&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceDecoratorTracker.java (added)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceDecoratorTracker.java Tue Mar  9 13:38:34 2010
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.resource.internal;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceDecorator;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Helper class to track the resource decorators and keep
+ * them sorted by their service ranking.
+ */
+public class ResourceDecoratorTracker {
+
+    private static final ResourceDecorator[] EMPTY_ARRAY = new ResourceDecorator[0];
+
+    /**
+     * The (optional) resource decorators, working copy.
+     */
+    protected final List<ResourceDecoratorEntry> resourceDecorators = new ArrayList<ResourceDecoratorEntry>();
+
+    /**
+     * An array of the above, updates when changes are created.
+     */
+    private volatile ResourceDecorator[] resourceDecoratorsArray = EMPTY_ARRAY;
+
+    public void close() {
+        synchronized (this.resourceDecorators) {
+            this.resourceDecorators.clear();
+            this.resourceDecoratorsArray = EMPTY_ARRAY;
+        }
+    }
+
+    /** Decorate a resource. */
+    public Resource decorate(final Resource resource, final HttpServletRequest request) {
+        Resource result = resource;
+        final ResourceDecorator[] decorators = this.resourceDecoratorsArray;
+        for(final ResourceDecorator decorator : decorators) {
+            final Resource original = result;
+            if ( request == null ) {
+                result = decorator.decorate(original);
+            } else {
+                result = decorator.decorate(original, request);
+            }
+            if ( result == null ) {
+                result = original;
+            }
+        }
+        return result;
+    }
+
+    public ResourceDecorator[] getResourceDecorators() {
+        return this.resourceDecoratorsArray;
+    }
+
+    protected void addResourceDecorator(final ServiceReference reference) {
+    }
+
+    protected void bindResourceDecorator(final ResourceDecorator decorator, final Map<String, Object> props) {
+        synchronized (this.resourceDecorators) {
+            final Long id = (Long) props.get(Constants.SERVICE_ID);
+            long ranking = -1;
+            if (props.get(Constants.SERVICE_RANKING) != null) {
+                ranking = (Long) props.get(Constants.SERVICE_RANKING);
+            }
+            this.resourceDecorators.add(new ResourceDecoratorEntry(id, ranking, decorator));
+            Collections.sort(this.resourceDecorators, ResourceDecoratorEntry.COMPARATOR);
+            updateResourceDecoratorsArray();
+        }
+    }
+
+    protected void unbindResourceDecorator(final ResourceDecorator decorator, final Map<String, Object> props) {
+        synchronized (this.resourceDecorators) {
+            final long id = (Long) props.get(Constants.SERVICE_ID);
+            final Iterator<ResourceDecoratorEntry> i = this.resourceDecorators.iterator();
+            while (i.hasNext()) {
+                final ResourceDecoratorEntry current = i.next();
+                if (current.serviceId == id) {
+                    i.remove();
+                    break;
+                }
+            }
+            updateResourceDecoratorsArray();
+        }
+    }
+
+    /**
+     * Updates the ResourceDecorators array, this method is not thread safe and should only be
+     * called from a synchronized block.
+     */
+    protected void updateResourceDecoratorsArray() {
+        ResourceDecorator[] decorators = null;
+        if (this.resourceDecorators.size() > 0) {
+            decorators = new ResourceDecorator[this.resourceDecorators.size()];
+            int index = 0;
+            final Iterator<ResourceDecoratorEntry> i = this.resourceDecorators.iterator();
+            while (i.hasNext()) {
+                decorators[index] = i.next().decorator;
+                index++;
+            }
+        }
+        this.resourceDecoratorsArray = decorators;
+    }
+
+    /**
+     * Internal class to keep track of the resource decorators.
+     */
+    private static final class ResourceDecoratorEntry {
+
+        final long serviceId;
+
+        final long ranking;
+
+        final ResourceDecorator decorator;
+
+        public ResourceDecoratorEntry(final long id,
+               final long ranking,
+               final ResourceDecorator d) {
+            this.serviceId = id;
+            this.ranking = ranking;
+            this.decorator = d;
+        }
+
+        public static Comparator<ResourceDecoratorEntry> COMPARATOR =
+
+            new Comparator<ResourceDecoratorEntry>() {
+
+                public int compare(ResourceDecoratorEntry o1,
+                        ResourceDecoratorEntry o2) {
+                    if (o1.ranking < o2.ranking) {
+                        return 1;
+                    } else if (o1.ranking > o2.ranking) {
+                        return -1;
+                    } else {
+                        if (o1.serviceId < o2.serviceId) {
+                            return -1;
+                        } else if (o1.serviceId > o2.serviceId) {
+                            return 1;
+                        }
+                    }
+                    return 0;
+                }
+            };
+    }
+}

Propchange: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceDecoratorTracker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceDecoratorTracker.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceDecoratorTracker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceIteratorDecorator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceIteratorDecorator.java?rev=920872&view=auto
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceIteratorDecorator.java (added)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceIteratorDecorator.java Tue Mar  9 13:38:34 2010
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.jcr.resource.internal;
+
+import java.util.Iterator;
+
+import org.apache.sling.api.resource.Resource;
+
+/**
+ * Resource iterator handling the decoration of resources.
+ */
+public class ResourceIteratorDecorator implements Iterator<Resource> {
+
+    private final ResourceDecoratorTracker tracker;
+
+    private final Iterator<Resource> iterator;
+
+    public ResourceIteratorDecorator(final ResourceDecoratorTracker tracker,
+            final Iterator<Resource> iterator) {
+        this.tracker = tracker;
+        this.iterator = iterator;
+    }
+
+    public boolean hasNext() {
+        return this.iterator.hasNext();
+    }
+
+    public Resource next() {
+        return this.tracker.decorate(this.iterator.next(), null);
+    }
+
+    public void remove() {
+        this.iterator.remove();
+    }
+}

Propchange: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceIteratorDecorator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceIteratorDecorator.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/ResourceIteratorDecorator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResource.java Tue Mar  9 13:38:34 2010
@@ -28,7 +28,6 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.jcr.resource.JcrResourceConstants;
-import org.apache.sling.jcr.resource.JcrResourceTypeProvider;
 
 abstract class JcrItemResource extends SlingAdaptable implements Resource {
 
@@ -38,15 +37,11 @@ abstract class JcrItemResource extends S
 
     private final ResourceMetadata metadata;
 
-    protected final JcrResourceTypeProvider[] resourceTypeProviders;
-
     protected JcrItemResource(ResourceResolver resourceResolver,
-                              String path,
-                              JcrResourceTypeProvider[] resourceTypeProviders) {
+                              String path) {
 
         this.resourceResolver = resourceResolver;
         this.path = path;
-        this.resourceTypeProviders = resourceTypeProviders;
 
         metadata = new ResourceMetadata();
         metadata.setResolutionPath(path);
@@ -77,14 +72,6 @@ abstract class JcrItemResource extends S
             result = node.getProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY).getValue().getString();
         }
 
-        if (result == null && this.resourceTypeProviders != null) {
-            int index = 0;
-            while ( result == null && index < this.resourceTypeProviders.length ) {
-                result = this.resourceTypeProviders[index].getResourceTypeForNode(node);
-                index++;
-            }
-        }
-
         if (result == null || result.length() == 0) {
             result = node.getPrimaryNodeType().getName();
         }

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java Tue Mar  9 13:38:34 2010
@@ -48,7 +48,6 @@ import org.apache.sling.api.resource.Val
 import org.apache.sling.jcr.resource.JcrModifiablePropertyMap;
 import org.apache.sling.jcr.resource.JcrPropertyMap;
 import org.apache.sling.jcr.resource.JcrResourceConstants;
-import org.apache.sling.jcr.resource.JcrResourceTypeProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -73,16 +72,14 @@ public class JcrNodeResource extends Jcr
      * Constructor
      * @param resourceResolver
      * @param node
-     * @param resourceTypeProviders
      * @param dynamicClassLoader Dynamic class loader for loading serialized objects.
      * @throws RepositoryException
      */
     public JcrNodeResource(final ResourceResolver resourceResolver,
                            final Node node,
-                           final JcrResourceTypeProvider[] resourceTypeProviders,
                            final ClassLoader dynamicClassLoader)
     throws RepositoryException {
-        super(resourceResolver, node.getPath(), resourceTypeProviders);
+        super(resourceResolver, node.getPath());
         this.dynamicClassLoader = dynamicClassLoader;
         this.node = node;
         resourceType = getResourceTypeForNode(node);
@@ -236,7 +233,7 @@ public class JcrNodeResource extends Jcr
         try {
             if (getNode().hasNodes()) {
                 return new JcrNodeResourceIterator(getResourceResolver(),
-                    getNode().getNodes(), this.resourceTypeProviders, this.dynamicClassLoader);
+                    getNode().getNodes(), this.dynamicClassLoader);
             }
         } catch (RepositoryException re) {
             log.error("listChildren: Cannot get children of " + this, re);

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java Tue Mar  9 13:38:34 2010
@@ -25,7 +25,6 @@ import javax.jcr.NodeIterator;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.jcr.resource.JcrResourceTypeProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,8 +48,6 @@ public class JcrNodeResourceIterator imp
     /** The prefetched next iterator entry, null at the end of iterating */
     private Resource nextResult;
 
-    private final JcrResourceTypeProvider[] resourceTypeProviders;
-
     private final ClassLoader dynamicClassLoader;
 
     /**
@@ -59,11 +56,9 @@ public class JcrNodeResourceIterator imp
      */
     public JcrNodeResourceIterator(final ResourceResolver resourceResolver,
                                    final NodeIterator nodes,
-                                   final JcrResourceTypeProvider[] resourceTypeProviders,
                                    final ClassLoader dynamicClassLoader) {
         this.resourceResolver = resourceResolver;
         this.nodes = nodes;
-        this.resourceTypeProviders = resourceTypeProviders;
         this.nextResult = seek();
         this.dynamicClassLoader = dynamicClassLoader;
     }
@@ -94,7 +89,7 @@ public class JcrNodeResourceIterator imp
         while (nodes.hasNext()) {
             try {
                 Resource resource = new JcrNodeResource(resourceResolver,
-                    nodes.nextNode(), resourceTypeProviders, dynamicClassLoader);
+                    nodes.nextNode(), dynamicClassLoader);
                 log.debug("seek: Returning Resource {}", resource);
                 return resource;
             } catch (Throwable t) {

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrPropertyResource.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrPropertyResource.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrPropertyResource.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrPropertyResource.java Tue Mar  9 13:38:34 2010
@@ -32,7 +32,6 @@ import javax.jcr.ValueFormatException;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.jcr.resource.JcrResourceTypeProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,10 +46,9 @@ public class JcrPropertyResource extends
 
     public JcrPropertyResource(ResourceResolver resourceResolver,
                                String path,
-                               Property property,
-                               JcrResourceTypeProvider[] resourceTypeProviders)
+                               Property property)
     throws RepositoryException {
-        super(resourceResolver, path, resourceTypeProviders);
+        super(resourceResolver, path);
         this.property = property;
         this.resourceType = getResourceTypeForNode(property.getParent())
             + "/" + property.getName();

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java Tue Mar  9 13:38:34 2010
@@ -31,7 +31,6 @@ import org.apache.sling.api.SlingExcepti
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.api.resource.ResourceResolver;
-import org.apache.sling.jcr.resource.JcrResourceTypeProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,14 +46,11 @@ public class JcrResourceProvider impleme
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     private final Session session;
-    private final JcrResourceTypeProvider[] resourceTypeProviders;
     private final ClassLoader dynamicClassLoader;
 
     public JcrResourceProvider(final Session session,
-                               final JcrResourceTypeProvider[] resourceTypeProviders,
                                final ClassLoader dynamicClassLoader) {
         this.session = session;
-        this.resourceTypeProviders = resourceTypeProviders;
         this.dynamicClassLoader = dynamicClassLoader;
     }
 
@@ -134,14 +130,14 @@ public class JcrResourceProvider impleme
                 log.debug(
                     "createResource: Found JCR Node Resource at path '{}'",
                     path);
-                return new JcrNodeResource(resourceResolver, (Node) item, resourceTypeProviders, dynamicClassLoader);
+                return new JcrNodeResource(resourceResolver, (Node) item, dynamicClassLoader);
             }
 
             log.debug(
                 "createResource: Found JCR Property Resource at path '{}'",
                 path);
             return new JcrPropertyResource(resourceResolver, path,
-                (Property) item, resourceTypeProviders);
+                (Property) item);
         }
 
         log.debug("createResource: No JCR Item exists at path '{}'", path);

Modified: sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderEntry.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderEntry.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderEntry.java (original)
+++ sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProviderEntry.java Tue Mar  9 13:38:34 2010
@@ -25,7 +25,6 @@ import java.util.List;
 import javax.jcr.Session;
 
 import org.apache.sling.api.resource.ResourceProvider;
-import org.apache.sling.jcr.resource.JcrResourceTypeProvider;
 import org.apache.sling.jcr.resource.internal.helper.ResourceProviderEntry;
 
 public class JcrResourceProviderEntry extends ResourceProviderEntry {
@@ -39,28 +38,20 @@ public class JcrResourceProviderEntry ex
 
     private final Session session;
 
-    private final JcrResourceTypeProvider[] resourceTypeProviders;
-
     public JcrResourceProviderEntry(Session session,
             ResourceProviderEntry delegatee,
-            JcrResourceTypeProvider[] resourceTypeProviders,
             final ClassLoader dynamicClassLoader) {
         super("/", new ResourceProvider[] { new JcrResourceProvider(session,
-                resourceTypeProviders, dynamicClassLoader) });
+                dynamicClassLoader) });
 
         this.delegatee = delegatee;
         this.session = session;
-        this.resourceTypeProviders = resourceTypeProviders;
     }
 
     public Session getSession() {
         return session;
     }
 
-    public JcrResourceTypeProvider[] getResourceTypeProviders() {
-        return resourceTypeProviders;
-    }
-
     @Override
     public boolean addResourceProvider(String prefix, ResourceProvider provider, Comparable<?> comparable) {
         return delegatee.addResourceProvider(prefix, provider, comparable);

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIteratorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIteratorTest.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIteratorTest.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/JcrNodeResourceIteratorTest.java Tue Mar  9 13:38:34 2010
@@ -35,7 +35,7 @@ public class JcrNodeResourceIteratorTest
 
     public void testEmpty() {
         NodeIterator ni = new MockNodeIterator(null);
-        JcrNodeResourceIterator ri = new JcrNodeResourceIterator(null, ni, null, null);
+        JcrNodeResourceIterator ri = new JcrNodeResourceIterator(null, ni, null);
 
         assertFalse(ri.hasNext());
 
@@ -51,7 +51,7 @@ public class JcrNodeResourceIteratorTest
         String path = "/parent/path/node";
         Node node = new MockNode(path);
         NodeIterator ni = new MockNodeIterator(new Node[] { node });
-        JcrNodeResourceIterator ri = new JcrNodeResourceIterator(null, ni, null, null);
+        JcrNodeResourceIterator ri = new JcrNodeResourceIterator(null, ni, null);
 
         assertTrue(ri.hasNext());
         Resource res = ri.next();
@@ -76,7 +76,7 @@ public class JcrNodeResourceIteratorTest
             nodes[i] = new MockNode(pathBase + i, "some:type" + i);
         }
         NodeIterator ni = new MockNodeIterator(nodes);
-        JcrNodeResourceIterator ri = new JcrNodeResourceIterator(null, ni, null, null);
+        JcrNodeResourceIterator ri = new JcrNodeResourceIterator(null, ni, null);
 
         for (int i=0; i < nodes.length; i++) {
             assertTrue(ri.hasNext());

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceTest.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceTest.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceTest.java Tue Mar  9 13:38:34 2010
@@ -45,7 +45,7 @@ public class JcrNodeResourceTest extends
         getSession().save();
 
         file = rootNode.getNode(name);
-        JcrNodeResource jnr = new JcrNodeResource(null, file, null, null);
+        JcrNodeResource jnr = new JcrNodeResource(null, file, null);
 
         assertEquals(file.getPath(), jnr.getPath());
 
@@ -63,7 +63,7 @@ public class JcrNodeResourceTest extends
         getSession().save();
 
         file = rootNode.getNode(name);
-        JcrNodeResource jnr = new JcrNodeResource(null, file, null, null);
+        JcrNodeResource jnr = new JcrNodeResource(null, file, null);
 
         assertEquals(file.getPath(), jnr.getPath());
 
@@ -79,7 +79,7 @@ public class JcrNodeResourceTest extends
         getSession().save();
 
         res = rootNode.getNode(name);
-        JcrNodeResource jnr = new JcrNodeResource(null, res, null, null);
+        JcrNodeResource jnr = new JcrNodeResource(null, res, null);
 
         assertEquals(res.getPath(), jnr.getPath());
 
@@ -95,7 +95,7 @@ public class JcrNodeResourceTest extends
         getSession().save();
 
         res = rootNode.getNode(name);
-        JcrNodeResource jnr = new JcrNodeResource(null, res, null, null);
+        JcrNodeResource jnr = new JcrNodeResource(null, res, null);
 
         assertEquals(res.getPath(), jnr.getPath());
 
@@ -108,14 +108,14 @@ public class JcrNodeResourceTest extends
         Node node = rootNode.addNode(name, JcrConstants.NT_UNSTRUCTURED);
         getSession().save();
 
-        JcrNodeResource jnr = new JcrNodeResource(null, node, null, null);
+        JcrNodeResource jnr = new JcrNodeResource(null, node, null);
         assertEquals(JcrConstants.NT_UNSTRUCTURED, jnr.getResourceType());
 
         String typeName = "some/resource/type";
         node.setProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY, typeName);
         getSession().save();
 
-        jnr = new JcrNodeResource(null, node, null, null);
+        jnr = new JcrNodeResource(null, node, null);
         assertEquals(typeName, jnr.getResourceType());
     }
 
@@ -127,7 +127,7 @@ public class JcrNodeResourceTest extends
         node.setProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY, typeName);
         getSession().save();
 
-        Resource jnr = new JcrNodeResource(resourceResolver, node, null, null);
+        Resource jnr = new JcrNodeResource(resourceResolver, node, null);
         assertEquals(typeName, jnr.getResourceType());
 
         // default super type is null
@@ -138,7 +138,7 @@ public class JcrNodeResourceTest extends
         typeNode.setProperty(JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY, superTypeName);
         getSession().save();
 
-        jnr = new JcrNodeResource(resourceResolver, node, null, null);
+        jnr = new JcrNodeResource(resourceResolver, node, null);
         assertEquals(typeName, jnr.getResourceType());
         assertEquals(superTypeName, ResourceUtil.findResourceSuperType(jnr));
 
@@ -147,7 +147,7 @@ public class JcrNodeResourceTest extends
         node.setProperty(JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY, otherSuperTypeName);
         getSession().save();
 
-        jnr = new JcrNodeResource(resourceResolver, node, null, null);
+        jnr = new JcrNodeResource(resourceResolver, node, null);
         assertEquals(typeName, jnr.getResourceType());
         assertEquals(otherSuperTypeName, jnr.getResourceSuperType());
 
@@ -155,7 +155,7 @@ public class JcrNodeResourceTest extends
         node.getProperty(JcrResourceConstants.SLING_RESOURCE_SUPER_TYPE_PROPERTY).remove();
         getSession().save();
 
-        jnr = new JcrNodeResource(resourceResolver, node, null, null);
+        jnr = new JcrNodeResource(resourceResolver, node, null);
         assertEquals(typeName, jnr.getResourceType());
         assertNull(jnr.getResourceSuperType());
     }
@@ -168,7 +168,7 @@ public class JcrNodeResourceTest extends
         getSession().save();
 
         res = rootNode.getNode(name);
-        JcrNodeResource jnr = new JcrNodeResource(null, res, null, null);
+        JcrNodeResource jnr = new JcrNodeResource(null, res, null);
 
         final Map<?, ?> props = jnr.adaptTo(Map.class);
 

Modified: sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java?rev=920872&r1=920871&r2=920872&view=diff
==============================================================================
--- sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java (original)
+++ sling/trunk/bundles/jcr/resource/src/test/java/org/apache/sling/jcr/resource/internal/helper/jcr/MockResourceResolver.java Tue Mar  9 13:38:34 2010
@@ -48,10 +48,10 @@ public class MockResourceResolver implem
             Item item = session.getItem(path);
 
             if (item.isNode()) {
-                return new JcrNodeResource(this, (Node) item, null, null);
+                return new JcrNodeResource(this, (Node) item, null);
             }
 
-            return new JcrPropertyResource(this, path, (Property) item, null);
+            return new JcrPropertyResource(this, path, (Property) item);
         } catch (Exception e) {
             // don't care
         }



Mime
View raw message