-/**
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.mdsal.InitializationContext;
-import org.opendaylight.controller.mdsal.Providers;
+import org.opendaylight.controller.config.api.osgi.WaitingServiceTracker;
+import org.opendaylight.controller.messagebus.spi.EventSource;
+import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
+import org.opendaylight.controller.messagebus.spi.EventSourceRegistry;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.List;
-
-public class MessageBusAppImplModule extends org.opendaylight.controller.config.yang.messagebus.app.impl.AbstractMessageBusAppImplModule {
- private static final Logger LOGGER = LoggerFactory.getLogger(MessageBusAppImplModule.class);
+@Deprecated
+public class MessageBusAppImplModule extends AbstractMessageBusAppImplModule {
+ private static final Logger LOG = LoggerFactory.getLogger(MessageBusAppImplModule.class);
private BundleContext bundleContext;
return bundleContext;
}
- public void setBundleContext(BundleContext bundleContext) {
+ public void setBundleContext(final BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
- public MessageBusAppImplModule( ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
+ public MessageBusAppImplModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver) {
super(identifier, dependencyResolver);
}
- public MessageBusAppImplModule( ModuleIdentifier identifier,
- DependencyResolver dependencyResolver,
- MessageBusAppImplModule oldModule,
- java.lang.AutoCloseable oldInstance) {
+ public MessageBusAppImplModule(final ModuleIdentifier identifier, final DependencyResolver dependencyResolver,
+ final MessageBusAppImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
super(identifier, dependencyResolver, oldModule, oldInstance);
}
- @Override
- protected void customValidation() {}
-
@Override
public java.lang.AutoCloseable createInstance() {
- List<NamespaceToStream> namespaceMapping = getNamespaceToStream();
- InitializationContext ic = new InitializationContext(namespaceMapping);
-
- final Providers.BindingAware bap = new Providers.BindingAware(ic);
- final Providers.BindingIndependent bip = new Providers.BindingIndependent(ic);
-
- getBindingBrokerDependency().registerProvider(bap, getBundleContext());
- getDomBrokerDependency().registerProvider(bip);
+ final WaitingServiceTracker<EventSourceRegistry> tracker =
+ WaitingServiceTracker.create(EventSourceRegistry.class, bundleContext);
+ final EventSourceRegistry service = tracker.waitForService(WaitingServiceTracker.FIVE_MINUTES);
+
+ return new EventSourceRegistry() {
+ @Override
+ public void close() {
+ // We need to close the WaitingServiceTracker however we don't want to close the actual
+ // service instance because its life-cycle is controlled via blueprint.
+ tracker.close();
+ }
- AutoCloseable closer = new AutoCloseable() {
- @Override public void close() {
- closeProvider(bap);
- closeProvider(bip);
+ @Override
+ public <T extends EventSource> EventSourceRegistration<T> registerEventSource(T eventSource) {
+ return service.registerEventSource(eventSource);
}
};
-
- return closer;
- }
-
- private void closeProvider(AutoCloseable closable) {
- try {
- closable.close();
- } catch (Exception e) {
- LOGGER.error("Exception while closing: {}\n Exception: {}", closable, e);
- }
}
}