aaaedadf7fcebc268ab68791c2e29678fb2220c7
[bgpcep.git] / bgp / topology-provider / src / main / java / org / opendaylight / bgpcep / topology / provider / bgp / impl / Activator.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.bgpcep.topology.provider.bgp.impl;
9
10 import org.opendaylight.bgpcep.topology.provider.bgp.LocRIBListeners;
11 import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
13 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
19 import org.osgi.framework.BundleContext;
20 import org.osgi.framework.ServiceRegistration;
21
22 import com.google.common.base.Preconditions;
23
24 public class Activator extends AbstractBindingAwareProvider {
25         private ServiceRegistration<LocRIBListeners.Subscribtion> ipv4, ipv6, linkstate;
26         private BundleContext context;
27
28         @Override
29         public void onSessionInitiated(final ProviderContext session) {
30                 final LocRIBListenerSubscriptionTracker reg = new LocRIBListenerSubscriptionTracker(context, session.getSALService(DataProviderService.class));
31                 reg.open();
32
33                 ipv4 = LocRIBListeners.subscribe(context, Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class,
34                                 new Ipv4ReachabilityTopologyBuilder(null));
35                 ipv6 = LocRIBListeners.subscribe(context, Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class,
36                                 new Ipv6ReachabilityTopologyBuilder(null));
37                 linkstate = LocRIBListeners.subscribe(context, LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class,
38                                 new LinkstateTopologyBuilder(null));
39         }
40
41         @Override
42         protected void startImpl(final BundleContext context) {
43                 this.context = Preconditions.checkNotNull(context);
44         }
45 }