X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fblueprint%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fblueprint%2Fext%2FNotificationListenerBean.java;fp=opendaylight%2Fblueprint%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fblueprint%2Fext%2FNotificationListenerBean.java;h=bdef13f59c88f3f3a2bfe8bb225f238e520720db;hb=33767a11f3aec774ec2ac8c13cc18b0ff0da9c10;hp=0000000000000000000000000000000000000000;hpb=acbbcc0278c08cf49d71a35b776608fee9e7d417;p=controller.git diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/NotificationListenerBean.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/NotificationListenerBean.java new file mode 100644 index 0000000000..bdef13f59c --- /dev/null +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/NotificationListenerBean.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.blueprint.ext; + +import org.opendaylight.controller.md.sal.binding.api.NotificationService; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.osgi.framework.Bundle; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Blueprint bean corresponding to the "notification-listener" element that registers a NotificationListener + * with the NotificationService. + * + * @author Thomas Pantelis + */ +public class NotificationListenerBean { + private static final Logger LOG = LoggerFactory.getLogger(NotificationListenerBean.class); + static final String NOTIFICATION_LISTENER = "notification-listener"; + + private Bundle bundle; + private NotificationService notificationService; + private NotificationListener notificationListener; + private ListenerRegistration registration; + + public void setNotificationService(NotificationService notificationService) { + this.notificationService = notificationService; + } + public void setNotificationListener(NotificationListener notificationListener) { + this.notificationListener = notificationListener; + } + + public void setBundle(Bundle bundle) { + this.bundle = bundle; + } + + @SuppressWarnings({ }) + public void init() { + LOG.debug("{}: init - registering NotificationListener {}", bundle.getSymbolicName(), notificationListener); + + registration = notificationService.registerNotificationListener(notificationListener); + } + + public void destroy() { + if(registration != null) { + registration.close(); + } + } +}