<module>
<name>messagebus-app-impl</name>
<type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:messagebus:app:impl">binding-impl:messagebus-app-impl</type>
- <binding-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:messagebus:app:impl">
- <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">prefix:binding-broker-osgi-registry</type>
- <name>binding-osgi-broker</name>
- </binding-broker>
</module>
</modules>
<services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
import org.opendaylight.controller.config.api.DependencyResolver;
import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.messagebus.app.impl.EventSourceTopology;
-import org.opendaylight.controller.messagebus.app.util.Providers;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+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;
-public class MessageBusAppImplModule extends org.opendaylight.controller.config.yang.messagebus.app.impl.AbstractMessageBusAppImplModule {
+@Deprecated
+public class MessageBusAppImplModule extends AbstractMessageBusAppImplModule {
private static final Logger LOG = LoggerFactory.getLogger(MessageBusAppImplModule.class);
private BundleContext bundleContext;
super(identifier, dependencyResolver, oldModule, oldInstance);
}
- @Override
- protected void customValidation() {
- }
-
@Override
public java.lang.AutoCloseable createInstance() {
- final ProviderContext bindingCtx = getBindingBrokerDependency().registerProvider(new Providers.BindingAware());
- final DataBroker dataBroker = bindingCtx.getSALService(DataBroker.class);
- final RpcProviderRegistry rpcRegistry = bindingCtx.getSALService(RpcProviderRegistry.class);
- final EventSourceTopology eventSourceTopology = new EventSourceTopology(dataBroker, rpcRegistry);
- LOG.info("Messagebus initialized");
- return eventSourceTopology;
+ 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();
+ }
+
+ @Override
+ public <T extends EventSource> EventSourceRegistration<T> registerEventSource(T eventSource) {
+ return service.registerEventSource(eventSource);
+ }
+ };
}
-
}
import org.opendaylight.controller.config.spi.Module;
import org.osgi.framework.BundleContext;
-public class MessageBusAppImplModuleFactory extends org.opendaylight.controller.config.yang.messagebus.app.impl.AbstractMessageBusAppImplModuleFactory {
+@Deprecated
+public class MessageBusAppImplModuleFactory extends AbstractMessageBusAppImplModuleFactory {
@Override
public Module createModule(String instanceName,
DependencyResolver dependencyResolver,
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2017 Inocybe Technologies 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,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+ odl:use-default-for-reference-types="true">
+
+ <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+ <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
+
+ <bean id="eventSourceTopology" class="org.opendaylight.controller.messagebus.app.impl.EventSourceTopology"
+ destroy-method="close">
+ <argument ref="dataBroker"/>
+ <argument ref="rpcRegistry"/>
+ </bean>
+
+ <service ref="eventSourceTopology"
+ interface="org.opendaylight.controller.messagebus.spi.EventSourceRegistry"/>
+</blueprint>
}
identity messagebus-app-impl {
+ status deprecated;
base config:module-type;
config:provided-service esr:event-source-registry;
config:java-name-prefix MessageBusAppImpl;
container binding-broker {
uses config:service-ref {
refine type {
- mandatory true;
+ mandatory false;
config:required-identity sal:binding-broker-osgi-registry;
}
}
}
}
-}
\ No newline at end of file
+}
+++ /dev/null
-/*
- * 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.messagebus.app.impl;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
-import org.osgi.framework.BundleContext;
-
-public class MessageBusAppImplModuleFactoryTest {
-
- DependencyResolver dependencyResolverMock;
- BundleContext bundleContextMock;
- MessageBusAppImplModuleFactory messageBusAppImplModuleFactory;
- DynamicMBeanWithInstance dynamicMBeanWithInstanceMock;
-
- @BeforeClass
- public static void initTestClass() throws IllegalAccessException, InstantiationException {
- }
-
- @Before
- public void setUp() throws Exception {
- dependencyResolverMock = mock(DependencyResolver.class);
- bundleContextMock = mock(BundleContext.class);
- dynamicMBeanWithInstanceMock = mock(DynamicMBeanWithInstance.class);
- messageBusAppImplModuleFactory = new MessageBusAppImplModuleFactory();
- }
-
- @Test
- public void createModuleTest() {
- assertNotNull("Module has not been created correctly.", messageBusAppImplModuleFactory.createModule("instanceName1", dependencyResolverMock, bundleContextMock));
- }
-
- @Test
- public void createModuleBTest() throws Exception{
- MessageBusAppImplModule messageBusAppImplModuleMock = mock(MessageBusAppImplModule.class);
- doReturn(messageBusAppImplModuleMock).when(dynamicMBeanWithInstanceMock).getModule();
- assertNotNull("Module has not been created correctly.", messageBusAppImplModuleFactory.createModule("instanceName1", dependencyResolverMock, dynamicMBeanWithInstanceMock, bundleContextMock));
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.controller.config.yang.messagebus.app.impl;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.JmxAttribute;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.MountPointService;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotificationPublishService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.opendaylight.controller.sal.core.api.Provider;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.osgi.framework.BundleContext;
-
-import com.google.common.util.concurrent.CheckedFuture;
-
-import javax.management.ObjectName;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-public class MessageBusAppImplModuleTest {
-
- MessageBusAppImplModule messageBusAppImplModule;
- ModuleIdentifier moduleIdentifier;
- DependencyResolver dependencyResolverMock;
-
- @BeforeClass
- public static void initTestClass() throws IllegalAccessException, InstantiationException {
- }
-
- @Before
- public void setUp() throws Exception {
- moduleIdentifier = new ModuleIdentifier("factoryName1", "instanceName1");
- dependencyResolverMock = mock(DependencyResolver.class);
- messageBusAppImplModule = new MessageBusAppImplModule(moduleIdentifier, dependencyResolverMock);
- }
-
- @Test
- public void constructorTest() {
- assertNotNull("Instance has not been created correctly.", messageBusAppImplModule);
- }
-
- @Test
- public void constructorBTest() {
- MessageBusAppImplModule messageBusAppImplModuleOld = mock(MessageBusAppImplModule.class);
- java.lang.AutoCloseable oldInstanceAutocloseableMock = mock(AutoCloseable.class);
- MessageBusAppImplModule messageBusAppImplModule = new MessageBusAppImplModule(moduleIdentifier, dependencyResolverMock, messageBusAppImplModuleOld, oldInstanceAutocloseableMock);
- assertNotNull("Instance has not been created correctly.", messageBusAppImplModule);
- }
-
- @Test
- public void setGetBundleContextTest() {
- BundleContext bundleContext = mock(BundleContext.class);
- messageBusAppImplModule.setBundleContext(bundleContext);
- assertEquals("Set and/or get method/s don't work correctly.", bundleContext, messageBusAppImplModule.getBundleContext());
- }
-
- @Test
- public void createInstanceTest() throws Exception{
- org.opendaylight.controller.sal.binding.api.BindingAwareBroker bindingAwareBrokerMock = mock(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.class);
- Broker brokerMock = mock(Broker.class);
- doReturn(brokerMock).when(dependencyResolverMock).resolveInstance(eq(org.opendaylight.controller.sal.core.api.Broker.class), any(ObjectName.class), any(JmxAttribute.class));
- doReturn(bindingAwareBrokerMock).when(dependencyResolverMock).resolveInstance(eq(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class));
- messageBusAppImplModule.resolveDependencies();
-
- BindingAwareBroker.ProviderContext providerContext = mock(BindingAwareBroker.ProviderContext.class);
- doReturn(providerContext).when(bindingAwareBrokerMock).registerProvider(any(BindingAwareProvider.class));
- Broker.ProviderSession providerSessionMock = mock(Broker.ProviderSession.class);
- doReturn(providerSessionMock).when(brokerMock).registerProvider(any(Provider.class));
- DataBroker dataBrokerMock = mock(DataBroker.class);
- doReturn(dataBrokerMock).when(providerContext).getSALService(eq(DataBroker.class));
- DOMNotificationPublishService domNotificationPublishServiceMock = mock(DOMNotificationPublishService.class);
- doReturn(domNotificationPublishServiceMock).when(providerSessionMock).getService(DOMNotificationPublishService.class);
- DOMMountPointService domMountPointServiceMock = mock(DOMMountPointService.class);
- doReturn(domMountPointServiceMock).when(providerSessionMock).getService(DOMMountPointService.class);
- MountPointService mountPointServiceMock = mock(MountPointService.class);
- doReturn(mountPointServiceMock).when(providerContext).getSALService(eq(MountPointService.class));
- RpcProviderRegistry rpcProviderRegistryMock = mock(RpcProviderRegistry.class);
- doReturn(rpcProviderRegistryMock).when(providerContext).getSALService(eq(RpcProviderRegistry.class));
-
- WriteTransaction writeTransactionMock = mock(WriteTransaction.class);
- doReturn(writeTransactionMock).when(dataBrokerMock).newWriteOnlyTransaction();
- doNothing().when(writeTransactionMock).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(DataObject.class), eq(true));
- CheckedFuture checkedFutureMock = mock(CheckedFuture.class);
- doReturn(checkedFutureMock).when(writeTransactionMock).submit();
- assertNotNull("EventSourceRegistryWrapper has not been created correctly.", messageBusAppImplModule.createInstance());
- }
-
-}
\ No newline at end of file
}
identity event-source-registry {
+ status deprecated;
base "config:service-type";
config:java-class "org.opendaylight.controller.messagebus.spi.EventSourceRegistry";
+ config:disable-osgi-service-registration;
}
}