OPNFLWPLUG-1046 : Migrate OFP from XML to annotation based blueprint 62/78162/3
authorgobinath <gobinath@ericsson.com>
Mon, 26 Nov 2018 15:08:16 +0000 (20:38 +0530)
committergobinath <gobinath@ericsson.com>
Tue, 11 Dec 2018 05:34:52 +0000 (11:04 +0530)
BP to Annotation changes for of-switch-config-pusher module

Change-Id: I822ac17da2559cbfb26ca9ee1203f3e620cdc46c
Signed-off-by: gobinath <gobinath@ericsson.com>
applications/of-switch-config-pusher/pom.xml
applications/of-switch-config-pusher/src/main/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusher.java
applications/of-switch-config-pusher/src/main/resources/OSGI-INF/blueprint/of-switch-config-pusher.xml

index 73caa58f5c91684e21dfd752976349dd20bb5b03..c5928645948d1aaa4be19aaabac460adfdd86d9e 100644 (file)
             <artifactId>junit</artifactId>
             <scope>test</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>
+                <configuration>
+                    <scanPaths>
+                        <scanPath>org.opendaylight.openflowplugin.openflow.ofswitch.config</scanPath>
+                    </scanPaths>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
index 6a2bfe896409d54f9ab4d55d7622eb7d199780af..9ae9e180fac55690dc89843201a35557afb9bb58 100644 (file)
@@ -12,6 +12,11 @@ import com.google.common.base.Preconditions;
 import java.util.Collection;
 import java.util.concurrent.Future;
 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.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
@@ -36,6 +41,7 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class DefaultConfigPusher implements AutoCloseable, ClusteredDataTreeChangeListener<FlowCapableNode> {
     private static final Logger LOG = LoggerFactory.getLogger(DefaultConfigPusher.class);
     private static final long STARTUP_LOOP_TICK = 500L;
@@ -45,8 +51,9 @@ public class DefaultConfigPusher implements AutoCloseable, ClusteredDataTreeChan
     private final DeviceOwnershipService deviceOwnershipService;
     private ListenerRegistration<?> listenerRegistration;
 
-    public DefaultConfigPusher(NodeConfigService nodeConfigService, DataBroker dataBroker,
-            DeviceOwnershipService deviceOwnershipService) {
+    @Inject
+    public DefaultConfigPusher(NodeConfigService nodeConfigService, @Reference DataBroker dataBroker,
+            @Reference DeviceOwnershipService deviceOwnershipService) {
         this.nodeConfigService = nodeConfigService;
         this.dataBroker = dataBroker;
         this.deviceOwnershipService = Preconditions.checkNotNull(deviceOwnershipService,
@@ -54,6 +61,7 @@ public class DefaultConfigPusher implements AutoCloseable, ClusteredDataTreeChan
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
+    @PostConstruct
     public void start() {
         try {
             final InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class)
@@ -71,6 +79,7 @@ public class DefaultConfigPusher implements AutoCloseable, ClusteredDataTreeChan
     }
 
     @Override
+    @PreDestroy
     public void close() {
         if (listenerRegistration != null) {
             listenerRegistration.close();
index f303c62da2ea3e37ba47bb7c62fe9b3cd660056f..f56ddc8ed29b37f584c998299fe88451ee9d3040 100644 (file)
@@ -3,15 +3,6 @@
            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="deviceOwnershipService" interface="org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService"/>
-
   <odl:rpc-service id="nodeConfigService" interface="org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService"/>
 
-  <bean id="LLDPPacketPuntEnforcer" class="org.opendaylight.openflowplugin.openflow.ofswitch.config.DefaultConfigPusher"
-          init-method="start" destroy-method="close">
-    <argument ref="nodeConfigService"/>
-    <argument ref="dataBroker"/>
-    <argument ref="deviceOwnershipService"/>
-  </bean>
 </blueprint>
\ No newline at end of file