+ private Metadata parseNotificationListener(Element element, ParserContext context) {
+ registerNotificationServiceRefBean(context);
+
+ MutableBeanMetadata metadata = context.createMetadata(MutableBeanMetadata.class);
+ metadata.setId(context.generateId());
+ metadata.setScope(BeanMetadata.SCOPE_SINGLETON);
+ metadata.setActivation(ReferenceMetadata.ACTIVATION_EAGER);
+ metadata.setRuntimeClass(NotificationListenerBean.class);
+ metadata.setInitMethod("init");
+ metadata.setDestroyMethod("destroy");
+ metadata.addProperty("bundle", createRef(context, "blueprintBundle"));
+ metadata.addProperty("notificationService", createRef(context, NOTIFICATION_SERVICE_NAME));
+ metadata.addProperty("notificationListener", createRef(context, element.getAttribute(REF_ATTR)));
+
+ LOG.debug("parseNotificationListener returning {}", metadata);
+
+ return metadata;
+ }
+
+ private void registerNotificationServiceRefBean(ParserContext context) {
+ ComponentDefinitionRegistry registry = context.getComponentDefinitionRegistry();
+ if(registry.getComponentDefinition(NOTIFICATION_SERVICE_NAME) == null) {
+ MutableReferenceMetadata metadata = createServiceRef(context, NotificationService.class, null);
+ metadata.setId(NOTIFICATION_SERVICE_NAME);
+ registry.registerComponentDefinition(metadata);
+ }
+ }
+