You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2011/12/02 23:32:42 UTC
svn commit: r1209749 - in
/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal:
JcrResourceResolverFactoryImpl.java helper/jcr/JcrNodeResource.java
helper/jcr/JcrPropertyResource.java
Author: justin
Date: Fri Dec 2 22:32:42 2011
New Revision: 1209749
URL: http://svn.apache.org/viewvc?rev=1209749&view=rev
Log:
SLING-2315 - adding an AdapterFactory for Nodes & Properties to Resources, Map, ValueMap, etc.
Modified:
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/helper/jcr/JcrNodeResource.java
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrPropertyResource.java
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=1209749&r1=1209748&r2=1209749&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 Fri Dec 2 22:32:42 2011
@@ -207,6 +207,8 @@ public class JcrResourceResolverFactoryI
@Reference(cardinality=ReferenceCardinality.OPTIONAL_UNARY, policy=ReferencePolicy.DYNAMIC)
private DynamicClassLoaderManager dynamicClassLoaderManager;
+ private JcrItemAdapterFactory jcrItemAdapterFactory;
+
public JcrResourceResolverFactoryImpl() {
this.rootProviderEntry = new RootResourceProviderEntry();
@@ -495,12 +497,19 @@ public class JcrResourceResolverFactoryI
log.debug(
"activate: unable to setup web console plugin.", ignore);
}
+
+ jcrItemAdapterFactory = new JcrItemAdapterFactory(componentContext.getBundleContext(), this);
}
private JcrResourceResolverWebConsolePlugin plugin;
/** Deativates this component, called by SCR to take out of service */
protected void deactivate(final ComponentContext componentContext) {
+ if (jcrItemAdapterFactory != null) {
+ jcrItemAdapterFactory.dispose();
+ jcrItemAdapterFactory = null;
+ }
+
if (plugin != null) {
plugin.dispose();
plugin = null;
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=1209749&r1=1209748&r2=1209749&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 Fri Dec 2 22:32:42 2011
@@ -58,7 +58,7 @@ import org.slf4j.LoggerFactory;
@Adapter(value=PersistableValueMap.class, condition="If the resource is a JcrNodeResource and the user has set property privileges on the node."),
@Adapter(value=InputStream.class, condition="If the resource is a JcrNodeResource and has a jcr:data property or is an nt:file node.")
})
-class JcrNodeResource extends JcrItemResource {
+public class JcrNodeResource extends JcrItemResource {
/** marker value for the resourceSupertType before trying to evaluate */
private static final String UNSET_RESOURCE_SUPER_TYPE = "<unset>";
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=1209749&r1=1209748&r2=1209749&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 Fri Dec 2 22:32:42 2011
@@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
Double.class, Calendar.class, InputStream.class, Value[].class, String[].class,
Boolean[].class, Long[].class, Double[].class }),
@Adapter(value = Node.class, condition = "If the resource is a JcrPropertyResource and the property is a reference or weak reference property.") })
-class JcrPropertyResource extends JcrItemResource {
+public class JcrPropertyResource extends JcrItemResource {
/** default log */
private static final Logger LOGGER = LoggerFactory.getLogger(JcrPropertyResource.class);
@@ -67,6 +67,12 @@ class JcrPropertyResource extends JcrIte
this.setContentLength(property);
}
+ public JcrPropertyResource(ResourceResolver resourceResolver,
+ Property property)
+ throws RepositoryException {
+ this(resourceResolver, property.getPath(), property);
+ }
+
public String getResourceType() {
return resourceType;
}