2 * Copyright (c) 2014 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.config.yang.messagebus.app.impl;
10 import org.opendaylight.controller.config.api.DependencyResolver;
11 import org.opendaylight.controller.config.api.ModuleIdentifier;
12 import org.opendaylight.controller.mdsal.InitializationContext;
13 import org.opendaylight.controller.mdsal.Providers;
14 import org.osgi.framework.BundleContext;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 import java.util.List;
20 public class MessageBusAppImplModule extends org.opendaylight.controller.config.yang.messagebus.app.impl.AbstractMessageBusAppImplModule {
21 private static final Logger LOGGER = LoggerFactory.getLogger(MessageBusAppImplModule.class);
23 private BundleContext bundleContext;
25 public BundleContext getBundleContext() {
29 public void setBundleContext(BundleContext bundleContext) {
30 this.bundleContext = bundleContext;
33 public MessageBusAppImplModule( ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
34 super(identifier, dependencyResolver);
37 public MessageBusAppImplModule( ModuleIdentifier identifier,
38 DependencyResolver dependencyResolver,
39 MessageBusAppImplModule oldModule,
40 java.lang.AutoCloseable oldInstance) {
41 super(identifier, dependencyResolver, oldModule, oldInstance);
45 protected void customValidation() {}
48 public java.lang.AutoCloseable createInstance() {
49 List<NamespaceToStream> namespaceMapping = getNamespaceToStream();
50 InitializationContext ic = new InitializationContext(namespaceMapping);
52 final Providers.BindingAware bap = new Providers.BindingAware(ic);
53 final Providers.BindingIndependent bip = new Providers.BindingIndependent(ic);
55 getBindingBrokerDependency().registerProvider(bap, getBundleContext());
56 getDomBrokerDependency().registerProvider(bip);
58 AutoCloseable closer = new AutoCloseable() {
59 @Override public void close() {
68 private void closeProvider(AutoCloseable closable) {
71 } catch (Exception e) {
72 LOGGER.error("Exception while closing: {}\n Exception: {}", closable, e);