Add blueprint wiring for the of-switch-config-pusher app 35/38835/4
authorTom Pantelis <tpanteli@brocade.com>
Tue, 10 May 2016 22:12:49 +0000 (18:12 -0400)
committerAnil Vishnoi <vishnoianil@gmail.com>
Fri, 3 Jun 2016 08:10:58 +0000 (08:10 +0000)
Change-Id: I38c0cbac5882468853a73882d717bb57b93d9c63
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
applications/of-switch-config-pusher/src/main/java/org/opendaylight/openflowplugin/openflow/ofswitch/config/DefaultConfigPusher.java
applications/of-switch-config-pusher/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/of/_switch/config/pusher/rev141015/DefaultConfigPusherModule.java
applications/of-switch-config-pusher/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/of/_switch/config/pusher/rev141015/DefaultConfigPusherModuleFactory.java
applications/of-switch-config-pusher/src/main/resources/initial/70-of-switch-config-pusher.xml
applications/of-switch-config-pusher/src/main/resources/org/opendaylight/blueprint/of-switch-config-pusher.xml [new file with mode: 0644]
applications/of-switch-config-pusher/src/main/yang/of-switch-config-pusher.yang

index 8f020b46dae075ac3a9b3f3ca2e4a7aa838e9919..40952c6ac779bc0b4f6d49fa98cf2be1aa4592c0 100644 (file)
@@ -9,14 +9,20 @@
 package org.opendaylight.openflowplugin.openflow.ofswitch.config;
 
 import java.util.Set;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
@@ -25,15 +31,28 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
  */
 public class DefaultConfigPusher implements AutoCloseable, DataChangeListener {
 
-    private NodeConfigService nodeConfigService;
+    private final NodeConfigService nodeConfigService;
+    private final DataBroker dataBroker;
+    private ListenerRegistration<DataChangeListener> dataChangeListenerRegistration;
 
-    public DefaultConfigPusher(NodeConfigService nodeConfigService) {
+    public DefaultConfigPusher(NodeConfigService nodeConfigService, DataBroker dataBroker) {
         this.nodeConfigService = nodeConfigService;
+        this.dataBroker = dataBroker;
     }
 
-    @Override
-    public void close() throws Exception {
+    public void start() {
+        InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).
+                augmentation(FlowCapableNode.class);
+        dataChangeListenerRegistration = dataBroker.registerDataChangeListener(
+                LogicalDatastoreType.OPERATIONAL,
+                path, this, AsyncDataBroker.DataChangeScope.BASE);
+    }
 
+    @Override
+    public void close() {
+        if(dataChangeListenerRegistration != null) {
+            dataChangeListenerRegistration.close();
+        }
     }
 
     @Override
index ff0ce1e6e5e9487723afd0ef710bab697dcb9f47..a38f826e7fad9e5cba35924a90cb56706068eec4 100644 (file)
@@ -1,15 +1,12 @@
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.of._switch.config.pusher.rev141015;
 
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.openflowplugin.openflow.ofswitch.config.DefaultConfigPusher;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 
-public class DefaultConfigPusherModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.of._switch.config.pusher.rev141015.AbstractDefaultConfigPusherModule {
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class DefaultConfigPusherModule extends AbstractDefaultConfigPusherModule {
     public DefaultConfigPusherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
@@ -18,20 +15,9 @@ public class DefaultConfigPusherModule extends org.opendaylight.yang.gen.v1.urn.
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
     @Override
     public java.lang.AutoCloseable createInstance() {
-        InstanceIdentifier<FlowCapableNode> path = InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
-        NodeConfigService nodeConfigService = getRpcRegistryDependency().getRpcService(NodeConfigService.class);
-        return getDataBrokerDependency().registerDataChangeListener(
-                LogicalDatastoreType.OPERATIONAL,
-                path,
-                new DefaultConfigPusher(nodeConfigService),
-                AsyncDataBroker.DataChangeScope.BASE);
+        // DefaultConfigPusher instance is created via blueprint so this in a no-op.
+        return NoopAutoCloseable.INSTANCE;
     }
-
 }
index e3150ef0614d47a1e68d80ed28fac2ad4e5bfe67..d6079bed9e5522ebda599a2fce3c3a481b4e9284 100644 (file)
@@ -8,6 +8,11 @@
 * Do not modify this file unless it is present under src/main directory
 */
 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.of._switch.config.pusher.rev141015;
-public class DefaultConfigPusherModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.of._switch.config.pusher.rev141015.AbstractDefaultConfigPusherModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class DefaultConfigPusherModuleFactory extends AbstractDefaultConfigPusherModuleFactory {
 
 }
index 4ab4a12c34332cc6aa0ffc5ed33e1b97aa8bea70..8aded67ad1fd4fcb3d66f88e309efe892e2d4f16 100644 (file)
@@ -5,6 +5,9 @@
   ~ 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
+
+  NOTE: This file is deprecated as wiring is now done via blueprint. This file is kept for
+       backwards compatibility. Runtime modifications are not honored.
   -->
 
 <!-- vi: set et smarttab sw=4 tabstop=4: -->
diff --git a/applications/of-switch-config-pusher/src/main/resources/org/opendaylight/blueprint/of-switch-config-pusher.xml b/applications/of-switch-config-pusher/src/main/resources/org/opendaylight/blueprint/of-switch-config-pusher.xml
new file mode 100644 (file)
index 0000000..39e82e8
--- /dev/null
@@ -0,0 +1,15 @@
+<?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"
+        odl:use-default-for-reference-types="true">
+
+  <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
+
+  <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"/>
+  </bean>
+</blueprint>
\ No newline at end of file
index 463edb6a60e3e47581ff49f5d5af6930266c73ed..adaa2a950b5e0f0fc4db0ab290e432c378414a2b 100644 (file)
@@ -16,6 +16,7 @@ module of-switch-config-pusher {
     identity of-switch-config-pusher {
         base "config:module-type";
         config:java-name-prefix DefaultConfigPusher;
+        status deprecated;
     }
 
     augment "/config:modules/config:module/config:configuration" {