infoscale commented on code in PR #8:
URL: 
https://github.com/apache/sling-org-apache-sling-commons-metrics/pull/8#discussion_r1727142571


##########
src/main/java/org/apache/sling/commons/metrics/internal/JmxExporterFactory.java:
##########
@@ -78,14 +85,46 @@ public class JmxExporterFactory {
     MetricsService metrics;
     
     MBeanServer server;
-    
+
+    NotificationListener listener = new NotificationListener() {
+        public void handleNotification(Notification notification, Object 
handback) {
+            if 
(MBeanServerNotification.REGISTRATION_NOTIFICATION.equals(notification.getType()))
 {
+                ObjectName objectname = null;
+                try {
+                    if(notification instanceof MBeanServerNotification) {
+                        MBeanServerNotification mbeanNotification = 
(MBeanServerNotification) notification;
+                        objectname = mbeanNotification.getMBeanName();
+                        LOG.debug("JMX Notification : match {} with pattern = 
{}", objectname, Arrays.asList(patterns));
+                        for (String pattern : patterns) {
+                            if (objectname.toString().matches(pattern)) {
+                                LOG.debug("JMX Notification : register metrics 
for MBean: {}", objectname);
+                                registerMBeanProperties(objectname);
+                                break;
+                            }
+                        }
+                    } else {
+                        LOG.debug("JMX Notification : Cannot register metrics 
for objectname = {}", objectname);

Review Comment:
   Changed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to