code: @Override
      public void handleNotification(Notification notification, Object handback) {
          String notificationType = notification.getType();
          if (notificationType.equals(JMXConnectionNotification.OPENED)) {
              managementContext.incrementManagementSessionCount();
          } else if (notificationType.equals(JMXConnectionNotification.CLOSED)) {
              managementContext.decrementManagementSessionCount();
          }
      }
docs: NotificationListener support for connection open and closed notifications