use annotations instead XML for BP in impl 00/77800/2
authorMichael Vorburger <vorburger@redhat.com>
Wed, 14 Nov 2018 16:15:14 +0000 (17:15 +0100)
committerMichael Vorburger <vorburger@redhat.com>
Wed, 14 Nov 2018 22:05:19 +0000 (23:05 +0100)
JIRA: OPNFLWPLUG-1046
Change-Id: Idd8004a4aaac25c40fa7ec15beb1083115b0236a
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
openflowplugin-impl/pom.xml
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/configuration/ConfigurationServiceFactoryOsgiImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/mastership/MastershipChangeServiceManagerImpl.java
openflowplugin-impl/src/main/resources/OSGI-INF/blueprint/openflowplugin-impl.xml

index 96b0aa0dd1377ce595a00ffca94425451ac01165..a0a2ee095046999693d6fe1b4d6a6aae53f4bb22 100644 (file)
             <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>
         <plugins>
+            <plugin>
+                <groupId>org.apache.aries.blueprint</groupId>
+                <artifactId>blueprint-maven-plugin</artifactId>
+            </plugin>
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
index da7d56f2a9ae1299d4df1d88ac4d003ffe21f5ac..f3d63bf0e9111726afa8b8912af19a849e6a0fbd 100644 (file)
@@ -8,6 +8,8 @@
 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;
@@ -28,6 +30,8 @@ import org.slf4j.LoggerFactory;
  *
  * @author Thomas Pantelis
  */
+@Singleton
+@Service(classes = OpenFlowPluginProviderFactory.class)
 public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProviderFactory {
     private static final Logger LOG = LoggerFactory.getLogger(OpenFlowPluginProviderFactoryImpl.class);
 
index 5546ed63efcb1a8d33e2b8c96df442909d8ef43e..bd9e1ae540d526911e3ac6b4734663661b27ed50 100644 (file)
@@ -12,6 +12,7 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
+import javax.inject.Inject;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfig;
@@ -21,12 +22,14 @@ import org.osgi.service.cm.ConfigurationAdmin;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+// NOT @Singleton @Service - we do not want this OSGi specific implementation to be auto-discovered in a standalone env
 public class ConfigurationServiceFactoryOsgiImpl extends ConfigurationServiceFactoryImpl {
 
     private static final Logger LOG = LoggerFactory.getLogger(ConfigurationServiceFactoryOsgiImpl.class);
 
     private final BundleContext bundleContext;
 
+    @Inject
     public ConfigurationServiceFactoryOsgiImpl(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
index 240c2411aaad734fbda52b8c8a77f62ba62a3d35..45e6bb2bec1db751cb8b1616cacaf115ee808a2c 100644 (file)
@@ -13,6 +13,8 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 import javax.annotation.Nonnull;
+import javax.inject.Singleton;
+import org.apache.aries.blueprint.annotation.service.Service;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.lifecycle.MasterChecker;
 import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeException;
@@ -23,6 +25,8 @@ import org.opendaylight.openflowplugin.api.openflow.mastership.ReconciliationFra
 import org.opendaylight.openflowplugin.api.openflow.mastership.ReconciliationFrameworkRegistration;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState;
 
+@Singleton
+@Service(classes = MastershipChangeServiceManager.class)
 public final class MastershipChangeServiceManagerImpl implements MastershipChangeServiceManager {
 
     private final List<MastershipChangeService> serviceGroup = new CopyOnWriteArrayList<>();
index 5231eb0f48ecbe378757f694cdb2339e9bac01ea..0642bf64293226fba9e579b1a87b4d9b422fc773 100644 (file)
@@ -3,15 +3,10 @@
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
            odl:use-default-for-reference-types="true">
 
-  <odl:action-provider interface="org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService"/>
-  <bean id="ofPluginProviderFactory" class="org.opendaylight.openflowplugin.impl.OpenFlowPluginProviderFactoryImpl"/>
-  <service ref="ofPluginProviderFactory" interface="org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory"/>
-
   <bean id="configurationServiceFactory" class="org.opendaylight.openflowplugin.impl.configuration.ConfigurationServiceFactoryOsgiImpl">
     <argument ref="blueprintBundleContext"/>
   </bean>
   <service ref="configurationServiceFactory" interface="org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationServiceFactory"/>
 
-  <bean id="mastershipChangeServiceManager" class="org.opendaylight.openflowplugin.impl.mastership.MastershipChangeServiceManagerImpl"/>
-  <service ref="mastershipChangeServiceManager" interface="org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager"/>
+  <odl:action-provider interface="org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService"/>
 </blueprint>