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 org.opendaylight.controller.sal.binding.api.BindingAwareConsumer
11 import org.opendaylight.controller.sal.binding.api.BindingAwareProvider
12 import org.osgi.framework.BundleContext
13 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker
14 import org.opendaylight.controller.sal.binding.api.NotificationProviderService
15 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
16 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
17 import org.opendaylight.yangtools.yang.binding.DataObject
18 import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener
19 import org.opendaylight.controller.sal.binding.spi.RpcContextIdentifier
20 import org.opendaylight.controller.sal.binding.api.data.DataProviderService
21 import org.slf4j.LoggerFactory
23 class BindingAwareBrokerImpl extends RpcProviderRegistryImpl implements BindingAwareBroker, AutoCloseable {
24 private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl)
26 private InstanceIdentifier<? extends DataObject> root = InstanceIdentifier.builder().toInstance();
29 private var NotificationProviderService notifyBroker
32 private var DataProviderService dataBroker
35 var BundleContext brokerBundleContext
37 public new(String name,BundleContext bundleContext) {
39 _brokerBundleContext = bundleContext;
43 log.info("Starting MD-SAL: Binding Aware Broker");
48 override registerConsumer(BindingAwareConsumer consumer, BundleContext bundleCtx) {
49 val ctx = consumer.createContext(bundleCtx)
50 consumer.onSessionInitialized(ctx)
54 override registerProvider(BindingAwareProvider provider, BundleContext bundleCtx) {
55 val ctx = provider.createContext(bundleCtx)
56 provider.onSessionInitialized(ctx)
57 provider.onSessionInitiated(ctx as ProviderContext)
61 private def createContext(BindingAwareConsumer consumer, BundleContext consumerCtx) {
62 new OsgiConsumerContext(consumerCtx, this)
65 private def createContext(BindingAwareProvider provider, BundleContext providerCtx) {
66 new OsgiProviderContext(providerCtx, this)
69 override <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> registerRouteChangeListener(L listener) {
70 super.<L>registerRouteChangeListener(listener)
73 override close() throws Exception {