2 * Copyright (C) 2013 Red Hat, Inc.
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 * Authors : Madhu Venugopal
11 package org.opendaylight.ovsdb.neutron;
12 import org.apache.felix.dm.Component;
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
15 import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
16 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
17 import org.osgi.framework.BundleContext;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20 public class MDSALConsumer implements BindingAwareConsumer, IMDSALConsumer {
22 private BundleContext ctx = null;
23 private BindingAwareBroker broker = null;
24 private ConsumerContext consumerContext = null;
25 private DataBrokerService dataBrokerService;
27 static final Logger logger = LoggerFactory.getLogger(MDSALConsumer.class);
29 void setBindingAwareBroker (BindingAwareBroker b) {
33 void unsetBindingAwareBroker(BindingAwareBroker b) {
34 if (this.broker == b) {
39 void init(Component c) {
40 this.ctx = c.getDependencyManager().getBundleContext();
41 logger.info("OVSDB Neutron Registered with MD-SAL");
42 broker.registerConsumer(this, this.ctx);
46 // Now lets close MDSAL session
47 if (this.consumerContext != null) {
48 //this.consumerContext.close();
49 this.consumerContext = null;
60 public void onSessionInitialized(ConsumerContext session) {
61 this.consumerContext = session;
62 dataBrokerService = session.getSALService(DataBrokerService.class);
63 logger.info("OVSDB Neutron Session Initilized with CONSUMER CONTEXT {}", session.toString());
67 public ConsumerContext getConsumerContext() {
68 return consumerContext;
71 public DataBrokerService getDataBrokerService() {
72 return dataBrokerService;