Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 54620 invoked from network); 4 Jan 2008 16:34:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Jan 2008 16:34:17 -0000 Received: (qmail 38838 invoked by uid 500); 4 Jan 2008 16:34:06 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 38812 invoked by uid 500); 4 Jan 2008 16:34:06 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 38803 invoked by uid 99); 4 Jan 2008 16:34:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Jan 2008 08:34:06 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 04 Jan 2008 16:33:51 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A18ED1A9832; Fri, 4 Jan 2008 08:33:56 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r608907 - in /incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api: adapter/ resource/ Date: Fri, 04 Jan 2008 16:33:56 -0000 To: sling-commits@incubator.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080104163356.A18ED1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmeschbe Date: Fri Jan 4 08:33:55 2008 New Revision: 608907 URL: http://svn.apache.org/viewvc?rev=608907&view=rev Log: First steps towards a Prototype of "Everything is a Resource" Added: incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/adapter/ incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/adapter/Adaptable.java incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java Modified: incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/Resource.java incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java Added: incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/adapter/Adaptable.java URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/adapter/Adaptable.java?rev=608907&view=auto ============================================================================== --- incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/adapter/Adaptable.java (added) +++ incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/adapter/Adaptable.java Fri Jan 4 08:33:55 2008 @@ -0,0 +1,35 @@ +/* + * 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.adapter; + +public interface Adaptable { + + /** + * Adapts the adaptable to another type. + * + * @param The generic type to which this resource is adapted + * to + * @param type The Class object of the target type, such as + * Node.class + * @return The adapter target or null if the resource cannot + * adapt to the requested type + */ + AdapterType adaptTo(Class type); + +} Modified: incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java?rev=608907&r1=608906&r2=608907&view=diff ============================================================================== --- incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java (original) +++ incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java Fri Jan 4 08:33:55 2008 @@ -46,6 +46,11 @@ return resourceMetadata; } + public ResourceProvider getResourceProvider() { + // TODO Auto-generated method stub + return null; + } + /** * Returns null because a non-existing resource cannot adapt * to anything. Modified: incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/Resource.java URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/Resource.java?rev=608907&r1=608906&r2=608907&view=diff ============================================================================== --- incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/Resource.java (original) +++ incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/Resource.java Fri Jan 4 08:33:55 2008 @@ -16,8 +16,10 @@ */ package org.apache.sling.api.resource; +import org.apache.sling.api.adapter.Adaptable; + /** Resources are pieces of content on which Sling acts */ -public interface Resource { +public interface Resource extends Adaptable { /** * The special resource type for resource instances representing nonexisting @@ -59,6 +61,11 @@ * @see ResourceMetadata */ ResourceMetadata getResourceMetadata(); + + /** + * Returns the ResourceProvider from which this resource has been retrieved. + */ + ResourceProvider getResourceProvider(); /** * Adapts this resource to another type. A JCR based resource might support Added: incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java?rev=608907&view=auto ============================================================================== --- incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java (added) +++ incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/ResourceProvider.java Fri Jan 4 08:33:55 2008 @@ -0,0 +1,90 @@ +/* + * 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 java.util.Iterator; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.sling.api.SlingException; + +/** + * API for providers of resources. Used by the {@link ResourceResolver} to + * transparently access resources from different locations such as a JCR + * repository (the default) or OSGi bundles. + *

+ * This interface is intended to be implemented by providers of Resource + * instances on behalf of the {@link ResourceResolver}. It is not intended to + * be used by client applications directly. + */ +public interface ResourceProvider { + + /** + * The name of the service registration property containing the root paths + * of the resources provided by this provider (value is "provider.roots"). + */ + static final String ROOTS = "provider.roots"; + + /** + * Returns a resource from this resource provider or null if + * the resource provider cannot find it. The path should have one of the + * {@link #getRoots()} strings as its prefix. + *

+ * This method is called to resolve a resource for the given request. The + * properties of the request, such as request parameters, may be use to + * parametrize the resource resolution. An example of such parametrization + * is support for a JSR-311 style resource provider to support the + * parametrized URL patterns. + * + * @throws Exception may be thrown in case of any problem creating the + * Resource instance. + */ + Resource getResource(/* ResourceResolver resourceResolver, */ + HttpServletRequest request, String path) throws SlingException; + + /** + * Returns a resource from this resource provider or null if + * the resource provider cannot find it. The path should have one of the + * {@link #getRoots()} strings as its prefix. + * + * @throws Exception may be thrown in case of any problem creating the + * Resource instance. + */ + Resource getResource(/* ResourceResolver ResourceResolver, */ String path) + throws SlingException; + + /** + * Returns an Iterator of {@link Resource} objects loaded + * from the children of the given Resource. + *

+ * This method is only called for resource providers whose root path list + * contains an entry which is a prefix for the path of the parent resource. + * + * @param parent The {@link Resource Resource} whose children are requested. + * @return An Iterator of {@link Resource} objects or + * null if the resource provider has no children for + * the given resource. + * @throws NullPointerException If parent is + * null. + * @throws SlingException If any error occurs acquiring the child resource + * iterator. + */ + Iterator listChildren(Resource parent) throws SlingException; + +} Modified: incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java?rev=608907&r1=608906&r2=608907&view=diff ============================================================================== --- incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java (original) +++ incubator/sling/whiteboard/fmeschbe/resource/api/src/main/java/org/apache/sling/api/resource/ResourceResolver.java Fri Jan 4 08:33:55 2008 @@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletRequest; import org.apache.sling.api.SlingException; +import org.apache.sling.api.adapter.Adaptable; /** * The ResourceResolver defines the service API which may be used @@ -32,7 +33,7 @@ * {@link org.apache.sling.api.SlingHttpServletRequest#getResourceResolver()} * method. */ -public interface ResourceResolver { +public interface ResourceResolver extends Adaptable { /** * Resolves the resource from the given HttpServletRequest. @@ -44,7 +45,7 @@ * {@link Resource#getURI() resource URI} set to the request URI. * {@link Resource#adaptTo(Class) object} returns null for * all classes. - * + * * @param request The http servlet request object used to resolve the * resource for. * @return The {@link Resource} for the request. @@ -60,7 +61,7 @@ * a Java Content Repository, the path could be a * javax.jcr.Item path from which the resource object is * loaded. - * + * * @param path The absolute path to the resource object to be loaded. The * path may contain relative path specifiers like . * (current location) and .. (parent location), @@ -86,7 +87,7 @@ * a Java Content Repository, the path could be a * javax.jcr.Item path from which the resource object is * loaded. - * + * * @param base The base {@link Resource} against which a relative path * argument given by path is resolved. This * parameter may be null if the path @@ -118,7 +119,7 @@ * reading content from a Java Content Repository, the children could be the * {@link Resource} objects loaded from child items of the Item * of the given Resource. - * + * * @param parent The {@link Resource Resource} whose children are requested. * If null the children of this request's Resource * are returned. @@ -140,7 +141,7 @@ * create a JCR Query through the QueryManager. * The result returned is then based on the NodeIterator * provided by the query result. - * + * * @param query The query string to use to find the resources. * @param language The language in which the query is formulated. * @return An Iterator of {@link Resource} objects matching @@ -163,7 +164,7 @@ * the column name and the column value is the JCR Value * object converted into the respective Java object, such as * Boolean for a value of property type Boolean. - * + * * @param query The query string to use to find the resources. * @param language The language in which the query is formulated. * @return An Iterator of Map instances @@ -177,7 +178,7 @@ * Adapts this resource resolver to another type. A JCR based resource * resolver might support adapting to the JCR Session used by the resolver * to access the JCR Repository. - * + * * @param The generic type to which this resource is adapted * to * @param type The Class object of the target type, such as