Update to MD-SAL APIs
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / BrokerActivator.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 java.util.Hashtable;
11
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
13 import org.osgi.framework.BundleActivator;
14 import org.osgi.framework.BundleContext;
15 import org.osgi.framework.ServiceRegistration;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 public class BrokerActivator implements BundleActivator {
20
21     private static final Logger log = LoggerFactory.getLogger(BrokerActivator.class);
22     private BindingAwareBrokerImpl baSal;
23     private ServiceRegistration<BindingAwareBroker> baSalRegistration;
24
25     @Override
26     public void start(BundleContext context) throws Exception {
27         log.info("Binding Aware Broker initialized");
28         baSal = new BindingAwareBrokerImpl();
29         baSal.setBrokerBundleContext(context);
30         baSal.start();
31
32         BindingAwareBroker baSalService = baSal;
33         Hashtable<String, String> properties = new Hashtable<>();
34         this.baSalRegistration = context.registerService(BindingAwareBroker.class, baSalService, properties);
35
36     }
37
38     @Override
39     public void stop(BundleContext context) throws Exception {
40         log.info("Binding Aware Broker stopped");
41         baSalRegistration.unregister();
42     }
43
44 }