2 * Copyright (c) 2017 Cisco Systems, Inc. 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.lispflowmapping.neutron.intenthandler.listener.service;
10 import javax.annotation.Nonnull;
11 import org.opendaylight.lispflowmapping.neutron.intenthandler.listener.VbridgeTopologyListener;
12 import org.opendaylight.mdsal.binding.api.DataBroker;
13 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
14 import org.opendaylight.mdsal.binding.api.MountPointService;
15 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.TopologyTypesVbridgeAugment;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vbridge.topology.rev160129.network.topology.topology.topology.types.VbridgeTopology;
18 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
19 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypes;
21 import org.opendaylight.yangtools.concepts.ListenerRegistration;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 * Created by Shakib Ahmed on 1/19/17.
29 public class VbridgeTopologyListenerService implements AutoCloseable {
30 private static final Logger LOG = LoggerFactory.getLogger(VbridgeTopologyListenerService.class);
32 private final ListenerRegistration<VbridgeTopologyListener> listenerRegistration;
34 private boolean closed;
36 private static final DataTreeIdentifier<VbridgeTopology> TREE_LISTENER_IDENTIFIER =
37 DataTreeIdentifier.create(
38 LogicalDatastoreType.OPERATIONAL,
39 InstanceIdentifier.builder(NetworkTopology.class)
40 .child(Topology.class)
41 .child(TopologyTypes.class)
42 .augmentation(TopologyTypesVbridgeAugment.class)
43 .child(VbridgeTopology.class).build());
45 public VbridgeTopologyListenerService(final ListenerRegistration<VbridgeTopologyListener> reg) {
46 this.listenerRegistration = reg;
50 public static VbridgeTopologyListenerService initialize(@Nonnull final DataBroker dataBroker,
51 @Nonnull final MountPointService mountPointService) {
52 final ListenerRegistration<VbridgeTopologyListener> reg =
53 dataBroker.registerDataTreeChangeListener(TREE_LISTENER_IDENTIFIER,
54 new VbridgeTopologyListener(dataBroker, mountPointService));
56 return new VbridgeTopologyListenerService(reg);
64 final VbridgeTopologyListener listener = listenerRegistration.getInstance();
66 listenerRegistration.close();