public ServerNotificationManager populateNotificationTypeMappings(Map<String, Class<? extends Notification>> eventMap, Map<String, Class<? extends NotificationListener>> interfaceMap) throws InitialisationException { Map<String, NotificationsProvider> providersMap = new HashMap<>(); for (NotificationsProvider provider : registry.lookupAllByType(NotificationsProvider.class)) { for (Entry<String, Pair<Class<? extends Notification>, Class<? extends NotificationListener>>> entry : provider .getEventListenerMapping().entrySet()) { final String notificationType = entry.getKey(); if (!notificationType.matches("[a-zA-Z]+:[A-Z\\-]+")) { throw new InitialisationException(createStaticMessage("Notification '%s' declared in '%s' doesn't comply with the '[artifactID]:[NOTIFICATION-ID]' format", notificationType, provider.toString()), this); } if (eventMap.containsKey(notificationType)) { throw new InitialisationException(createStaticMessage("Notification '%s' declared in '%s' is already declared for another artifact in provider '%s'.", notificationType, provider.toString(), eventMap.get(notificationType)), this); } eventMap.put(notificationType, entry.getValue().getFirst()); interfaceMap.put(notificationType, entry.getValue().getSecond()); providersMap.put(notificationType, provider); } } ServerNotificationManager notificationManager = muleContext.getNotificationManager(); if (dynamic != null) { notificationManager.setNotificationDynamic(dynamic.booleanValue()); } return notificationManager; }
@Test public void testDynamicManagerDecisions() throws ClassNotFoundException { registerDefaultEvents(); registerDefaultListeners(); manager.setNotificationDynamic(true); OptimisedNotificationHandler decision = new OptimisedNotificationHandler(manager, Event2.class); assertTrue(decision.isNotificationEnabled(Event2.class)); manager.disableType(Event2.class); assertFalse(decision.isNotificationEnabled(Event2.class)); }
public ServerNotificationManager populateNotificationTypeMappings(Map<String, Class<? extends Notification>> eventMap, Map<String, Class<? extends NotificationListener>> interfaceMap) throws InitialisationException { Map<String, NotificationsProvider> providersMap = new HashMap<>(); for (NotificationsProvider provider : registry.lookupAllByType(NotificationsProvider.class)) { for (Entry<String, Pair<Class<? extends Notification>, Class<? extends NotificationListener>>> entry : provider .getEventListenerMapping().entrySet()) { final String notificationType = entry.getKey(); if (!notificationType.matches("[a-zA-Z]+:[A-Z\\-]+")) { throw new InitialisationException(createStaticMessage("Notification '%s' declared in '%s' doesn't comply with the '[artifactID]:[NOTIFICATION-ID]' format", notificationType, provider.toString()), this); } if (eventMap.containsKey(notificationType)) { throw new InitialisationException(createStaticMessage("Notification '%s' declared in '%s' is already declared for another artifact in provider '%s'.", notificationType, provider.toString(), eventMap.get(notificationType)), this); } eventMap.put(notificationType, entry.getValue().getFirst()); interfaceMap.put(notificationType, entry.getValue().getSecond()); providersMap.put(notificationType, provider); } } ServerNotificationManager notificationManager = muleContext.getNotificationManager(); if (dynamic != null) { notificationManager.setNotificationDynamic(dynamic.booleanValue()); } return notificationManager; }
@Test public void testDynamicManagerDecisions() throws ClassNotFoundException { registerDefaultEvents(); registerDefaultListeners(); manager.setNotificationDynamic(true); OptimisedNotificationHandler decision = new OptimisedNotificationHandler(manager, Event2.class); assertTrue(decision.isNotificationEnabled(Event2.class)); manager.disableType(Event2.class); assertFalse(decision.isNotificationEnabled(Event2.class)); }