BUG-614: convert NotificationBrokerImpl
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / GeneratedListenerRegistration.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.binding.impl;
9
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;
14
15 public class GeneratedListenerRegistration extends AbstractObjectRegistration<NotificationListener> implements ListenerRegistration<NotificationListener> {
16     private final NotificationInvoker _invoker;
17
18     public NotificationInvoker getInvoker() {
19         return this._invoker;
20     }
21
22     private NotificationBrokerImpl notificationBroker;
23
24     public GeneratedListenerRegistration(final NotificationListener instance, final NotificationInvoker invoker, final NotificationBrokerImpl broker) {
25         super(instance);
26         this._invoker = invoker;
27         this.notificationBroker = broker;
28     }
29
30     @Override
31     protected void removeRegistration() {
32         this.notificationBroker.unregisterListener(this);
33         this.notificationBroker = null;
34         NotificationInvoker _invoker = this.getInvoker();
35         _invoker.close();
36     }
37 }