Merge "Simplify method isMutualExclusive in Subnet. Remove redundant 'if' statements."
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / sal / binding / impl / BindingAwareBrokerImpl.xtend
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 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
22
23 class BindingAwareBrokerImpl extends RpcProviderRegistryImpl implements BindingAwareBroker, AutoCloseable {
24     private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl)
25
26     private InstanceIdentifier<? extends DataObject> root = InstanceIdentifier.builder().toInstance();
27
28     @Property
29     private var NotificationProviderService notifyBroker
30
31     @Property
32     private var DataProviderService dataBroker
33
34     @Property
35     var BundleContext brokerBundleContext
36
37     public new(String name,BundleContext bundleContext) {
38         super(name);
39         _brokerBundleContext = bundleContext;
40     }
41
42     def start() {
43         log.info("Starting MD-SAL: Binding Aware Broker");
44     }
45
46
47
48     override registerConsumer(BindingAwareConsumer consumer, BundleContext bundleCtx) {
49         val ctx = consumer.createContext(bundleCtx)
50         consumer.onSessionInitialized(ctx)
51         return ctx
52     }
53
54     override registerProvider(BindingAwareProvider provider, BundleContext bundleCtx) {
55         val ctx = provider.createContext(bundleCtx)
56         provider.onSessionInitialized(ctx)
57         provider.onSessionInitiated(ctx as ProviderContext)
58         return ctx
59     }
60
61     private def createContext(BindingAwareConsumer consumer, BundleContext consumerCtx) {
62         new OsgiConsumerContext(consumerCtx, this)
63     }
64
65     private def createContext(BindingAwareProvider provider, BundleContext providerCtx) {
66         new OsgiProviderContext(providerCtx, this)
67     }
68
69     override <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> registerRouteChangeListener(L listener) {
70         super.<L>registerRouteChangeListener(listener)
71     }
72     
73     override close() throws Exception {
74         
75     }
76 }