OPNFLWPLUG-1046 : Migrate OFP from XML to annotation based blueprint 60/78160/4
authorgobinath <gobinath@ericsson.com>
Mon, 26 Nov 2018 12:05:46 +0000 (17:35 +0530)
committergobinath <gobinath@ericsson.com>
Tue, 11 Dec 2018 09:42:57 +0000 (15:12 +0530)
BP to Annotation changes for reconciliation-framework module
Change-Id: If823064bd47cde9cc00d37bd33cb7410faae83ee
Signed-off-by: gobinath <gobinath@ericsson.com>
applications/arbitratorreconciliation/impl/pom.xml
applications/forwardingrules-manager/pom.xml
applications/reconciliation-framework/pom.xml
applications/reconciliation-framework/src/main/java/org/opendaylight/openflowplugin/applications/reconciliation/impl/ReconciliationManagerImpl.java
applications/reconciliation-framework/src/main/resources/OSGI-INF/blueprint/commands.xml
applications/reconciliation-framework/src/main/resources/OSGI-INF/blueprint/reconciliation-framework.xml [deleted file]

index 2946b62d339b262ed68f0c4cd280d2988e8e0867..c83e37e2eb46cddeb1ab2fa894bc42e0b3191ed5 100644 (file)
             <plugin>
                 <groupId>org.apache.aries.blueprint</groupId>
                 <artifactId>blueprint-maven-plugin</artifactId>
+                <configuration>
+                    <scanPaths>
+                        <scanPath>org.opendaylight.openflowplugin.applications.arbitratorreconciliation</scanPath>
+                    </scanPaths>
+                </configuration>
             </plugin>
         </plugins>
     </build>
index c492a6397059bd6744ff02d7fa27102b96e50d7d..494ee56a8604c7bed606579eb29435f8df4abe7e 100644 (file)
       <plugin>
         <groupId>org.apache.aries.blueprint</groupId>
         <artifactId>blueprint-maven-plugin</artifactId>
+        <configuration>
+          <scanPaths>
+            <scanPath>org.opendaylight.openflowplugin.applications.frm</scanPath>
+          </scanPaths>
+        </configuration>
       </plugin>
     </plugins>
   </build>
index 57bdc2d681ff8e302e34fc6423b152746f68413f..f0201b4a019da4f470cbb25e520b64de50034aab 100644 (file)
             <artifactId>org.apache.karaf.shell.console</artifactId>
             <scope>provided</scope>
         </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>
+        </plugins>
+    </build>
     <scm>
         <connection>scm:git:ssh://git.opendaylight.org:29418/openflowplugin.git</connection>
         <developerConnection>scm:git:ssh://git.opendaylight.org:29418/openflowplugin.git</developerConnection>
index 2eb4d395dc2bd67fb9ed1af4243a367c9d93f478..fab79142df4a27ab8f977ed0c8d61f83d679f807 100644 (file)
@@ -21,6 +21,12 @@ import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.concurrent.atomic.AtomicReference;
 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 org.apache.aries.blueprint.annotation.service.Reference;
+import org.apache.aries.blueprint.annotation.service.Service;
 import org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo;
 import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeException;
 import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
@@ -32,6 +38,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 = ReconciliationManager.class)
 public class ReconciliationManagerImpl implements ReconciliationManager, ReconciliationFrameworkEvent {
     private static final Logger LOG = LoggerFactory.getLogger(ReconciliationManagerImpl.class);
 
@@ -42,11 +50,13 @@ public class ReconciliationManagerImpl implements ReconciliationManager, Reconci
     private final Map<ResultState, Integer> resultStateMap = new ConcurrentHashMap<>();
     private final AtomicReference<ResultState> decidedResultState = new AtomicReference<>(ResultState.DONOTHING);
 
-    public ReconciliationManagerImpl(MastershipChangeServiceManager mastershipChangeServiceManager) {
+    @Inject
+    public ReconciliationManagerImpl(@Reference MastershipChangeServiceManager mastershipChangeServiceManager) {
         this.mastershipChangeServiceManager = Preconditions
                 .checkNotNull(mastershipChangeServiceManager, "MastershipChangeServiceManager can not be null!");
     }
 
+    @PostConstruct
     public void start() throws MastershipChangeException {
         mastershipChangeServiceManager.reconciliationFrameworkRegistration(this);
         LOG.info("ReconciliationManager has started successfully.");
@@ -88,6 +98,7 @@ public class ReconciliationManagerImpl implements ReconciliationManager, Reconci
     }
 
     @Override
+    @PreDestroy
     public void close() throws Exception {
     }
 
index 03aff8336e45922cd7276a228152704105217927..85dadeadea3c25b20fd4bfa9d06693e1de5a0079 100644 (file)
@@ -3,14 +3,11 @@
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
            odl:use-default-for-reference-types="true">
 
-    <reference id="reconciliationManagerRef"
-               interface="org.opendaylight.openflowplugin.applications.reconciliation.ReconciliationManager"
-               availability="optional"/>
     <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
         <command>
             <action class="org.opendaylight.openflowplugin.applications.reconciliation.cli.GetRegisteredServices">
                 <property name="reconciliationManager"
-                          ref="reconciliationManagerRef"/>
+                          ref="reconciliationManagerImpl"/>
             </action>
         </command>
     </command-bundle>
diff --git a/applications/reconciliation-framework/src/main/resources/OSGI-INF/blueprint/reconciliation-framework.xml b/applications/reconciliation-framework/src/main/resources/OSGI-INF/blueprint/reconciliation-framework.xml
deleted file mode 100644 (file)
index f5ad65a..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
-           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
-           odl:use-default-for-reference-types="true">
-
-  <reference id="mastershipChangeServiceManager"
-             interface="org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager"/>
-  <bean id="reconciliationManagerImpl"
-        class="org.opendaylight.openflowplugin.applications.reconciliation.impl.ReconciliationManagerImpl"
-        init-method="start"
-        destroy-method="close">
-    <argument ref="mastershipChangeServiceManager"/>
-  </bean>
-  <service ref="reconciliationManagerImpl"
-           interface="org.opendaylight.openflowplugin.applications.reconciliation.ReconciliationManager"
-           odl:type="default"/>
-
-</blueprint>
\ No newline at end of file