sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1534954 - /sling/trunk/contrib/extensions/jmxprovider/src/main/java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java
Date Wed, 23 Oct 2013 08:21:09 GMT
Author: cziegeler
Date: Wed Oct 23 08:21:09 2013
New Revision: 1534954

URL: http://svn.apache.org/r1534954
Log:
SLING-3200 : Avoid duplicated requests to mbeans when creating resources

Modified:
    sling/trunk/contrib/extensions/jmxprovider/src/main/java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java

Modified: sling/trunk/contrib/extensions/jmxprovider/src/main/java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jmxprovider/src/main/java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java?rev=1534954&r1=1534953&r2=1534954&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/jmxprovider/src/main/java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java
(original)
+++ sling/trunk/contrib/extensions/jmxprovider/src/main/java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java
Wed Oct 23 08:21:09 2013
@@ -152,8 +152,22 @@ public class JMXResourceProvider impleme
                     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 impleme
                                     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);
                             }



Mime
View raw message