Source:
protected Set<BeanDefinition> bindNotificationDispatchers(Set<BeanDefinition> beanDefinitions) { DispatchFactory dispatchFactory = DispatchFactory.getInstance(); bind(DispatchFactory.class).toInstance(dispatchFactory); if (null == beanDefinitions || beanDefinitions.isEmpty()) { String packageName = AlertScriptDispatcher.class.getPackage().getName(); LOG.info("Searching package for dispatchers matching {}", packageName, NotificationDispatcher.class); ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false); AssignableTypeFilter filter = new AssignableTypeFilter( NotificationDispatcher.class); scanner.addIncludeFilter(filter); beanDefinitions = scanner.findCandidateComponents(packageName); } if (null == beanDefinitions || beanDefinitions.size() == 0) { LOG.error("No instances of found to register", NotificationDispatcher.class); return null; } for (BeanDefinition beanDefinition : beanDefinitions) { String className = beanDefinition.getBeanClassName(); if (className != null) { Class<?> clazz = ClassUtils.resolveClassName(className, ClassUtils.getDefaultClassLoader()); try { NotificationDispatcher dispatcher; if (clazz.equals(AmbariSNMPDispatcher.class)) { dispatcher = (NotificationDispatcher) clazz.getConstructor(Integer.class) .newInstance(configuration.getAmbariSNMPUdpBindPort()); } else if (clazz.equals(SNMPDispatcher.class)) { dispatcher = (NotificationDispatcher) clazz.getConstructor(Integer.class) .newInstance(configuration.getSNMPUdpBindPort()); } else { dispatcher = (NotificationDispatcher) clazz.newInstance(); } dispatchFactory.register(dispatcher.getType(), dispatcher); bind((Class<NotificationDispatcher>) clazz).toInstance(dispatcher); LOG.info("Binding and registering notification dispatcher {}", clazz); } catch (Exception exception) { LOG.error("Unable to bind and register notification dispatcher {}", clazz, exception); } } } return beanDefinitions; }

Target:
protected Set<BeanDefinition> bindNotificationDispatchers(Set<BeanDefinition> beanDefinitions) { DispatchFactory dispatchFactory = DispatchFactory.getInstance(); bind(DispatchFactory.class).toInstance(dispatchFactory); if (null == beanDefinitions || beanDefinitions.isEmpty()) { String packageName = AlertScriptDispatcher.class.getPackage().getName(); LOG.info("Searching package for dispatchers matching {}", packageName, NotificationDispatcher.class); ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false); AssignableTypeFilter filter = new AssignableTypeFilter( NotificationDispatcher.class); scanner.addIncludeFilter(filter); beanDefinitions = scanner.findCandidateComponents(packageName); } if (null == beanDefinitions || beanDefinitions.size() == 0) { LOG.error("No instances of found to register", NotificationDispatcher.class); return null; } for (BeanDefinition beanDefinition : beanDefinitions) { String className = beanDefinition.getBeanClassName(); if (className != null) { Class<?> clazz = ClassUtils.resolveClassName(className, ClassUtils.getDefaultClassLoader()); try { NotificationDispatcher dispatcher; if (clazz.equals(AmbariSNMPDispatcher.class)) { dispatcher = (NotificationDispatcher) clazz.getConstructor(Integer.class) .newInstance(configuration.getAmbariSNMPUdpBindPort()); } else if (clazz.equals(SNMPDispatcher.class)) { dispatcher = (NotificationDispatcher) clazz.getConstructor(Integer.class) .newInstance(configuration.getSNMPUdpBindPort()); } else { dispatcher = (NotificationDispatcher) clazz.newInstance(); } dispatchFactory.register(dispatcher.getType(), dispatcher); bind((Class<NotificationDispatcher>) clazz).toInstance(dispatcher); LOG.info("Binding and registering notification dispatcher {}", clazz); } catch (Exception exception) { LOG.error("Unable to bind and register notification dispatcher {}", clazz, exception); } } else { LOG.error("Binding and registering notification dispatcher is not possible for" + " beanDefinition: in the absence of className", beanDefinition); } } return beanDefinitions; }