17cd67a8576018485d3f1162dab89d51be0fcf15
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / config / yang / md / sal / binding / impl / BindingAsyncDataBrokerImplModule.java
1 package org.opendaylight.controller.config.yang.md.sal.binding.impl;
2
3 import java.util.Collection;
4 import java.util.Collections;
5
6 import org.opendaylight.controller.md.sal.binding.impl.ForwardedBindingDataBroker;
7 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
8 import org.opendaylight.controller.sal.core.api.Broker;
9 import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
10 import org.opendaylight.controller.sal.core.api.Provider;
11 import org.opendaylight.controller.sal.core.api.model.SchemaService;
12 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
13 import org.osgi.framework.BundleContext;
14
15 public class BindingAsyncDataBrokerImplModule extends
16         org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingAsyncDataBrokerImplModule implements
17         Provider {
18     private BundleContext bundleContext;
19
20     public BindingAsyncDataBrokerImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
21             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
22         super(identifier, dependencyResolver);
23     }
24
25     public BindingAsyncDataBrokerImplModule(
26             final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
27             final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
28             final org.opendaylight.controller.config.yang.md.sal.binding.impl.BindingAsyncDataBrokerImplModule oldModule,
29             final java.lang.AutoCloseable oldInstance) {
30         super(identifier, dependencyResolver, oldModule, oldInstance);
31     }
32
33     @Override
34     public void customValidation() {
35         // add custom validation form module attributes here.
36     }
37
38     @Override
39     public java.lang.AutoCloseable createInstance() {
40         Broker domBroker = getDomAsyncBrokerDependency();
41         BindingIndependentMappingService mappingService = getBindingMappingServiceDependency();
42
43         // FIXME: Switch this to DOM Broker registration which would not require
44         // BundleContext when API are updated.
45         ProviderSession session = domBroker.registerProvider(this, getBundleContext());
46         DOMDataBroker domDataBroker = session.getService(DOMDataBroker.class);
47         SchemaService schemaService = session.getService(SchemaService.class);
48         return new ForwardedBindingDataBroker(domDataBroker, mappingService, schemaService);
49     }
50
51     // FIXME: Remove this when DOM Broker registration would not require
52     // BundleContext
53     @Deprecated
54     private BundleContext getBundleContext() {
55         return bundleContext;
56     }
57
58     // FIXME: Remove this when DOM Broker registration would not require
59     // BundleContext
60     @Deprecated
61     void setBundleContext(final BundleContext bundleContext) {
62         this.bundleContext = bundleContext;
63     }
64
65     @Override
66     public Collection<ProviderFunctionality> getProviderFunctionality() {
67         return Collections.emptySet();
68     }
69
70     @Override
71     public void onSessionInitiated(final ProviderSession arg0) {
72         // intentional NOOP
73     }
74
75 }

©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.