use maven-blueprint-plugin 31/55031/2
authorIsaku Yamahata <isaku.yamahata@intel.com>
Thu, 13 Apr 2017 21:37:06 +0000 (14:37 -0700)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Fri, 23 Jun 2017 09:38:06 +0000 (02:38 -0700)
TODO: figure out how to convert NeutronHostconfigVppListener

Change-Id: Id3361cc5a1c4847484c1dfa6db3ca2ea7b87b5cb
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
neutron-hostconfig/ovs/pom.xml
neutron-hostconfig/ovs/src/main/java/org/opendaylight/neutron/hostconfig/ovs/NeutronHostconfigOvsListener.java
neutron-hostconfig/ovs/src/main/resources/org/opendaylight/blueprint/neutron-hostconfig-ovs.xml
neutron-logger/pom.xml
neutron-logger/src/main/java/org/opendaylight/neutron/logger/NeutronLogger.java
neutron-logger/src/main/resources/org/opendaylight/blueprint/neutron-logger.xml
transcriber/pom.xml
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronTranscriberProvider.java
transcriber/src/main/resources/org/opendaylight/blueprint/transcriber.xml

index f7d61bc3034ce670e62e8ac0e4f1046fff2edf85..6a9889ea9f556121524d13952db72ff80131d397 100644 (file)
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>config-api</artifactId>
           </compilerArgs>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.aries.blueprint</groupId>
+        <artifactId>blueprint-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
   <scm>
index f3cbf1b197517ff7d8856edc20884d35f6665b33..9135b477f7ad7f5439fa744829bf215ae29281ad 100644 (file)
@@ -14,6 +14,10 @@ import com.google.common.collect.Maps;
 import java.util.Collection;
 import java.util.Map;
 import javax.annotation.Nonnull;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 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;
@@ -36,7 +40,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NeutronHostconfigOvsListener implements ClusteredDataTreeChangeListener<Node>, AutoCloseable {
+@Singleton
+public class NeutronHostconfigOvsListener implements ClusteredDataTreeChangeListener<Node> {
     private static final Logger LOG = LoggerFactory.getLogger(NeutronHostconfigOvsListener.class);
     private final DataBroker dataBroker;
     private final SouthboundUtils southboundUtils;
@@ -46,6 +51,7 @@ public class NeutronHostconfigOvsListener implements ClusteredDataTreeChangeList
     private static final String OS_HOST_CONFIG_CONFIG_KEY_PREFIX = "odl_os_hostconfig_config_odl_";
     private static int HOST_TYPE_STR_LEN = 8;
 
+    @Inject
     public NeutronHostconfigOvsListener(final DataBroker dataBroker) {
         this.dataBroker = dataBroker;
         MdsalUtils mdsalUtils = new MdsalUtils(dataBroker);
@@ -91,6 +97,7 @@ public class NeutronHostconfigOvsListener implements ClusteredDataTreeChangeList
                 .child(Node.class);
     }
 
+    @PostConstruct
     public void init() {
         LOG.info("{} start", getClass().getSimpleName());
         DataTreeIdentifier<Node> dataTreeIdentifier =
@@ -99,6 +106,7 @@ public class NeutronHostconfigOvsListener implements ClusteredDataTreeChangeList
         listenerRegistration = dataBroker.registerDataTreeChangeListener(dataTreeIdentifier, this);
     }
 
+    @PreDestroy
     public void close() throws Exception {
         if (listenerRegistration != null) {
             listenerRegistration.close();
index 71f4febf03f4a0e89593d374871d3543b63fee04..aa1e55610dd8c6d871007d85d0b1a48b9dc3aae7 100644 (file)
@@ -7,11 +7,4 @@
       interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
       odl:type="default" />
 
-  <bean id="neutronHostconfigOvs"
-     class="org.opendaylight.neutron.hostconfig.ovs.NeutronHostconfigOvsListener"
-     init-method="init"
-     destroy-method="close">
-    <argument ref="dataBroker"/>
-  </bean>
-
 </blueprint>
index f5e1fe72c597e4e09bf0fb6d420c80f4ccd3e07e..a2ea186f42f58ed11b82de193d4c3a3bd5718f87 100644 (file)
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>config-api</artifactId>
           </compilerArgs>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.aries.blueprint</groupId>
+        <artifactId>blueprint-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
   <scm>
index 46bf1714a5855284015ce10b12014877c86638bd..1ef6513b5b37bab6a41e8bdec71f5f45b941e0f5 100644 (file)
@@ -12,6 +12,10 @@ import com.google.common.base.Preconditions;
 
 import java.util.Collection;
 import javax.annotation.Nonnull;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 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;
@@ -25,7 +29,8 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class NeutronLogger implements AutoCloseable {
+@Singleton
+public final class NeutronLogger {
     private static final Logger LOG = LoggerFactory.getLogger(NeutronLogger.class);
 
     private DataBroker db;
@@ -34,6 +39,7 @@ public final class NeutronLogger implements AutoCloseable {
     private ClusteredDataTreeChangeListener<Neutron> operationalDataTreeChangeListener;
     private ListenerRegistration<? extends ClusteredDataTreeChangeListener<Neutron>> operationalRegisteredListener;
 
+    @Inject
     public NeutronLogger(@Nonnull DataBroker db) {
         LOG.info("Creating NeutronLogger {}", db);
         this.db = Preconditions.checkNotNull(db, "null db");
@@ -91,6 +97,7 @@ public final class NeutronLogger implements AutoCloseable {
         LOG.info(messageBuilder.toString());
     }
 
+    @PostConstruct
     public void init() {
         LOG.info("Register listener for Neutron model data changes");
         InstanceIdentifier<Neutron> instanceId = Preconditions.checkNotNull(InstanceIdentifier.create(Neutron.class));
@@ -118,7 +125,7 @@ public final class NeutronLogger implements AutoCloseable {
                 operationalDataTreeChangeListener);
     }
 
-    @Override
+    @PreDestroy
     public void close() throws Exception {
         configurationRegisteredListener.close();
         configurationRegisteredListener = null;
index a2dc1bad4939cef2d7a54efa0eab24287f4b53aa..aa1e55610dd8c6d871007d85d0b1a48b9dc3aae7 100644 (file)
@@ -7,11 +7,4 @@
       interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
       odl:type="default" />
 
-  <bean id="neutronLogger"
-     class="org.opendaylight.neutron.logger.NeutronLogger"
-     init-method="init"
-     destroy-method="close">
-    <argument ref="dataBroker"/>
-  </bean>
-
 </blueprint>
index b92a7561a8d9f4a4543037452cea8344753fbc6e..095112073e3a10d54211c4bd6110077918f6f69f 100644 (file)
           </compilerArgs>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.aries.blueprint</groupId>
+        <artifactId>blueprint-maven-plugin</artifactId>
+      </plugin>
     </plugins>
   </build>
   <dependencies>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>
     </dependency>
+    <dependency>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+    </dependency>
   </dependencies>
   <scm>
     <connection>scm:git:ssh://git.opendaylight.org:29418/neutron.git</connection>
index 7c1bd5920c422fba66a2f64577b087cdf6a787e9..28fcabafe9cb622a6c91ea14f70be1053b4767bd 100644 (file)
@@ -11,6 +11,10 @@ package org.opendaylight.neutron.transcriber;
 import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.neutron.spi.INeutronBgpvpnCRUD;
 import org.opendaylight.neutron.spi.INeutronCRUD;
@@ -47,7 +51,8 @@ import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class NeutronTranscriberProvider implements AutoCloseable, NeutronTranscriber {
+@Singleton
+public final class NeutronTranscriberProvider implements NeutronTranscriber {
     private static final Logger LOG = LoggerFactory.getLogger(NeutronTranscriberProvider.class);
 
     private BundleContext context;
@@ -55,6 +60,7 @@ public final class NeutronTranscriberProvider implements AutoCloseable, NeutronT
     private final List<ServiceRegistration<? extends INeutronCRUD<?>>> registrations = new ArrayList<>();
     private final List<AutoCloseable> neutronInterfaces = new ArrayList<>();
 
+    @Inject
     public NeutronTranscriberProvider(BundleContext context, DataBroker db) {
         LOG.debug("DataBroker set to: {}", db);
         this.context = Preconditions.checkNotNull(context);
@@ -71,6 +77,7 @@ public final class NeutronTranscriberProvider implements AutoCloseable, NeutronT
         registrations.add(crudInterfaceRegistration);
     }
 
+    @PostConstruct
     public void init() {
         registerCRUDInterface(INeutronBgpvpnCRUD.class, new NeutronBgpvpnInterface(db));
         registerCRUDInterface(INeutronFirewallCRUD.class, new NeutronFirewallInterface(db));
@@ -108,7 +115,7 @@ public final class NeutronTranscriberProvider implements AutoCloseable, NeutronT
         this.context = null;
     }
 
-    @Override
+    @PreDestroy
     public void close() throws Exception {
         for (final ServiceRegistration registration : registrations) {
             registration.unregister();
index 15fea5603b084c246496a7f34766e920d16bae3f..644966cb282c2ebbcdfe3c35362418a6ddabc672 100644 (file)
@@ -7,15 +7,7 @@
       interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
       odl:type="default" />
 
-  <bean id="neutronTranscriberImpl"
-     class="org.opendaylight.neutron.transcriber.NeutronTranscriberProvider"
-     init-method="init"
-     destroy-method="close">
-    <argument ref="blueprintBundleContext"/>
-    <argument ref="dataBroker"/>
-  </bean>
-
-  <service ref="neutronTranscriberImpl"
+  <service ref="neutronTranscriberProvider"
     interface="org.opendaylight.neutron.transcriber.NeutronTranscriber"
     odl:type="default"/>