diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2017-08-11 14:05:30 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2017-08-14 08:20:18 +0000 |
commit | 2a39a0f17d82ecf7c75840d53960c42c6ea2c6ac (patch) | |
tree | be89dcd0d219dc2ff9c928c77a4fc218458e071f /acl | |
parent | 72493bf45a8823dbb2bc8e0745ebb7106a7ae01f (diff) |
HONEYCOMB-381 - Usage of ShutdownHandler for jvpp components
and notification producer
Change-Id: I70e749de5b290c84e86a28625d5ec79c98de80f2
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'acl')
-rw-r--r-- | acl/acl-impl/pom.xml | 6 | ||||
-rw-r--r-- | acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/JVppAclProvider.java | 17 |
2 files changed, 13 insertions, 10 deletions
diff --git a/acl/acl-impl/pom.xml b/acl/acl-impl/pom.xml index e7fad9e0a..638ea54c2 100644 --- a/acl/acl-impl/pom.xml +++ b/acl/acl-impl/pom.xml @@ -35,6 +35,12 @@ <dependencies> <dependency> + <groupId>io.fd.honeycomb</groupId> + <artifactId>cfg-init</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> <groupId>io.fd.hc2vpp.acl</groupId> <artifactId>acl-api</artifactId> <version>${project.version}</version> diff --git a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/JVppAclProvider.java b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/JVppAclProvider.java index be8c48894..96e26a4e3 100644 --- a/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/JVppAclProvider.java +++ b/acl/acl-impl/src/main/java/io/fd/hc2vpp/acl/JVppAclProvider.java @@ -19,6 +19,7 @@ package io.fd.hc2vpp.acl; import com.google.inject.Inject; import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer; import io.fd.honeycomb.binding.init.ProviderTrait; +import io.fd.honeycomb.data.init.ShutdownHandler; import io.fd.vpp.jvpp.JVppRegistry; import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.acl.JVppAclImpl; @@ -37,24 +38,20 @@ class JVppAclProvider extends ProviderTrait<FutureJVppAclFacade> implements Jvpp @Inject private JVppRegistry registry; - private static JVppAclImpl initAclApi() { + @Inject + private ShutdownHandler shutdownHandler; + + private static JVppAclImpl initAclApi(final ShutdownHandler shutdownHandler) { final JVppAclImpl jvppAcl = new JVppAclImpl(); // Free jvpp-acl plugin's resources on shutdown - Runtime.getRuntime().addShutdownHook(new Thread() { - @Override - public void run() { - LOG.info("Unloading jvpp-acl plugin"); - jvppAcl.close(); - LOG.info("Successfully unloaded jvpp-acl plugin"); - } - }); + shutdownHandler.register("jvpp-acl", jvppAcl); return jvppAcl; } @Override protected FutureJVppAclFacade create() { try { - return reportVersionAndGet(initAclApi()); + return reportVersionAndGet(initAclApi(shutdownHandler)); } catch (IOException e) { throw new IllegalStateException("Unable to open VPP management connection", e); } catch (TimeoutException | VppBaseCallException e) { |