Author: cziegeler
Date: Tue Aug 19 06:08:18 2014
New Revision: 1618800
URL: http://svn.apache.org/r1618800
Log:
SLING-3848 : JcrNodeResource takes too long and initializes too much too soon.
Apply modified patch from Rob Ryan
Modified:
sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java
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=1618800&r1=1618799&r2=1618800&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 Aug 19 06:08:18 2014
@@ -64,7 +64,7 @@ class JcrNodeResource extends JcrItemRes
private final Node node;
- private final String resourceType;
+ private String resourceType;
private String resourceSuperType;
@@ -84,7 +84,6 @@ class JcrNodeResource extends JcrItemRes
super(resourceResolver, node.getPath(), new
JcrNodeResourceMetadata(node));
this.dynamicClassLoader = dynamicClassLoader;
this.node = node;
- this.resourceType = getResourceTypeForNode(node);
this.resourceSuperType = UNSET_RESOURCE_SUPER_TYPE;
}
@@ -92,6 +91,14 @@ class JcrNodeResource extends JcrItemRes
* @see org.apache.sling.api.resource.Resource#getResourceType()
*/
public String getResourceType() {
+ if ( this.resourceType == null ) {
+ try {
+ this.resourceType = getResourceTypeForNode(this.node);
+ } catch (final RepositoryException e) {
+ LOGGER.error("Unable to get resource type for node " + node,
e);
+ this.resourceType = "<unknown resource type>";
+ }
+ }
return resourceType;
}