Author: fmeschbe
Date: Mon Dec 3 03:27:34 2007
New Revision: 600487
URL: http://svn.apache.org/viewvc?rev=600487&view=rev
Log:
SLING-109 Replace Provider mechanism by adapter pattern.
- add generic adaptTo method
- remove XXXProvider interfaces
- remove JCR dependency from project
Removed:
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NodeProvider.java
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/ObjectProvider.java
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/StreamProvider.java
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/URLProvider.java
Modified:
incubator/sling/trunk/api/pom.xml
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/Resource.java
Modified: incubator/sling/trunk/api/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/api/pom.xml?rev=600487&r1=600486&r2=600487&view=diff
==============================================================================
--- incubator/sling/trunk/api/pom.xml (original)
+++ incubator/sling/trunk/api/pom.xml Mon Dec 3 03:27:34 2007
@@ -60,10 +60,6 @@
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
- <dependency>
- <groupId>javax.jcr</groupId>
- <artifactId>jcr</artifactId>
- </dependency>
</dependencies>
<build>
Modified:
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java?rev=600487&r1=600486&r2=600487&view=diff
==============================================================================
---
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java
(original)
+++
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/NonExistingResource.java
Mon Dec 3 03:27:34 2007
@@ -46,4 +46,11 @@
return resourceMetadata;
}
+ /**
+ * Returns <code>null</code> because a non-existing resource cannot adapt
+ * to anything.
+ */
+ public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
+ return null;
+ }
}
Modified:
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/Resource.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/Resource.java?rev=600487&r1=600486&r2=600487&view=diff
==============================================================================
---
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/Resource.java
(original)
+++
incubator/sling/trunk/api/src/main/java/org/apache/sling/api/resource/Resource.java
Mon Dec 3 03:27:34 2007
@@ -21,10 +21,10 @@
/**
* The special resource type for resource instances representing
nonexisting
- * resources (value is "sling:nonexisting"). This resource type is used
- * by [EMAIL PROTECTED] ResourceResolver} instances to mark a resource
which could not
+ * resources (value is "sling:nonexisting"). This resource type is used by
+ * [EMAIL PROTECTED] ResourceResolver} instances to mark a resource which
could not
* actually be resolved.
- *
+ *
* @see #getResourceType()
* @see ResourceResolver#resolve(javax.servlet.ServletRequest)
*/
@@ -55,8 +55,22 @@
* except for the [EMAIL PROTECTED] ResourceMetadata#RESOLUTION_PATH}
property which is
* required to be set to the part of the request URI used to resolve the
* resource.
- *
+ *
* @see ResourceMetadata
*/
ResourceMetadata getResourceMetadata();
+
+ /**
+ * Adapts this resource to another type. A JCR based resource might
provided
+ * adapters to the JCR Node on which the resource is based.
+ *
+ * @param <AdapterType> The generic type to which this resource is adapted
+ * to
+ * @param type The Class object of the target type, such as
+ * <code>Node.class</code>
+ * @return The adapter target or <code>null</code> if the resource cannot
+ * adapt to the requested type
+ */
+ <AdapterType> AdapterType adaptTo(Class<AdapterType> type);
+
}