You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Justin Edelson <ju...@gmail.com> on 2010/08/20 17:28:22 UTC

Re: svn commit: r987533 - /sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java

ooh. good idea.

On 8/20/10 11:00 AM, fmeschbe@apache.org wrote:
> Author: fmeschbe
> Date: Fri Aug 20 15:00:05 2010
> New Revision: 987533
> 
> URL: http://svn.apache.org/viewvc?rev=987533&view=rev
> Log:
> SLING-1611 Add attributes of Platform MBeanServer delegate to the service registration of the Platform MBeanServer service as service properties
> 
> Modified:
>     sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
> 
> Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
> URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java?rev=987533&r1=987532&r2=987533&view=diff
> ==============================================================================
> --- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java (original)
> +++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java Fri Aug 20 15:00:05 2010
> @@ -38,7 +38,10 @@ import java.util.TreeMap;
>  import java.util.TreeSet;
>  import java.util.Map.Entry;
>  
> +import javax.management.Attribute;
> +import javax.management.AttributeList;
>  import javax.management.MBeanServer;
> +import javax.management.ObjectName;
>  
>  import org.apache.felix.framework.Felix;
>  import org.apache.felix.framework.Logger;
> @@ -314,8 +317,28 @@ public class Sling implements BundleActi
>  
>          // register the platform MBeanServer
>          MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
> +        Properties mbeanProps = new Properties();
> +        try {
> +            ObjectName beanName = ObjectName.getInstance("JMImplementation:type=MBeanServerDelegate");
> +            AttributeList attrs = platformMBeanServer.getAttributes(beanName,
> +                new String[] { "MBeanServerId", "SpecificationName",
> +                    "SpecificationVersion", "SpecificationVendor",
> +                    "ImplementationName", "ImplementationVersion",
> +                    "ImplementationVendor" });
> +            for (Object object : attrs) {
> +                Attribute attr = (Attribute) object;
> +                if (attr.getValue() != null) {
> +                    mbeanProps.put(attr.getName(), attr.getValue().toString());
> +                }
> +            }
> +        } catch (Exception je) {
> +            logger.log(
> +                Logger.LOG_INFO,
> +                "start: Cannot set service properties of Platform MBeanServer service, registering without",
> +                je);
> +        }
>          bundleContext.registerService(MBeanServer.class.getName(),
> -                platformMBeanServer, null);
> +            platformMBeanServer, mbeanProps);
>  
>          // execute optional bundle startup tasks of an extension
>          this.doStartBundle();
> 
>