8d3545fbbb169f7faafd40330660dc5b109342ef
[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.opendaylight.yangtools.yang.binding.RpcService
13 import javassist.ClassPool
14 import org.osgi.framework.BundleContext
15 import java.util.Map
16 import javassist.LoaderClassPath
17 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker
18 import java.util.Hashtable
19 import static extension org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.*
20
21 import org.opendaylight.controller.sal.binding.api.NotificationProviderService
22 import org.osgi.framework.ServiceRegistration
23 import static org.opendaylight.controller.sal.binding.impl.osgi.Constants.*
24 import static extension org.opendaylight.controller.sal.binding.impl.osgi.PropertiesUtils.*
25 import org.opendaylight.controller.sal.binding.api.NotificationService
26 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext
27
28 import org.slf4j.LoggerFactory
29 import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator
30 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier
31 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration
32 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration
33 import org.opendaylight.controller.sal.binding.api.data.DataProviderService
34 import org.opendaylight.controller.sal.binding.api.data.DataBrokerService
35 import org.opendaylight.controller.sal.binding.spi.RpcRouter
36 import java.util.concurrent.ConcurrentHashMap
37 import static com.google.common.base.Preconditions.*
38 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration
39 import org.opendaylight.yangtools.yang.binding.BaseIdentity
40 import com.google.common.collect.Multimap
41 import com.google.common.collect.HashMultimap
42 import static org.opendaylight.controller.sal.binding.impl.util.ClassLoaderUtils.*
43 import java.util.concurrent.Executors
44 import java.util.Collections
45 import org.opendaylight.yangtools.yang.binding.DataObject
46 import java.util.concurrent.locks.ReentrantLock
47 import java.util.concurrent.Callable
48 import java.util.WeakHashMap
49 import javax.annotation.concurrent.GuardedBy
50 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry
51 import org.opendaylight.yangtools.concepts.ListenerRegistration
52 import org.opendaylight.yangtools.concepts.util.ListenerRegistry
53
54 class BindingAwareBrokerImpl extends RpcProviderRegistryImpl implements BindingAwareBroker, AutoCloseable {
55     private static val log = LoggerFactory.getLogger(BindingAwareBrokerImpl)
56
57     private InstanceIdentifier<? extends DataObject> root = InstanceIdentifier.builder().toInstance();
58
59     @Property
60     private var NotificationProviderService notifyBroker
61
62     @Property
63     private var DataProviderService dataBroker
64
65     @Property
66     var BundleContext brokerBundleContext
67
68     public new(BundleContext bundleContext) {
69         _brokerBundleContext = bundleContext;
70     }
71
72     def start() {
73         log.info("Starting MD-SAL: Binding Aware Broker");
74     }
75
76
77
78     override registerConsumer(BindingAwareConsumer consumer, BundleContext bundleCtx) {
79         val ctx = consumer.createContext(bundleCtx)
80         consumer.onSessionInitialized(ctx)
81         return ctx
82     }
83
84     override registerProvider(BindingAwareProvider provider, BundleContext bundleCtx) {
85         val ctx = provider.createContext(bundleCtx)
86         provider.onSessionInitialized(ctx)
87         provider.onSessionInitiated(ctx as ProviderContext)
88         return ctx
89     }
90
91     private def createContext(BindingAwareConsumer consumer, BundleContext consumerCtx) {
92         new OsgiConsumerContext(consumerCtx, this)
93     }
94
95     private def createContext(BindingAwareProvider provider, BundleContext providerCtx) {
96         new OsgiProviderContext(providerCtx, this)
97     }
98     
99     override close() throws Exception {
100         
101     }
102
103 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.