Add blueprint wiring for the lldp-speaker app 36/38836/4
authorTom Pantelis <tpanteli@brocade.com>
Wed, 11 May 2016 01:06:50 +0000 (21:06 -0400)
committerAnil Vishnoi <vishnoianil@gmail.com>
Fri, 3 Jun 2016 08:11:02 +0000 (08:11 +0000)
Change-Id: Iab911edca42540835c668cf20d7b00dd673e9428
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
applications/lldp-speaker/src/main/java/org/opendaylight/openflowplugin/applications/lldpspeaker/LLDPSpeaker.java
applications/lldp-speaker/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/lldp/speaker/rev141023/LLDPSpeakerModule.java
applications/lldp-speaker/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/openflow/applications/lldp/speaker/rev141023/LLDPSpeakerModuleFactory.java
applications/lldp-speaker/src/main/resources/initial/71-lldp-speaker.xml
applications/lldp-speaker/src/main/resources/org/opendaylight/blueprint/lldp-speaker.xml [new file with mode: 0644]
applications/lldp-speaker/src/main/yang/lldp-speaker-config.yang [new file with mode: 0644]
applications/lldp-speaker/src/main/yang/lldp-speaker.yang

index a45c69544b92d866d85c5ee7dd525306e5017087..6351d546befb85076142e361e1b64eaca389ec6c 100644 (file)
@@ -46,7 +46,7 @@ public class LLDPSpeaker implements AutoCloseable, NodeConnectorEventsObserver,
     private final Map<InstanceIdentifier<NodeConnector>, TransmitPacketInput> nodeConnectorMap = new ConcurrentHashMap<>();
     private final ScheduledFuture<?> scheduledSpeakerTask;
     private final MacAddress addressDestionation;
-    private OperStatus operationalStatus = OperStatus.RUN;
+    private volatile OperStatus operationalStatus = OperStatus.RUN;
 
     public LLDPSpeaker(final PacketProcessingService packetProcessingService,
             final MacAddress addressDestionation) {
index 3d2735331d2c33054ad667bf0dffb61b4d7244d5..c56d0e954a1450d482dfa5409884377534370728 100644 (file)
@@ -2,62 +2,25 @@ package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflo
 
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.openflowplugin.applications.lldpspeaker.LLDPSpeaker;
-import org.opendaylight.openflowplugin.applications.lldpspeaker.NodeConnectorInventoryEventTranslator;
-import org.opendaylight.openflowplugin.applications.lldpspeaker.OperationalStatusChangeService;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
 public class LLDPSpeakerModule extends AbstractLLDPSpeakerModule {
-    private static final Logger LOG = LoggerFactory
-            .getLogger(LLDPSpeakerModule.class);
-
-    public LLDPSpeakerModule(ModuleIdentifier identifier,
-            DependencyResolver dependencyResolver) {
+    public LLDPSpeakerModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
     public LLDPSpeakerModule(ModuleIdentifier identifier,
-            DependencyResolver dependencyResolver, LLDPSpeakerModule oldModule,
-            AutoCloseable oldInstance) {
+            DependencyResolver dependencyResolver, LLDPSpeakerModule oldModule, AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
-    @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
-    }
-
     @Override
     public AutoCloseable createInstance() {
-        LOG.trace("Creating LLDP speaker.");
-
-        PacketProcessingService packetProcessingService = getRpcRegistryDependency()
-                .getRpcService(PacketProcessingService.class);
-        MacAddress macDestination = getAddressDestination();
-
-        final LLDPSpeaker lldpSpeaker = new LLDPSpeaker(
-                packetProcessingService, macDestination);
-        final NodeConnectorInventoryEventTranslator eventTranslator = new NodeConnectorInventoryEventTranslator(
-                getDataBrokerDependency(), lldpSpeaker);
-
-        OperationalStatusChangeService operationalStatusChangeService = new OperationalStatusChangeService(
-                lldpSpeaker);
-        final BindingAwareBroker.RpcRegistration<LldpSpeakerService> statusServiceRegistration =
-                getRpcRegistryDependency().addRpcImplementation(LldpSpeakerService.class, operationalStatusChangeService);
-
-        return new AutoCloseable() {
-            @Override
-            public void close() {
-                LOG.trace("Closing LLDP speaker.");
-                eventTranslator.close();
-                lldpSpeaker.close();
-                statusServiceRegistration.close();
-            }
-        };
+        // Instances are created via blueprint so this in a no-op.
+        return NoopAutoCloseable.INSTANCE;
     }
-
 }
index a09e921c408d58e9f558e8cc8e5c65257977a2da..94d995f40f0d6d4faf5b9cdc0ce86832d0473583 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.lldp.speaker.rev141023;
-public class LLDPSpeakerModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.rev141023.AbstractLLDPSpeakerModuleFactory {
+
+/**
+ * @deprecated Replaced by blueprint wiring
+ */
+@Deprecated
+public class LLDPSpeakerModuleFactory extends AbstractLLDPSpeakerModuleFactory {
 
 }
index 11f33b1402236ad9932883804b78f4ba9fab9b38..2efa88574971836e58cdbd5b601f2f5d4a1c73eb 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/lldp-speaker/src/main/resources/org/opendaylight/blueprint/lldp-speaker.xml b/applications/lldp-speaker/src/main/resources/org/opendaylight/blueprint/lldp-speaker.xml
new file mode 100644 (file)
index 0000000..98fd805
--- /dev/null
@@ -0,0 +1,43 @@
+<?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:clustered-app-config id="lldpSpeakerConfig"
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.applications.lldp.speaker.config.rev160512.LldpSpeakerConfig">
+    <odl:default-config><![CDATA[
+      <lldp-speaker-config xmlns="urn:opendaylight:params:xml:ns:yang:openflow:applications:lldp-speaker:config">
+        <address-destination>01:23:00:00:00:01</address-destination>
+      </lldp-speaker-config>
+    ]]></odl:default-config>
+  </odl:clustered-app-config>
+
+  <odl:rpc-service id="packetProcessingService"
+      interface="org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService"/>
+
+  <bean id="lldpSpeaker" class="org.opendaylight.openflowplugin.applications.lldpspeaker.LLDPSpeaker"
+          destroy-method="close">
+    <argument ref="packetProcessingService"/>
+    <argument>
+      <bean factory-ref="lldpSpeakerConfig" factory-method="getAddressDestination"/>
+    </argument>
+  </bean>
+
+  <bean id="nodeConnectorEventTranslator" class="org.opendaylight.openflowplugin.applications.lldpspeaker.NodeConnectorInventoryEventTranslator"
+          destroy-method="close">
+    <argument ref="dataBroker"/>
+    <argument>
+      <array>
+        <ref component-id="lldpSpeaker"/>
+      </array>
+    </argument>
+  </bean>
+
+  <bean id="operationalStatusChangeService" class="org.opendaylight.openflowplugin.applications.lldpspeaker.OperationalStatusChangeService">
+    <argument ref="lldpSpeaker"/>
+  </bean>
+
+  <odl:rpc-implementation ref="operationalStatusChangeService"/>
+</blueprint>
\ No newline at end of file
diff --git a/applications/lldp-speaker/src/main/yang/lldp-speaker-config.yang b/applications/lldp-speaker/src/main/yang/lldp-speaker-config.yang
new file mode 100644 (file)
index 0000000..6d02e22
--- /dev/null
@@ -0,0 +1,22 @@
+module lldp-speaker-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:openflow:applications:lldp-speaker:config";
+    prefix "lldp-speaker-config";
+
+    import ietf-yang-types {prefix yang; revision-date "2010-09-24";}
+
+    description
+        "Configuration for LLDP speaker application.";
+
+    revision "2016-05-12" {
+        description
+            "Initial revision.";
+    }
+
+    container lldp-speaker-config {
+        leaf address-destination {
+            type yang:mac-address;
+            mandatory true;
+        }
+    }
+}
\ No newline at end of file
index 32d0d16a6b415f115ab9443d5c0e1f180558aa6e..6fe5646fb7ae532c3a0ac07b72296ce34811cdd2 100644 (file)
@@ -19,6 +19,7 @@ module lldp-speaker {
     identity lldp-speaker {
         base "config:module-type";
         config:java-name-prefix LLDPSpeaker;
+        status deprecated;
     }
 
     typedef oper-status {