You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2020/07/30 14:56:10 UTC
[sling-org-apache-sling-feature-launcher] branch master updated:
Fixes SLING-9621 - Registering the Platform MBeanServer on framework start
This is an automated email from the ASF dual-hosted git repository.
dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-launcher.git
The following commit(s) were added to refs/heads/master by this push:
new 89d2a48 Fixes SLING-9621 - Registering the Platform MBeanServer on framework start
89d2a48 is described below
commit 89d2a4806b09051e95b16074d853f1d83b643172
Author: Dan Klco <dk...@apache.org>
AuthorDate: Thu Jul 30 10:55:47 2020 -0400
Fixes SLING-9621 - Registering the Platform MBeanServer on framework start
---
.../launcher/impl/launchers/AbstractRunner.java | 30 ++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java
index d5f952b..61816b5 100644
--- a/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java
+++ b/src/main/java/org/apache/sling/feature/launcher/impl/launchers/AbstractRunner.java
@@ -18,6 +18,7 @@ package org.apache.sling.feature.launcher.impl.launchers;
import java.io.IOException;
import java.io.InputStream;
+import java.lang.management.ManagementFactory;
import java.lang.reflect.Array;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
@@ -39,6 +40,11 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -219,6 +225,30 @@ public abstract class AbstractRunner implements Callable<Integer> {
this.installerTracker.open();
}
+ MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
+ Hashtable<String, Object> mbeanProps = new Hashtable<>();
+ 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.info(
+ "start: Cannot set service properties of Platform MBeanServer service, registering without",
+ je);
+ }
+
+ framework.getBundleContext().registerService(MBeanServer.class.getName(),
+ platformMBeanServer, mbeanProps);
+
this.install(framework, bundlesMap);
}