aclservice-impl use infrautils AbstractLifecycle 24/45424/2
authorMichael Vorburger <vorburger@redhat.com>
Tue, 6 Sep 2016 15:43:50 +0000 (17:43 +0200)
committerSam Hague <shague@redhat.com>
Mon, 19 Sep 2016 23:09:44 +0000 (23:09 +0000)
and do NOT use (repeat) @PostConstruct and @PreDestroy - they are on
AbstractLifecycle, which does correct exception handling etc.

Based on https://git.opendaylight.org/gerrit/#/c/44554/ &
https://git.opendaylight.org/gerrit/#/c/45248/ (follow-up); on which
this is dependent.

Also includes fixed up features.xml in line with above.

I've manually tested this in Karaf and made sure BP (diag) is OK.

Change-Id: I4fbc088fee359b74d9d47b89bb441cdeaecc2f84
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
(cherry picked from commit 4c93877c4e34a10a969c224d46e93f5fe1ae5b22)

vpnservice/aclservice/impl/pom.xml
vpnservice/aclservice/impl/src/main/java/org/opendaylight/netvirt/aclservice/AclServiceImplFactory.java
vpnservice/features/src/main/features/features.xml

index ce4cf8aae6089e345f4188efe246751e48fc4df8..78b2502d2c09144315a5061b80d2aee30202e337 100644 (file)
@@ -71,13 +71,9 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <version>${vpnservices.version}</version>
     </dependency>
     <dependency>
-      <!-- TODO Remove when https://git.opendaylight.org/gerrit/#/c/44502/ is merged -->
-      <groupId>javax.inject</groupId>
-      <artifactId>javax.inject</artifactId>
-      <version>1</version>
-      <!-- <scope>provided is wrong here, and causes "Missing Constraint: Import-Package: javax.inject",
-           because javax.inject.Inject & Co. are @Retention(RUNTIME).  As bnd generates a MANIFEST.MF with import-package,
-           you must have <bundle>wrap:mvn:javax.inject/javax.inject/{{VERSION}} in respective features.xml -->
+      <groupId>org.opendaylight.infrautils</groupId>
+      <artifactId>inject</artifactId>
+      <version>${infrautils.version}</version>
     </dependency>
   </dependencies>
 
index f866c42df4793c7babd8e437a85ba18a651b86e8..b0bed8d9ed6d77b9b72168a126613680724ea174 100644 (file)
@@ -7,12 +7,11 @@
  */
 package org.opendaylight.netvirt.aclservice;
 
-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.genius.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.infrautils.inject.AbstractLifecycle;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.config.rev160806.AclserviceConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.config.rev160806.AclserviceConfig.SecurityGroupMode;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -20,7 +19,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Singleton
-public class AclServiceImplFactory implements AutoCloseable {
+public class AclServiceImplFactory extends AbstractLifecycle {
 
     private static final Logger LOG = LoggerFactory.getLogger(AclServiceImplFactory.class);
     //private static final String SECURITY_GROUP_MODE = "security-group-mode";
@@ -44,14 +43,13 @@ public class AclServiceImplFactory implements AutoCloseable {
                 .create(AclserviceConfig.class);
     }
 
-    @PostConstruct
-    public void start() {
+    @Override
+    protected void start() {
         LOG.info("{} start", getClass().getSimpleName());
     }
 
-    @PreDestroy
     @Override
-    public void close() throws Exception {
+    protected void stop() {
         LOG.info("{} close", getClass().getSimpleName());
     }
 
@@ -80,4 +78,5 @@ public class AclServiceImplFactory implements AutoCloseable {
             return new LearnEgressAclServiceImpl(dataBroker, mdsalManager);
         }
     }
+
 }
index d20f04c2fa4869a3fe74fab7735f1aaca8b887c4..959f58a64d32cefb1ca4686f11b980e9de3bc167 100644 (file)
@@ -54,7 +54,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <feature version="${openflowplugin.version}">odl-openflowplugin-southbound</feature>
     <feature version="${openflowplugin.version}">odl-openflowplugin-flow-services</feature>
     <feature version='${genius.version}'>odl-genius</feature>
-    <bundle>wrap:mvn:javax.inject/javax.inject/{{VERSION}}</bundle>
+    <feature version='${infrautils.version}'>odl-infrautils-inject</feature>
     <bundle>mvn:commons-net/commons-net/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.netvirt/bgpmanager-api/{{VERSION}}</bundle>
     <bundle>mvn:org.opendaylight.netvirt/bgpmanager-impl/{{VERSION}}</bundle>