You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:50:44 UTC

[sling-org-apache-sling-jmx-provider] annotated tag org.apache.sling.jmx.provider-1.0.0 created (now 66947d0)

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

rombert pushed a change 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.


      at 66947d0  (tag)
 tagging ecdc4d7ee925b3631932d9b3769e873d4a8343ad (commit)
      by Carsten Ziegeler
      on Wed Mar 5 11:21:14 2014 +0000

- Log -----------------------------------------------------------------
org.apache.sling.jmx.provider-1.0.0
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 961d545  SLING-2999 : JMX Resource Provider
     new 0a6ebb3  SLING-2999 : JMX Resource Provider
     new 8b1df92  SLING-2999 : JMX Resource Provider
     new 0ad522b  SLING-2999 : JMX Resource Provider
     new 32d3a34  SLING-2999 : JMX Resource Provider
     new 94e5196  SLING-2999 : JMX Resource Provider
     new 7cb48f0  SLING-2999 : JMX Resource Provider - initial support for tabular and composite data
     new ecc0c20  SLING-2999 : JMX Resource Provider - add sorting of tabular data
     new 99a4f03  Update to parent pom 18
     new 4ea28ab  [maven-release-plugin] prepare release org.apache.sling.jmx.provider-0.5.0
     new 7bd8c1b  [maven-release-plugin] prepare for next development iteration
     new be725e1  SLING-3176 : ValueMap of jmx resource should contain mbean attributes
     new 770d4a1  SLING-3176 : ValueMap of jmx resource should contain mbean attributes
     new 6f5fc97  SLING-3176 : ValueMap of jmx resource should contain mbean attributes
     new cf50332  [maven-release-plugin] prepare release org.apache.sling.jmx.provider-0.6.0
     new b44bf14  [maven-release-plugin] prepare for next development iteration
     new 53b4e4e  SLING-3200 : Avoid duplicated requests to mbeans when creating resources
     new caba701  SLING-3200 : Avoid duplicated requests to mbeans when creating resources
     new 269ee17  SLING-3200 : Avoid duplicated requests to mbeans when creating resources
     new 2ca89af  Add metatype information
     new 37e96a7  Add metatype information for resource access security
     new 07c15c2  Make important properties private
     new 1c8b0ca  [maven-release-plugin] prepare release org.apache.sling.jmx.provider-1.0.0
     new ecdc4d7  [maven-release-plugin]  copy for tag org.apache.sling.jmx.provider-1.0.0

The 24 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


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

[sling-org-apache-sling-jmx-provider] 07/09: Make important properties private

Posted by ro...@apache.org.
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 07c15c236c6cc176e77371371b439aeae1e23cca
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Fri Jan 31 08:24:27 2014 +0000

    Make important properties private
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider@1563084 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 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 79725fa..f56aa13 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
@@ -65,8 +65,8 @@ import org.apache.sling.commons.osgi.PropertiesUtil;
     @Property(name = ResourceProvider.ROOTS, value="/system/sling/monitoring/mbeans",
             label="Root",
             description="The mount point of the JMX beans"),
-    @Property(name = ResourceProvider.USE_RESOURCE_ACCESS_SECURITY, boolValue=true,
-              label="Secure", description="If enabled additional access checks are performed")
+    @Property(name = ResourceProvider.USE_RESOURCE_ACCESS_SECURITY, boolValue=true, propertyPrivate=true),
+    @Property(name = ResourceProvider.OWNS_ROOTS, boolValue=true, propertyPrivate=true)
 })
 /**
  * Brief summary of a "good" object name:

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

[sling-org-apache-sling-jmx-provider] 03/09: SLING-3200 : Avoid duplicated requests to mbeans when creating resources

Posted by ro...@apache.org.
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 caba701b5007414fe4b17343fe9399c852f2e214
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Oct 23 08:01:59 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@1534947 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/jmx/provider/impl/AttributeResource.java | 53 ++++++++++++----------
 .../jmx/provider/impl/JMXResourceProvider.java     | 12 +++--
 .../sling/jmx/provider/impl/MapResource.java       | 12 ++++-
 3 files changed, 50 insertions(+), 27 deletions(-)

diff --git a/src/main/java/org/apache/sling/jmx/provider/impl/AttributeResource.java b/src/main/java/org/apache/sling/jmx/provider/impl/AttributeResource.java
index 2967d01..eabf9d2 100644
--- a/src/main/java/org/apache/sling/jmx/provider/impl/AttributeResource.java
+++ b/src/main/java/org/apache/sling/jmx/provider/impl/AttributeResource.java
@@ -28,6 +28,7 @@ import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.TreeMap;
 
@@ -188,24 +189,22 @@ public class AttributeResource extends AbstractResource {
                 current = (Map<String, Object>)child;
             }
 
-            return new MapResource(this.getResourceResolver(), this.getPath(), current);
+            return new MapResource(this.getResourceResolver(), this.getPath(), current, this);
         }
         return null;
     }
 
-    private Map<String, Object> convertData() {
-        try {
-            final Object value = attrValue;
+    private volatile Map<String, Object> convertedValue;
 
-            if ( value instanceof TabularData ) {
-                return convertObject((TabularData)value);
-            } else if ( value instanceof CompositeData ) {
-                return convertObject((CompositeData)value);
+    private Map<String, Object> convertData() {
+        if ( convertedValue == null ) {
+            if ( attrValue instanceof TabularData ) {
+                convertedValue = convertObject((TabularData)attrValue);
+            } else if ( attrValue instanceof CompositeData ) {
+                convertedValue = convertObject((CompositeData)attrValue);
             }
-        } catch (final Exception ignore) {
-            // ignore and return null
         }
-        return null;
+        return convertedValue;
     }
 
     private Map<String, Object> convertObject(final TabularData td) {
@@ -292,7 +291,7 @@ public class AttributeResource extends AbstractResource {
         return result;
     }
 
-    public Iterator<Resource> getChildren(String subPath) {
+    public Iterator<Resource> getChildren(final String parentPath, final String subPath) {
         final Map<String, Object> childStructure = this.convertData();
         if ( childStructure != null ) {
             Map<String, Object> current = childStructure;
@@ -309,13 +308,6 @@ public class AttributeResource extends AbstractResource {
                     current = (Map<String, Object>)child;
                 }
             }
-            final Iterator<Map.Entry<String, Object>> removeIter = current.entrySet().iterator();
-            while ( removeIter.hasNext() ) {
-                final Map.Entry<String, Object> c = removeIter.next();
-                if ( !(c.getValue() instanceof Map) ) {
-                    removeIter.remove();
-                }
-            }
             if ( current.size() == 0 ) {
                 return null;
             }
@@ -323,18 +315,33 @@ public class AttributeResource extends AbstractResource {
 
             return new Iterator<Resource>() {
 
+                private Map.Entry<String, Object> next = this.seek();
+
+                private Map.Entry<String, Object> seek() {
+                    while ( childIter.hasNext() ) {
+                        final Map.Entry<String, Object> c = childIter.next();
+                        if ( c.getValue() instanceof Map ) {
+                            return c;
+                        }
+                    }
+                    return null;
+                }
+
                 public void remove() {
                     throw new UnsupportedOperationException("remove");
                 }
 
                 public Resource next() {
-                    final Map.Entry<String, Object> props = childIter.next();
-
-                    return new MapResource(getResourceResolver(), getPath() + '/' + props.getKey(), (Map)props.getValue());
+                    final Map.Entry<String, Object> props = next;
+                    if ( props == null ) {
+                        throw new NoSuchElementException();
+                    }
+                    next = seek();
+                    return new MapResource(getResourceResolver(), parentPath + '/' + props.getKey(), (Map)props.getValue(), AttributeResource.this);
                 }
 
                 public boolean hasNext() {
-                    return childIter.hasNext();
+                    return next != null;
                 }
             };
         }
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 9d17f3f..2eb7b46 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
@@ -309,7 +309,7 @@ public class JMXResourceProvider implements ResourceProvider {
                             return new AttributeResource(parent.getResourceResolver(),
                                     parent.getPath() + "/" + attr.getName(),
                                     infoMap.get(attr.getName()),
-                                    attr,
+                                    attr.getValue(),
                                     parentResource);
                         }
 
@@ -318,7 +318,13 @@ public class JMXResourceProvider implements ResourceProvider {
                         }
                     };
                 } else if ( info.pathInfo.startsWith("mbean:attributes/") ) {
-                    final AttributeResource parentResource = (AttributeResource)parent;
+                    final AttributeResource parentResource;
+                    if ( parent instanceof AttributeResource ) {
+                        parentResource = (AttributeResource)parent;
+                    } else {
+                        parentResource = ((MapResource)parent).getAttributeResource();
+                    }
+
                     final String attrPath = info.pathInfo.substring("mbean:attributes/".length());
                     final int pos = attrPath.indexOf('/');
                     final String subPath;
@@ -328,7 +334,7 @@ public class JMXResourceProvider implements ResourceProvider {
                         subPath = attrPath.substring(pos + 1);
                     }
 
-                    return parentResource.getChildren(subPath);
+                    return parentResource.getChildren(parent.getPath(), subPath);
 
                 }
             }
diff --git a/src/main/java/org/apache/sling/jmx/provider/impl/MapResource.java b/src/main/java/org/apache/sling/jmx/provider/impl/MapResource.java
index bdecaf6..596f4e0 100644
--- a/src/main/java/org/apache/sling/jmx/provider/impl/MapResource.java
+++ b/src/main/java/org/apache/sling/jmx/provider/impl/MapResource.java
@@ -38,7 +38,13 @@ public class MapResource extends AbstractResource {
 
     private final ResourceMetadata metadata = new ResourceMetadata();
 
-    public MapResource(final ResourceResolver resolver, final String path, final Map<String, Object> props) {
+    private final AttributeResource parent;
+
+    public MapResource(final ResourceResolver resolver,
+            final String path,
+            final Map<String, Object> props,
+            final AttributeResource parent) {
+        this.parent = parent;
         this.resolver = resolver;
         this.path = path;
         this.properties = new HashMap<String, Object>();
@@ -49,6 +55,10 @@ public class MapResource extends AbstractResource {
         }
     }
 
+    public AttributeResource getAttributeResource() {
+        return this.parent;
+    }
+
     /**
      * @see org.apache.sling.api.resource.Resource#getPath()
      */

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

[sling-org-apache-sling-jmx-provider] 06/09: Add metatype information for resource access security

Posted by ro...@apache.org.
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 37e96a764989db0b764d4679e03a0d9dfa15ceea
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Jan 29 13:09:03 2014 +0000

    Add metatype information for resource access security
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider@1562432 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml                                                               | 2 +-
 .../java/org/apache/sling/jmx/provider/impl/JMXResourceProvider.java  | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9f0e064..5b3effc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,7 @@
         <dependency>
     	    <groupId>org.apache.sling</groupId>
     	    <artifactId>org.apache.sling.api</artifactId>
-    	    <version>2.4.0</version>
+    	    <version>2.5.0</version>
     	    <scope>provided</scope>
         </dependency>
         <dependency>
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 0ba933d..79725fa 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
@@ -64,7 +64,9 @@ import org.apache.sling.commons.osgi.PropertiesUtil;
 @Properties({
     @Property(name = ResourceProvider.ROOTS, value="/system/sling/monitoring/mbeans",
             label="Root",
-            description="The mount point of the JMX beans")
+            description="The mount point of the JMX beans"),
+    @Property(name = ResourceProvider.USE_RESOURCE_ACCESS_SECURITY, boolValue=true,
+              label="Secure", description="If enabled additional access checks are performed")
 })
 /**
  * Brief summary of a "good" object name:

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

[sling-org-apache-sling-jmx-provider] 05/09: Add metatype information

Posted by ro...@apache.org.
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 2ca89af694439052413c3f2c9c5f27c828263569
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Jan 13 14:56:52 2014 +0000

    Add metatype information
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider@1557741 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/jmx/provider/impl/JMXResourceProvider.java   | 8 ++++++--
 1 file changed, 6 insertions(+), 2 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 5d32811..0ba933d 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
@@ -57,10 +57,14 @@ import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.commons.osgi.PropertiesUtil;
 
-@Component
+@Component(metatype=true,
+    label="Apache Sling JMX Resource Provider",
+    description="This provider mounts JMX mbeans into the resource tree.")
 @Service(value = ResourceProvider.class)
 @Properties({
-    @Property(name = ResourceProvider.ROOTS, value="/system/sling/monitoring/mbeans")
+    @Property(name = ResourceProvider.ROOTS, value="/system/sling/monitoring/mbeans",
+            label="Root",
+            description="The mount point of the JMX beans")
 })
 /**
  * Brief summary of a "good" object name:

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

[sling-org-apache-sling-jmx-provider] 01/09: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
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 b44bf141d6fee0e22d87ffaf03068a948bd08eaf
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Sun Oct 20 14:07:20 2013 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider@1533906 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index fcba229..9f0e064 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,15 +28,15 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.jmx.provider</artifactId>
-    <version>0.6.0</version>
+    <version>0.6.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling JMX Resource Provider</name>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jmx.provider-0.6.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jmx.provider-0.6.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.jmx.provider-0.6.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jmxprovider</url>
     </scm>
 
     <build>

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

[sling-org-apache-sling-jmx-provider] 02/09: SLING-3200 : Avoid duplicated requests to mbeans when creating resources

Posted by ro...@apache.org.
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 53b4e4e4f42d841fe5c98b04e24aaf8e4b8b79d7
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Tue Oct 22 16:17:12 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@1534693 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/jmx/provider/impl/AttributeResource.java | 31 +++++++-----
 .../jmx/provider/impl/AttributesResource.java      | 10 +++-
 .../jmx/provider/impl/JMXResourceProvider.java     | 58 +++++++++++++++-------
 .../sling/jmx/provider/impl/MBeanResource.java     | 54 +++++++++++---------
 4 files changed, 98 insertions(+), 55 deletions(-)

diff --git a/src/main/java/org/apache/sling/jmx/provider/impl/AttributeResource.java b/src/main/java/org/apache/sling/jmx/provider/impl/AttributeResource.java
index 9e7c849..2967d01 100644
--- a/src/main/java/org/apache/sling/jmx/provider/impl/AttributeResource.java
+++ b/src/main/java/org/apache/sling/jmx/provider/impl/AttributeResource.java
@@ -32,8 +32,6 @@ import java.util.Set;
 import java.util.TreeMap;
 
 import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
 import javax.management.openmbean.CompositeData;
 import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.TabularData;
@@ -56,18 +54,25 @@ public class AttributeResource extends AbstractResource {
 
     private final MBeanAttributeInfo info;
 
-    private final MBeanServer server;
+    private final Object attrValue;
 
-    private final ObjectName on;
+    private final AttributesResource parent;
 
-    public AttributeResource(final MBeanServer server,
-                             final ObjectName on,
-                             final ResourceResolver resolver, final String p, final MBeanAttributeInfo mai) {
+    public AttributeResource(final ResourceResolver resolver,
+                             final String path,
+                             final MBeanAttributeInfo info,
+                             final Object value,
+                             final AttributesResource parent) {
         this.resourceResolver = resolver;
-        this.path = p;
-        this.info = mai;
-        this.on = on;
-        this.server = server;
+        this.path = path;
+        this.info = info;
+        this.attrValue = value;
+        this.parent = parent;
+    }
+
+    @Override
+    public Resource getParent() {
+        return this.parent;
     }
 
     /**
@@ -127,7 +132,7 @@ public class AttributeResource extends AbstractResource {
         result.put(Constants.PROP_TYPE, info.getType());
 
         try {
-            final Object value = server.getAttribute(this.on, info.getName());
+            final Object value = attrValue;
             if ( value != null ) {
                 if ( value.getClass().isArray() ) {
                     final int length = Array.getLength(value);
@@ -190,7 +195,7 @@ public class AttributeResource extends AbstractResource {
 
     private Map<String, Object> convertData() {
         try {
-            final Object value = server.getAttribute(this.on, info.getName());
+            final Object value = attrValue;
 
             if ( value instanceof TabularData ) {
                 return convertObject((TabularData)value);
diff --git a/src/main/java/org/apache/sling/jmx/provider/impl/AttributesResource.java b/src/main/java/org/apache/sling/jmx/provider/impl/AttributesResource.java
index fbfb1e5..b3d65f6 100644
--- a/src/main/java/org/apache/sling/jmx/provider/impl/AttributesResource.java
+++ b/src/main/java/org/apache/sling/jmx/provider/impl/AttributesResource.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.sling.api.resource.AbstractResource;
+import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ValueMap;
@@ -35,10 +36,17 @@ public class AttributesResource extends AbstractResource {
 
     private final ResourceMetadata metadata = new ResourceMetadata();
 
-    public AttributesResource(final ResourceResolver resolver, final String p) {
+    private final MBeanResource parent;
+
+    public AttributesResource(final ResourceResolver resolver, final String p, final MBeanResource parent) {
         this.resourceResolver = resolver;
         this.path = p;
+        this.parent = parent;
+    }
 
+    @Override
+    public Resource getParent() {
+        return this.parent;
     }
 
     /**
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 602fd35..9d17f3f 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
@@ -23,8 +23,8 @@ import java.lang.management.ManagementFactory;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -33,6 +33,8 @@ import java.util.NoSuchElementException;
 import java.util.Set;
 import java.util.TreeMap;
 
+import javax.management.Attribute;
+import javax.management.AttributeList;
 import javax.management.InstanceNotFoundException;
 import javax.management.IntrospectionException;
 import javax.management.MBeanAttributeInfo;
@@ -52,6 +54,7 @@ import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceProvider;
 import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceUtil;
 import org.apache.sling.commons.osgi.PropertiesUtil;
 
 @Component
@@ -145,9 +148,14 @@ public class JMXResourceProvider implements ResourceProvider {
                     return new MBeanResource(this.mbeanServer, resourceResolver, this.convertObjectNameToResourcePath(info.objectName), path, info.mbeanInfo, info.objectName);
                 }
                 if ( info.pathInfo.equals("mbean:attributes") ) {
-                    return new AttributesResource(resourceResolver, path);
+                    final MBeanResource parent = (MBeanResource)resourceResolver.getResource(ResourceUtil.getParent(path));
+                    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 AttributeList result = parentMBeanResource.getAttributes();
+
                     final String attrPath = info.pathInfo.substring("mbean:attributes/".length());
                     final int pos = attrPath.indexOf('/');
                     final String attrName;
@@ -161,7 +169,15 @@ public class JMXResourceProvider implements ResourceProvider {
                     }
                     for(final MBeanAttributeInfo mai : info.mbeanInfo.getAttributes()) {
                         if ( mai.getName().equals(attrName) ) {
-                            final AttributeResource rsrc = new AttributeResource(mbeanServer, info.objectName, resourceResolver, path, mai);
+                            final Iterator iter = result.iterator();
+                            Object value = null;
+                            while ( iter.hasNext() && value == null ) {
+                                final Attribute a = (Attribute) iter.next();
+                                if ( a.getName().equals(attrName) ) {
+                                    value = a.getValue();
+                                }
+                            }
+                            final AttributeResource rsrc = new AttributeResource(resourceResolver, path, mai, value, parent);
                             if ( subPath != null ) {
                                 return rsrc.getChildResource(subPath);
                             }
@@ -264,16 +280,24 @@ public class JMXResourceProvider implements ResourceProvider {
                     public void remove() {
                         throw new UnsupportedOperationException("remove");
                     }
-                    };
+                };
             } else {
                 if ( info.pathInfo == null ) {
+                    final MBeanResource parentResource = (MBeanResource)parent;
                     final List<Resource> list = new ArrayList<Resource>();
-                    list.add(new AttributesResource(parent.getResourceResolver(), parent.getPath() + "/mbean:attributes"));
+                    list.add(new AttributesResource(parent.getResourceResolver(), parent.getPath() + "/mbean:attributes", parentResource));
                     return list.iterator();
                 } else if ( info.pathInfo.equals("mbean:attributes") ) {
+                    final AttributesResource parentResource = (AttributesResource)parent;
+                    final MBeanResource parentMBeanResource = (MBeanResource)parentResource.getParent();
+                    final AttributeList result = parentMBeanResource.getAttributes();
+
                     final MBeanAttributeInfo[] infos = info.mbeanInfo.getAttributes();
-                    final List<MBeanAttributeInfo> list = Arrays.asList(infos);
-                    final Iterator<MBeanAttributeInfo> iter = list.iterator();
+                    final Map<String, MBeanAttributeInfo> infoMap = new HashMap<String, MBeanAttributeInfo>();
+                    for(final MBeanAttributeInfo i : infos) {
+                        infoMap.put(i.getName(), i);
+                    }
+                    final Iterator iter = result.iterator();
                     return new Iterator<Resource>() {
 
                         public void remove() {
@@ -281,8 +305,12 @@ public class JMXResourceProvider implements ResourceProvider {
                         }
 
                         public Resource next() {
-                            final MBeanAttributeInfo mai = iter.next();
-                            return new AttributeResource(mbeanServer, info.objectName, parent.getResourceResolver(), parent.getPath() + "/" + mai.getName(), mai);
+                            final Attribute attr = (Attribute)iter.next();
+                            return new AttributeResource(parent.getResourceResolver(),
+                                    parent.getPath() + "/" + attr.getName(),
+                                    infoMap.get(attr.getName()),
+                                    attr,
+                                    parentResource);
                         }
 
                         public boolean hasNext() {
@@ -290,23 +318,17 @@ public class JMXResourceProvider implements ResourceProvider {
                         }
                     };
                 } else if ( info.pathInfo.startsWith("mbean:attributes/") ) {
+                    final AttributeResource parentResource = (AttributeResource)parent;
                     final String attrPath = info.pathInfo.substring("mbean:attributes/".length());
                     final int pos = attrPath.indexOf('/');
-                    final String attrName;
                     final String subPath;
                     if ( pos == -1 ) {
-                        attrName = attrPath;
                         subPath = null;
                     } else {
-                        attrName = attrPath.substring(0, pos);
                         subPath = attrPath.substring(pos + 1);
                     }
-                    for(final MBeanAttributeInfo mai : info.mbeanInfo.getAttributes()) {
-                        if ( mai.getName().equals(attrName) ) {
-                            final AttributeResource rsrc = new AttributeResource(mbeanServer, info.objectName, parent.getResourceResolver(), parent.getPath(), mai);
-                            return rsrc.getChildren(subPath);
-                        }
-                    }
+
+                    return parentResource.getChildren(subPath);
 
                 }
             }
diff --git a/src/main/java/org/apache/sling/jmx/provider/impl/MBeanResource.java b/src/main/java/org/apache/sling/jmx/provider/impl/MBeanResource.java
index e062612..78c9e5a 100644
--- a/src/main/java/org/apache/sling/jmx/provider/impl/MBeanResource.java
+++ b/src/main/java/org/apache/sling/jmx/provider/impl/MBeanResource.java
@@ -54,6 +54,8 @@ public class MBeanResource extends AbstractResource {
     /** The mbean server. */
     private final MBeanServer mbeanServer;
 
+    private volatile AttributeList attributeList;
+
     public MBeanResource(final MBeanServer mbeanServer,
             final ResourceResolver resolver,
             final String resourceType,
@@ -73,6 +75,28 @@ public class MBeanResource extends AbstractResource {
         }
     }
 
+    public AttributeList getAttributes() {
+        if ( this.attributeList == null ) {
+            final MBeanAttributeInfo[] infos = info.getAttributes();
+            final String[] names = new String[infos.length];
+            int index = 0;
+            for(final MBeanAttributeInfo i : infos) {
+                names[index] = i.getName();
+                index++;
+            }
+            try {
+                this.attributeList = mbeanServer.getAttributes(objectName, names);
+            } catch (InstanceNotFoundException e) {
+                // ignore
+                this.attributeList = new AttributeList();
+            } catch (ReflectionException e) {
+                // ignore
+                this.attributeList = new AttributeList();
+            }
+        }
+        return this.attributeList;
+    }
+
     /**
      * @see org.apache.sling.api.resource.Resource#getPath()
      */
@@ -128,30 +152,14 @@ public class MBeanResource extends AbstractResource {
         result.put(Constants.PROP_CLASSNAME, this.info.getClassName());
         result.put(Constants.PROP_OBJECTNAME, this.objectName.getCanonicalName());
 
-        final MBeanAttributeInfo[] attribs = this.info.getAttributes();
-        final String[] names = new String[attribs.length];
-        int index = 0;
-        for(final MBeanAttributeInfo i : attribs) {
-            names[index] = i.getName();
-            index++;
-        }
-         AttributeList values = null;
-         try {
-            values = this.mbeanServer.getAttributes(this.objectName, names);
-            if ( values != null ) {
-                final Iterator iter = values.iterator();
-                while ( iter.hasNext() ) {
-                    final Attribute a = (Attribute)iter.next();
-                    final Object value = a.getValue();
-                    if ( value != null ) {
-                        result.put(a.getName(), value);
-                    }
-                }
+        final AttributeList values = this.getAttributes();
+        final Iterator iter = values.iterator();
+        while ( iter.hasNext() ) {
+            final Attribute a = (Attribute)iter.next();
+            final Object value = a.getValue();
+            if ( value != null ) {
+                result.put(a.getName(), value);
             }
-        } catch (final InstanceNotFoundException e) {
-            // ignore
-        } catch (final ReflectionException e) {
-            // ignore
         }
 
         return result;

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

[sling-org-apache-sling-jmx-provider] 04/09: SLING-3200 : Avoid duplicated requests to mbeans when creating resources

Posted by ro...@apache.org.
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 <cz...@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" <co...@sling.apache.org>.

[sling-org-apache-sling-jmx-provider] 08/09: [maven-release-plugin] prepare release org.apache.sling.jmx.provider-1.0.0

Posted by ro...@apache.org.
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 1c8b0ca04a1888997a9ce1fe7e5891e5176df5bd
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Mar 5 11:21:02 2014 +0000

    [maven-release-plugin] prepare release org.apache.sling.jmx.provider-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider@1574438 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 5b3effc..7aa6ac0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,15 +28,15 @@
 
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.jmx.provider</artifactId>
-    <version>0.6.1-SNAPSHOT</version>
+    <version>1.0.0</version>
     <packaging>bundle</packaging>
 
     <name>Apache Sling JMX Resource Provider</name>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/contrib/extensions/jmxprovider</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/jmxprovider</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jmx.provider-1.0.0</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jmx.provider-1.0.0</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.jmx.provider-1.0.0</url>
     </scm>
 
     <build>

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

[sling-org-apache-sling-jmx-provider] 09/09: [maven-release-plugin] copy for tag org.apache.sling.jmx.provider-1.0.0

Posted by ro...@apache.org.
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 ecdc4d7ee925b3631932d9b3769e873d4a8343ad
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Mar 5 11:21:14 2014 +0000

    [maven-release-plugin]  copy for tag org.apache.sling.jmx.provider-1.0.0
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.jmx.provider-1.0.0@1574439 13f79535-47bb-0310-9956-ffa450edef68

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