Author: fmeschbe
Date: Tue Dec 18 06:40:42 2007
New Revision: 605215
URL: http://svn.apache.org/viewvc?rev=605215&view=rev
Log:
Restrict adapters, otherwise we may get false positives, such as returning
the Node when adapting to class Object.
Modified:
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
Modified:
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java?rev=605215&r1=605214&r2=605215&view=diff
==============================================================================
---
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
(original)
+++
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrResourceResolver.java
Tue Dec 18 06:40:42 2007
@@ -208,9 +208,9 @@
@SuppressWarnings("unchecked")
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
- if (type.isInstance(getSession())) {
+ if (type == Session.class) {
return (AdapterType) getSession();
- } else if (type.isInstance(objectContentManager)) {
+ } else if (type == ObjectContentManager.class) {
return (AdapterType) objectContentManager;
} else if (type == PathResolver.class) {
return (AdapterType) this;
Modified:
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java?rev=605215&r1=605214&r2=605215&view=diff
==============================================================================
---
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
(original)
+++
incubator/sling/trunk/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
Tue Dec 18 06:40:42 2007
@@ -34,8 +34,10 @@
import java.net.URL;
import java.util.Iterator;
+import javax.jcr.Item;
import javax.jcr.Node;
import javax.jcr.RepositoryException;
+
import org.apache.jackrabbit.net.URLFactory;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceMetadata;
@@ -108,7 +110,7 @@
@SuppressWarnings("unchecked")
public <Type> Type adaptTo(Class<Type> type) {
- if (type.isInstance(getNode())) {
+ if (type == Node.class || type == Item.class) {
return (Type) getNode(); // unchecked cast
} else if (type == InputStream.class) {
return (Type) getInputStream(); // unchecked cast