public void removeAllListeners(RESTRequest request, ObjectName source_objName, JSONConverter converter) {
        NotificationTargetInformation nti = toNotificationTargetInformation(request, source_objName.getCanonicalName());

        //Get the corresponding List for the given ObjectName
        List<ServerNotification> notifications = serverNotifications.get(nti);

        if (notifications == null) {
            throw ErrorHelper.createRESTHandlerJsonException(new ListenerNotFoundException("There are no listeners registered for ObjectName: " + source_objName.getCanonicalName()),
                                                             converter,
                                                             APIConstants.STATUS_BAD_REQUEST);
        }

        Iterator<ServerNotification> notificationsIter = notifications.iterator();
        while (notificationsIter.hasNext()) {
            ServerNotification currentRegistration = notificationsIter.next();

            if (nti.getRoutingInformation() == null) {
                //Remove from MBeanServer               
                MBeanServerHelper.removeServerNotification(source_objName, //no need to make another ObjectName
                                                           currentRegistration.listener,
                                                           (NotificationFilter) getObject(currentRegistration.filter, null, converter),
                                                           getObject(currentRegistration.handback, null, converter),
                                                           converter);
            } else {
                // Remove the notification listener from the Target-Client Manager through EventAdmin
                MBeanRoutedNotificationHelper helper = MBeanRoutedNotificationHelper.getMBeanRoutedNotificationHelper();
                helper.removeRoutedServerNotificationListener(nti,
                                                              currentRegistration.listener,
                                                              (NotificationFilter) getObject(currentRegistration.filter, null, converter),
                                                              getObject(currentRegistration.handback, null, converter),
                                                              converter);
            }
            //Remove from local list (through iterator)
            notificationsIter.remove();

            //Clean up library
            removeObject(currentRegistration.filter);
            removeObject(currentRegistration.handback);
        }
    }
public void removeAllListeners ( RESTRequest request , ObjectName source_objName , JSONConverter converter ) { NotificationTargetInformation nti = toNotificationTargetInformation ( request , source_objName . getCanonicalName ( ) ) ; List < ServerNotification > notifications = serverNotifications . get ( nti ) ; if ( notifications == null ) { throw ErrorHelper . createRESTHandlerJsonException ( new ListenerNotFoundException ( "There are no listeners registered for ObjectName: " + source_objName . getCanonicalName ( ) ) , converter , APIConstants . STATUS_BAD_REQUEST ) ; } Iterator < ServerNotification > notificationsIter = notifications . iterator ( ) ; while ( notificationsIter . hasNext ( ) ) { ServerNotification currentRegistration = notificationsIter . next ( ) ; if ( nti . getRoutingInformation ( ) == null ) { MBeanServerHelper . removeServerNotification ( source_objName , currentRegistration . listener , ( NotificationFilter ) getObject ( currentRegistration . filter , null , converter ) , getObject ( currentRegistration . handback , null , converter ) , converter ) ; } else { MBeanRoutedNotificationHelper helper = MBeanRoutedNotificationHelper . getMBeanRoutedNotificationHelper ( ) ; helper . removeRoutedServerNotificationListener ( nti , currentRegistration . listener , ( NotificationFilter ) getObject ( currentRegistration . filter , null , converter ) , getObject ( currentRegistration . handback , null , converter ) , converter ) ; } notificationsIter . remove ( ) ; removeObject ( currentRegistration . filter ) ; removeObject ( currentRegistration . handback ) ; } }
Remove the appropriate server notifications from our list