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 java.util.Hashtable;
12 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
13 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
14 import org.osgi.framework.BundleActivator;
15 import org.osgi.framework.BundleContext;
16 import org.osgi.framework.ServiceRegistration;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class BrokerActivator implements BundleActivator {
22 private static final Logger log = LoggerFactory.getLogger(BrokerActivator.class);
23 private BindingAwareBrokerImpl baSal;
24 private ServiceRegistration<BindingAwareBroker> baSalRegistration;
25 private HashMapDataStore store = new HashMapDataStore();
26 private InstanceIdentifier<?> root = InstanceIdentifier.builder().toInstance();
29 public void start(BundleContext context) throws Exception {
30 log.info("Binding Aware Broker initialized");
31 baSal = new BindingAwareBrokerImpl();
32 baSal.setBrokerBundleContext(context);
34 baSal.getDataBroker().registerDataReader(root, store);
35 baSal.getDataBroker().registerCommitHandler(root, store);
37 BindingAwareBroker baSalService = baSal;
38 Hashtable<String, String> properties = new Hashtable<>();
39 this.baSalRegistration = context.registerService(BindingAwareBroker.class, baSalService, properties);
44 public void stop(BundleContext context) throws Exception {
45 log.info("Binding Aware Broker stopped");
46 baSalRegistration.unregister();