2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.binding.impl;
10 import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker;
11 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
12 import org.opendaylight.yangtools.concepts.ListenerRegistration;
13 import org.opendaylight.yangtools.yang.binding.NotificationListener;
15 import com.google.common.base.Preconditions;
17 class GeneratedListenerRegistration extends AbstractObjectRegistration<NotificationListener> implements ListenerRegistration<NotificationListener> {
18 private NotificationBrokerImpl notificationBroker;
19 private final NotificationInvoker invoker;
21 public GeneratedListenerRegistration(final NotificationListener instance, final NotificationInvoker invoker, final NotificationBrokerImpl broker) {
23 this.invoker = Preconditions.checkNotNull(invoker);
24 this.notificationBroker = Preconditions.checkNotNull(broker);
27 public NotificationInvoker getInvoker() {
28 // There is a race with NotificationBrokerImpl:
29 // the invoker can be closed here
34 protected void removeRegistration() {
35 notificationBroker.unregisterListener(this);
36 notificationBroker = null;