summaryrefslogtreecommitdiffstats
path: root/nsh/impl/src
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-08-11 14:05:30 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-08-14 08:20:18 +0000
commit2a39a0f17d82ecf7c75840d53960c42c6ea2c6ac (patch)
treebe89dcd0d219dc2ff9c928c77a4fc218458e071f /nsh/impl/src
parent72493bf45a8823dbb2bc8e0745ebb7106a7ae01f (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 'nsh/impl/src')
-rwxr-xr-xnsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/util/JVppNshProvider.java17
1 files changed, 7 insertions, 10 deletions
diff --git a/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/util/JVppNshProvider.java b/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/util/JVppNshProvider.java
index c520b2d97..8f25a44e9 100755
--- a/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/util/JVppNshProvider.java
+++ b/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/util/JVppNshProvider.java
@@ -18,6 +18,7 @@ package io.fd.hc2vpp.vppnsh.impl.util;
import com.google.inject.Inject;
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.nsh.JVppNshImpl;
import io.fd.vpp.jvpp.nsh.future.FutureJVppNshFacade;
@@ -26,8 +27,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Provides future API for jvpp-nsh plugin. Must be a singleton due to shutdown hook usage.
- * Registers shutdown hook to free plugin's resources on shutdown.
+ * Provides future API for jvpp-nsh plugin. Must be a singleton due to shutdown hook usage. Registers shutdown hook to
+ * free plugin's resources on shutdown.
*/
public final class JVppNshProvider extends ProviderTrait<FutureJVppNshFacade> {
@@ -36,19 +37,15 @@ public final class JVppNshProvider extends ProviderTrait<FutureJVppNshFacade> {
@Inject
private JVppRegistry registry;
+ @Inject
+ private ShutdownHandler shutdownHandler;
+
@Override
protected FutureJVppNshFacade create() {
try {
final JVppNshImpl jVppNsh = new JVppNshImpl();
// Free jvpp-nsh plugin's resources on shutdown
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- LOG.info("Unloading jvpp-nsh plugin");
- jVppNsh.close();
- LOG.info("Successfully unloaded jvpp-nsh plugin");
- }
- });
+ shutdownHandler.register("jvpp-nsh", jVppNsh);
LOG.info("Successfully loaded jvpp-nsh plugin");
return new FutureJVppNshFacade(registry, jVppNsh);