2 * Copyright (c) 2015 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.config.api.osgi.WaitingServiceTracker;
13 import org.opendaylight.controller.messagebus.spi.EventSource;
14 import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
15 import org.opendaylight.controller.messagebus.spi.EventSourceRegistry;
16 import org.osgi.framework.BundleContext;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 public class MessageBusAppImplModule extends AbstractMessageBusAppImplModule {
22 private static final Logger LOG = LoggerFactory.getLogger(MessageBusAppImplModule.class);
24 private BundleContext bundleContext;
26 public BundleContext getBundleContext() {
30 public void setBundleContext(final BundleContext bundleContext) {
31 this.bundleContext = bundleContext;
34 public MessageBusAppImplModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver) {
35 super(identifier, dependencyResolver);
38 public MessageBusAppImplModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver,
39 final MessageBusAppImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
40 super(identifier, dependencyResolver, oldModule, oldInstance);
44 public java.lang.AutoCloseable createInstance() {
45 final WaitingServiceTracker<EventSourceRegistry> tracker =
46 WaitingServiceTracker.create(EventSourceRegistry.class, bundleContext);
47 final EventSourceRegistry service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
49 return new EventSourceRegistry() {
52 // We need to close the WaitingServiceTracker however we don't want to close the actual
53 // service instance because its life-cycle is controlled via blueprint.
58 public <T extends EventSource> EventSourceRegistration<T> registerEventSource(T eventSource) {
59 return service.registerEventSource(eventSource);