summaryrefslogtreecommitdiffstats
path: root/ioam
diff options
context:
space:
mode:
Diffstat (limited to 'ioam')
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java13
-rw-r--r--ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java20
-rwxr-xr-xioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java20
3 files changed, 21 insertions, 32 deletions
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java
index 0ffc8dd94..a90bafee2 100644
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamExportProvider.java
@@ -18,6 +18,7 @@ package io.fd.hc2vpp.vppioam.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.ioamexport.JVppIoamexportImpl;
import io.fd.vpp.jvpp.ioamexport.future.FutureJVppIoamexportFacade;
@@ -32,19 +33,15 @@ public class JVppIoamExportProvider extends ProviderTrait<FutureJVppIoamexportFa
@Inject
private JVppRegistry registry;
+ @Inject
+ private ShutdownHandler shutdownHandler;
+
@Override
protected FutureJVppIoamexportFacade create() {
try {
final JVppIoamexportImpl jVppIoamexport = new JVppIoamexportImpl();
// Free jvpp-ioam-export plugin's resources on shutdown
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- LOG.info("Unloading jvpp-ioam-export plugin");
- jVppIoamexport.close();
- LOG.info("Successfully unloaded jvpp-ioam-export plugin");
- }
- });
+ shutdownHandler.register("jvpp-ioamexport", jVppIoamexport);
LOG.info("Successfully loaded jvpp-ioam-export plugin");
return new FutureJVppIoamexportFacade(registry, jVppIoamexport);
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java
index a8ae2dc70..03db9f01a 100644
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamPotProvider.java
@@ -18,17 +18,17 @@ package io.fd.hc2vpp.vppioam.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.ioampot.JVppIoampotImpl;
import io.fd.vpp.jvpp.ioampot.future.FutureJVppIoampotFacade;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
/**
- * Provides future API for jvpp-ioam 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-ioam plugin. Must be a singleton due to shutdown hook usage. Registers shutdown hook to
+ * free plugin's resources on shutdown.
*/
public final class JVppIoamPotProvider extends ProviderTrait<FutureJVppIoampotFacade> {
@@ -37,19 +37,15 @@ public final class JVppIoamPotProvider extends ProviderTrait<FutureJVppIoampotFa
@Inject
private JVppRegistry registry;
+ @Inject
+ private ShutdownHandler shutdownHandler;
+
@Override
protected FutureJVppIoampotFacade create() {
try {
final JVppIoampotImpl jVppIoamPot = new JVppIoampotImpl();
// Free jvpp-ioam plugin's resources on shutdown
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- LOG.info("Unloading jvpp-ioam-pot plugin");
- jVppIoamPot.close();
- LOG.info("Successfully unloaded jvpp-ioam-pot plugin");
- }
- });
+ shutdownHandler.register("jvpp-ioampot", jVppIoamPot);
LOG.info("Successfully loaded jvpp-ioam-pot plugin");
return new FutureJVppIoampotFacade(registry, jVppIoamPot);
diff --git a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java
index caf098e2d..f7e15fb68 100755
--- a/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java
+++ b/ioam/impl/src/main/java/io/fd/hc2vpp/vppioam/impl/util/JVppIoamTraceProvider.java
@@ -18,17 +18,17 @@ package io.fd.hc2vpp.vppioam.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.ioamtrace.JVppIoamtraceImpl;
import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
+import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
/**
- * Provides future API for jvpp-ioam 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-ioam plugin. Must be a singleton due to shutdown hook usage. Registers shutdown hook to
+ * free plugin's resources on shutdown.
*/
public final class JVppIoamTraceProvider extends ProviderTrait<FutureJVppIoamtraceFacade> {
@@ -37,19 +37,15 @@ public final class JVppIoamTraceProvider extends ProviderTrait<FutureJVppIoamtra
@Inject
private JVppRegistry registry;
+ @Inject
+ private ShutdownHandler shutdownHandler;
+
@Override
protected FutureJVppIoamtraceFacade create() {
try {
final JVppIoamtraceImpl jVppIoamTr = new JVppIoamtraceImpl();
// Free jvpp-ioam plugin's resources on shutdown
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- LOG.info("Unloading jvpp-ioam-trace plugin");
- jVppIoamTr.close();
- LOG.info("Successfully unloaded jvpp-ioam-trace plugin");
- }
- });
+ shutdownHandler.register("jvpp-ioamtrace", jVppIoamTr);
LOG.info("Successfully loaded jvpp-ioam-trace plugin");
return new FutureJVppIoamtraceFacade(registry, jVppIoamTr);