git rid of Blueprint openflowplugin.xml 32/77832/2
authorMichael Vorburger <vorburger@redhat.com>
Thu, 15 Nov 2018 00:38:06 +0000 (01:38 +0100)
committerMichael Vorburger <vorburger@redhat.com>
Thu, 15 Nov 2018 01:47:53 +0000 (02:47 +0100)
JIRA: OPNFLWPLUG-1046
Change-Id: Icc6a06cba34e45a81bc5d0161bdc532a4b4012f4
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
12 files changed:
openflowjava/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProviderList.java [new file with mode: 0644]
openflowjava/openflowjava-blueprint-config/src/main/resources/OSGI-INF/blueprint/openflowjava.xml
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java [deleted file]
openflowplugin-blueprint-config/src/main/resources/OSGI-INF/blueprint/openflowplugin.xml [deleted file]
openflowplugin-impl/pom.xml
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/ForwardingPingPongDataBroker.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java [deleted file]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenflowPluginDiagStatusProvider.java [moved from openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/diagstatus/OpenflowPluginDiagStatusProvider.java with 87% similarity]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/PingPongDataBroker.java [new file with mode: 0644]
openflowplugin-impl/src/main/resources/OSGI-INF/blueprint/openflowplugin-impl.xml
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java

diff --git a/openflowjava/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProviderList.java b/openflowjava/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProviderList.java
new file mode 100644 (file)
index 0000000..da8bf0c
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2018 Red Hat, 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.openflowjava.protocol.spi.connection;
+
+import com.google.common.collect.ForwardingList;
+import java.util.List;
+
+/**
+ * {@link List} of {@link SwitchConnectionProvider}.
+ * This is useful for strongly typed dependency injection,
+ * and makes it simpler to have a common single source of truth
+ * between Blueprint and other DI frameworks in a standalone environment.
+ *
+ * @author Michael Vorburger.ch
+ */
+public class SwitchConnectionProviderList extends ForwardingList<SwitchConnectionProvider> {
+
+    private final List<SwitchConnectionProvider> switchConnectionProviders;
+
+    public SwitchConnectionProviderList(List<SwitchConnectionProvider> switchConnectionProviders) {
+        this.switchConnectionProviders = switchConnectionProviders;
+    }
+
+    @Override
+    protected List<SwitchConnectionProvider> delegate() {
+        return switchConnectionProviders;
+    }
+}
index f54f1dca3779cc0b21765f02d5a54e08a32d9040..d26b04ea4e8f24863b26d75ae95f43fab7958e79 100644 (file)
@@ -9,11 +9,9 @@
       binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
       list-key-value="openflow-switch-connection-provider-default-impl">
   </odl:clustered-app-config>
-
   <bean id="defaultSwitchConnProvider" factory-ref="switchConnectionProviderFactory" factory-method="newInstance">
     <argument ref="defaultSwitchConnConfig"/>
   </bean>
-
   <service ref="defaultSwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
           odl:type="openflow-switch-connection-provider-default-impl"/>
 
       binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
       list-key-value="openflow-switch-connection-provider-legacy-impl">
   </odl:clustered-app-config>
-
   <bean id="legacySwitchConnProvider" factory-ref="switchConnectionProviderFactory" factory-method="newInstance">
     <argument ref="legacySwitchConnConfig"/>
   </bean>
-
   <service ref="legacySwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
           odl:type="openflow-switch-connection-provider-legacy-impl"/>
 
+  <bean id="switchConnectionProviders" class="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList">
+      <argument>
+          <list>
+              <ref component-id="defaultSwitchConnProvider"/>
+              <ref component-id="legacySwitchConnProvider"/>
+          </list>
+      </argument>
+  </bean>
+  <service ref="switchConnectionProviders" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList"/>
 </blueprint>
diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java
deleted file mode 100644 (file)
index d030e61..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2016 Brocade Communications 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.openflowplugin.api.openflow;
-
-import java.util.List;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.infrautils.ready.SystemReadyMonitor;
-import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
-import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider;
-import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
-import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
-
-/**
- * Factory for creating OpenFlowPluginProvider instances.
- */
-public interface OpenFlowPluginProviderFactory {
-    OpenFlowPluginProvider newInstance(ConfigurationService configurationService,
-                                       DataBroker dataBroker,
-                                       RpcProviderRegistry rpcRegistry,
-                                       NotificationPublishService notificationPublishService,
-                                       EntityOwnershipService entityOwnershipService,
-                                       List<SwitchConnectionProvider> switchConnectionProviders,
-                                       ClusterSingletonServiceProvider singletonServiceProvider,
-                                       MastershipChangeServiceManager mastershipChangeServiceManager,
-                                       OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider,
-                                       SystemReadyMonitor systemReadyMonitor);
-}
diff --git a/openflowplugin-blueprint-config/src/main/resources/OSGI-INF/blueprint/openflowplugin.xml b/openflowplugin-blueprint-config/src/main/resources/OSGI-INF/blueprint/openflowplugin.xml
deleted file mode 100644 (file)
index d29aa7b..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
-           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
-           odl:use-default-for-reference-types="true">
-
-    <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
-    <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
-    <reference id="notificationPublishService" interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"/>
-    <reference id="entityOwnershipService" interface="org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService"/>
-    <reference id="clusterSingletonServiceProvider" interface="org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider"/>
-    <reference id="diagStatusService" interface="org.opendaylight.infrautils.diagstatus.DiagStatusService" />
-    <reference id="systemReadyMonitor" interface="org.opendaylight.infrautils.ready.SystemReadyMonitor" />
-
-    <reference id="defaultSwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
-               odl:type="openflow-switch-connection-provider-default-impl"/>
-
-    <reference id="legacySwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
-               odl:type="openflow-switch-connection-provider-legacy-impl"/>
-
-    <reference id="openflowPluginProviderFactory"
-               interface="org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory"/>
-
-    <reference id="configurationServiceFactory"
-               interface="org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationServiceFactory"/>
-
-    <reference id="mastershipChangeServiceManager"
-               interface="org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager"/>
-
-    <odl:clustered-app-config id="openflowProviderConfig"
-                              binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig"/>
-
-    <bean id="configurationService"
-          factory-ref="configurationServiceFactory"
-          factory-method="newInstance"
-          destroy-method="close">
-        <argument ref="openflowProviderConfig" />
-        <cm:managed-properties persistent-id="org.opendaylight.openflowplugin"
-                               update-strategy="component-managed"
-                               update-method="update"/>
-    </bean>
-
-    <bean id="ofPluginDiagstatusProvider"
-          class="org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider">
-        <argument ref="diagStatusService"/>
-        <argument>
-            <list>
-                <ref component-id="defaultSwitchConnProvider"/>
-                <ref component-id="legacySwitchConnProvider"/>
-            </list>
-        </argument>
-    </bean>
-
-    <service ref="ofPluginDiagstatusProvider" interface="org.opendaylight.infrautils.diagstatus.ServiceStatusProvider"/>
-
-    <service ref="configurationService" interface="org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService"/>
-
-    <bean id="openflowPluginProvider"
-          factory-ref="openflowPluginProviderFactory"
-          factory-method="newInstance"
-          destroy-method="close">
-        <argument ref="configurationService"/>
-        <argument ref="dataBroker"/>
-        <argument ref="rpcRegistry"/>
-        <argument ref="notificationPublishService"/>
-        <argument ref="entityOwnershipService"/>
-        <argument>
-            <list>
-                <ref component-id="defaultSwitchConnProvider"/>
-                <ref component-id="legacySwitchConnProvider"/>
-            </list>
-        </argument>
-        <argument ref="clusterSingletonServiceProvider"/>
-        <argument ref="mastershipChangeServiceManager"/>
-        <argument ref="ofPluginDiagstatusProvider"/>
-        <argument ref="systemReadyMonitor"/>
-    </bean>
-
-    <service ref="openflowPluginProvider">
-        <interfaces>
-            <value>org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider</value>
-            <value>org.opendaylight.openflowplugin.extension.api.OpenFlowPluginExtensionRegistratorProvider</value>
-        </interfaces>
-    </service>
-
-</blueprint>
index a0a2ee095046999693d6fe1b4d6a6aae53f4bb22..254626301cf21dfbecc684f2c2c63b1954ef74b9 100644 (file)
@@ -85,6 +85,7 @@
         <dependency>
             <groupId>javax.inject</groupId>
             <artifactId>javax.inject</artifactId>
+            <optional>true</optional>
         </dependency>
         <dependency>
             <groupId>junit</groupId>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>openflowplugin-common</artifactId>
         </dependency>
-        <dependency>
-            <groupId>javax.inject</groupId>
-            <artifactId>javax.inject</artifactId>
-            <optional>true</optional>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.aries.blueprint</groupId>
-            <artifactId>blueprint-maven-plugin-annotation</artifactId>
-            <optional>true</optional>
-        </dependency>
     </dependencies>
 
     <build>
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/ForwardingPingPongDataBroker.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/ForwardingPingPongDataBroker.java
new file mode 100644 (file)
index 0000000..ad58e04
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2018 Red Hat, 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.openflowplugin.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.ForwardingDataBroker;
+
+/**
+ * Delegating {@link PingPongDataBroker} implementation.
+ * This is useful for simple strongly typed dependency injection.
+ *
+ * @author Michael Vorburger.ch
+ */
+public class ForwardingPingPongDataBroker extends ForwardingDataBroker implements PingPongDataBroker {
+
+    private final DataBroker delegate;
+
+    public ForwardingPingPongDataBroker(DataBroker delegate) {
+        this.delegate = delegate;
+    }
+
+    @Override
+    protected DataBroker delegate() {
+        return delegate;
+    }
+}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java
deleted file mode 100644 (file)
index f3d63bf..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2016, 2017 Brocade Communications 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.openflowplugin.impl;
-
-import java.util.List;
-import javax.inject.Singleton;
-import org.apache.aries.blueprint.annotation.service.Service;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.infrautils.ready.SystemReadyMonitor;
-import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
-import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider;
-import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
-import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory;
-import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
-import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of OpenFlowPluginProviderFactory.
- *
- * @author Thomas Pantelis
- */
-@Singleton
-@Service(classes = OpenFlowPluginProviderFactory.class)
-public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProviderFactory {
-    private static final Logger LOG = LoggerFactory.getLogger(OpenFlowPluginProviderFactoryImpl.class);
-
-    @Override
-    public OpenFlowPluginProvider newInstance(final ConfigurationService configurationService,
-                                              final DataBroker dataBroker,
-                                              final RpcProviderRegistry rpcRegistry,
-                                              final NotificationPublishService notificationPublishService,
-                                              final EntityOwnershipService entityOwnershipService,
-                                              final List<SwitchConnectionProvider> switchConnectionProviders,
-                                              final ClusterSingletonServiceProvider singletonServiceProvider,
-                                              final MastershipChangeServiceManager mastershipChangeServiceManager,
-                                              final OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider,
-                                              final SystemReadyMonitor systemReadyMonitor) {
-        LOG.info("Initializing new OFP southbound.");
-        final OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(
-                configurationService,
-                switchConnectionProviders,
-                dataBroker,
-                rpcRegistry,
-                notificationPublishService,
-                singletonServiceProvider,
-                entityOwnershipService,
-                mastershipChangeServiceManager,
-                ofPluginDiagstatusProvider,
-                systemReadyMonitor);
-
-        openflowPluginProvider.initialize();
-        return openflowPluginProvider;
-    }
-}
index b5570aa7d593d194585eb3e95e1ae3c40c4d30e2..7df895f6078f84d29d1aff37874fc8d4b5198aed 100644 (file)
@@ -5,7 +5,6 @@
  * 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.openflowplugin.impl;
 
 import com.google.common.util.concurrent.FutureCallback;
@@ -26,6 +25,10 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.stream.Collectors;
 import javax.annotation.Nonnull;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.MBeanRegistrationException;
@@ -33,6 +36,8 @@ import javax.management.MBeanServer;
 import javax.management.MalformedObjectNameException;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
+import org.apache.aries.blueprint.annotation.service.Reference;
+import org.apache.aries.blueprint.annotation.service.Service;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
@@ -42,7 +47,7 @@ import org.opendaylight.infrautils.ready.SystemReadyMonitor;
 import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
-import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider;
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionManager;
@@ -79,6 +84,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
+@Service(classes = { OpenFlowPluginProvider.class, OpenFlowPluginExtensionRegistratorProvider.class })
 public class OpenFlowPluginProviderImpl implements
         OpenFlowPluginProvider,
         OpenFlowPluginExtensionRegistratorProvider,
@@ -122,18 +129,19 @@ public class OpenFlowPluginProviderImpl implements
         return MESSAGE_INTELLIGENCE_AGENCY;
     }
 
-    OpenFlowPluginProviderImpl(final ConfigurationService configurationService,
-                               final List<SwitchConnectionProvider> switchConnectionProviders,
-                               final DataBroker dataBroker,
-                               final RpcProviderRegistry rpcProviderRegistry,
-                               final NotificationPublishService notificationPublishService,
-                               final ClusterSingletonServiceProvider singletonServiceProvider,
-                               final EntityOwnershipService entityOwnershipService,
+    @Inject
+    public OpenFlowPluginProviderImpl(final ConfigurationService configurationService,
+                               final SwitchConnectionProviderList switchConnectionProviders,
+                               final PingPongDataBroker pingPongDataBroker,
+                               final @Reference RpcProviderRegistry rpcProviderRegistry,
+                               final @Reference NotificationPublishService notificationPublishService,
+                               final @Reference ClusterSingletonServiceProvider singletonServiceProvider,
+                               final @Reference EntityOwnershipService entityOwnershipService,
                                final MastershipChangeServiceManager mastershipChangeServiceManager,
                                final OpenflowPluginDiagStatusProvider openflowPluginStatusMonitor,
-                               final SystemReadyMonitor systemReadyMonitor) {
+                               final @Reference SystemReadyMonitor systemReadyMonitor) {
         this.switchConnectionProviders = switchConnectionProviders;
-        this.dataBroker = dataBroker;
+        this.dataBroker = pingPongDataBroker;
         this.rpcProviderRegistry = rpcProviderRegistry;
         this.notificationPublishService = notificationPublishService;
         this.singletonServicesProvider = singletonServiceProvider;
@@ -211,6 +219,7 @@ public class OpenFlowPluginProviderImpl implements
     }
 
     @Override
+    @PostConstruct
     public void initialize() {
         registerMXBean(MESSAGE_INTELLIGENCE_AGENCY, MESSAGE_INTELLIGENCE_AGENCY_MX_BEAN_NAME);
 
@@ -279,6 +288,7 @@ public class OpenFlowPluginProviderImpl implements
     }
 
     @Override
+    @PreDestroy
     public void close() {
         try {
             shutdownSwitchConnections().get(10, TimeUnit.SECONDS);
@@ -5,20 +5,27 @@
  * 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.openflowplugin.api.diagstatus;
+package org.opendaylight.openflowplugin.impl;
 
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.Socket;
 import java.util.List;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.apache.aries.blueprint.annotation.service.Reference;
+import org.apache.aries.blueprint.annotation.service.Service;
 import org.opendaylight.infrautils.diagstatus.DiagStatusService;
 import org.opendaylight.infrautils.diagstatus.ServiceDescriptor;
 import org.opendaylight.infrautils.diagstatus.ServiceState;
 import org.opendaylight.infrautils.diagstatus.ServiceStatusProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
+@Service(classes = ServiceStatusProvider.class)
 public class OpenflowPluginDiagStatusProvider implements ServiceStatusProvider {
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginDiagStatusProvider.class);
@@ -30,8 +37,9 @@ public class OpenflowPluginDiagStatusProvider implements ServiceStatusProvider {
     private InetAddress defaultInetAddres;
     private InetAddress legacyInetAddress;
 
-    public OpenflowPluginDiagStatusProvider(final DiagStatusService diagStatusService,
-                                            final List<SwitchConnectionProvider> switchConnectionProviders) {
+    @Inject
+    public OpenflowPluginDiagStatusProvider(final @Reference DiagStatusService diagStatusService,
+                                            final SwitchConnectionProviderList switchConnectionProviders) {
         this.diagStatusService = diagStatusService;
         setSwitchConnectionInetAddress(switchConnectionProviders);
         diagStatusService.register(OPENFLOW_SERVICE_NAME);
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/PingPongDataBroker.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/PingPongDataBroker.java
new file mode 100644 (file)
index 0000000..009fa5a
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2018 Red Hat, 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.openflowplugin.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+
+/**
+ * An <code>odl:type="pingpong"</code> {@link DataBroker}.
+ *
+ * @author Michael Vorburger.ch
+ */
+public interface PingPongDataBroker extends DataBroker {}
index 0642bf64293226fba9e579b1a87b4d9b422fc773..4bda6dff3553cc12abf365906512359688087352 100644 (file)
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
            odl:use-default-for-reference-types="true">
 
   <bean id="configurationServiceFactory" class="org.opendaylight.openflowplugin.impl.configuration.ConfigurationServiceFactoryOsgiImpl">
@@ -8,5 +10,25 @@
   </bean>
   <service ref="configurationServiceFactory" interface="org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationServiceFactory"/>
 
+  <odl:clustered-app-config id="openflowProviderConfig"
+                          binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig"/>
+  <bean id="configurationService"
+        factory-ref="configurationServiceFactory"
+        factory-method="newInstance"
+        destroy-method="close">
+      <argument ref="openflowProviderConfig" />
+      <cm:managed-properties persistent-id="org.opendaylight.openflowplugin"
+                             update-strategy="component-managed"
+                             update-method="update"/>
+  </bean>
+  <service ref="configurationService" interface="org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService"/>
+
+  <reference id="ppDB" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" odl:type="pingpong"/>
+  <bean id="pingPongDataBroker" class="org.opendaylight.openflowplugin.impl.ForwardingPingPongDataBroker">
+    <argument ref="ppDB"/>
+  </bean>
+
+  <reference id="switchConnectionProviderList" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList" ext:proxy-method="classes"/>
+
   <odl:action-provider interface="org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService"/>
 </blueprint>
index cfc4f16ae942c830e3676695d0d27b4087780204..437550d38d36eb367f0e5dbbc1e31b97d9884e20 100644 (file)
@@ -20,7 +20,6 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
@@ -30,7 +29,7 @@ import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistratio
 import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
-import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider;
+import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
 import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
@@ -40,7 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 public class OpenFlowPluginProviderImplTest {
 
     @Mock
-    DataBroker dataBroker;
+    PingPongDataBroker dataBroker;
 
     @Mock
     RpcProviderRegistry rpcProviderRegistry;
@@ -112,7 +111,7 @@ public class OpenFlowPluginProviderImplTest {
     public void testInitializeAndClose() throws Exception {
         final OpenFlowPluginProviderImpl provider = new OpenFlowPluginProviderImpl(
                 configurationService,
-                Lists.newArrayList(switchConnectionProvider),
+                new SwitchConnectionProviderList(Lists.newArrayList(switchConnectionProvider)),
                 dataBroker,
                 rpcProviderRegistry,
                 notificationPublishService,