This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.jmx.provider-1.0.0
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jmx-provider.git

commit 269ee17f7c2f1c3a3b43a4b26aeaf94fbe18a793
Author: Carsten Ziegeler <cziege...@apache.org>
AuthorDate: Wed Oct 23 08:21:09 2013 +0000

    SLING-3200 : Avoid duplicated requests to mbeans when creating resources
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider@1534954
 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/jmx/provider/impl/JMXResourceProvider.java | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java 
b/src/main/java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java
index 2eb7b46..5d32811 100644
--- a/src/main/java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java
+++ b/src/main/java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java
@@ -152,8 +152,22 @@ public class JMXResourceProvider implements 
ResourceProvider {
                     return new AttributesResource(resourceResolver, path, 
parent);
                 }
                 if ( info.pathInfo.startsWith("mbean:attributes/") ) {
-                    final AttributesResource parent = 
(AttributesResource)resourceResolver.getResource(ResourceUtil.getParent(path));
-                    final MBeanResource parentMBeanResource = (MBeanResource) 
parent.getParent();
+                    final Resource parentRsrc = 
resourceResolver.getResource(ResourceUtil.getParent(path));
+                    final AttributesResource parentAttributesResource;
+                    final MBeanResource parentMBeanResource;
+                    if ( parentRsrc instanceof AttributesResource ) {
+                        parentAttributesResource = (AttributesResource) 
parentRsrc;
+                        parentMBeanResource = 
(MBeanResource)parentRsrc.getParent();
+                    } else {
+                        final AttributeResource parent;
+                        if ( parentRsrc instanceof AttributeResource) {
+                            parent = (AttributeResource)parentRsrc;
+                        } else {
+                            parent = 
((MapResource)parentRsrc).getAttributeResource();
+                        }
+                        parentAttributesResource = (AttributesResource) 
parent.getParent();
+                        parentMBeanResource = (MBeanResource) 
parentAttributesResource.getParent();
+                    }
                     final AttributeList result = 
parentMBeanResource.getAttributes();
 
                     final String attrPath = 
info.pathInfo.substring("mbean:attributes/".length());
@@ -177,7 +191,7 @@ public class JMXResourceProvider implements 
ResourceProvider {
                                     value = a.getValue();
                                 }
                             }
-                            final AttributeResource rsrc = new 
AttributeResource(resourceResolver, path, mai, value, parent);
+                            final AttributeResource rsrc = new 
AttributeResource(resourceResolver, path, mai, value, parentAttributesResource);
                             if ( subPath != null ) {
                                 return rsrc.getChildResource(subPath);
                             }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <commits@sling.apache.org>.

Reply via email to