diff --git a/src/main/java/io/scalecube/runners/Runners.java b/src/main/java/io/scalecube/runners/Runners.java deleted file mode 100644 index 7a47054..0000000 --- a/src/main/java/io/scalecube/runners/Runners.java +++ /dev/null @@ -1,32 +0,0 @@ -package io.scalecube.runners; - -import sun.misc.Signal; -import sun.misc.SignalHandler; - -public final class Runners { - - private Runners() { - // Do not instantiate - } - - /** - * Listens to jvm signas SIGTERM and SIGINT and applies shutdown lambda function. - * - * @param runnable shutdown task - */ - public static void onShutdown(Runnable runnable) { - SignalHandler handler = signal -> runnable.run(); - Signal.handle(new Signal("INT"), handler); - Signal.handle(new Signal("TERM"), handler); - } - - /** - * Utility method to simply check if current thread is interrupted. If it is, then {@code - * IllegalStateException} is being thrown. - */ - public static void checkInterrupted() { - if (Thread.currentThread().isInterrupted()) { - throw new IllegalStateException("Unexpected interrupt"); - } - } -} diff --git a/src/main/java/io/scalecube/utils/ServiceLoaderUtil.java b/src/main/java/io/scalecube/utils/ServiceLoaderUtil.java deleted file mode 100644 index 22dbd08..0000000 --- a/src/main/java/io/scalecube/utils/ServiceLoaderUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -package io.scalecube.utils; - -import java.util.Optional; -import java.util.ServiceLoader; -import java.util.function.Predicate; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; - -public final class ServiceLoaderUtil { - - private ServiceLoaderUtil() { - // Do not instantiate - } - - /** - * Finds the first implementation of the given service type and creates its instance. - * - * @param clazz service type - * @return the first implementation of the given service type - */ - public static Optional findFirst(Class clazz) { - ServiceLoader load = ServiceLoader.load(clazz); - return StreamSupport.stream(load.spliterator(), false).findFirst(); - } - - /** - * Finds the first implementation of the given service type using the given predicate to filter - * out found service types and creates its instance. - * - * @param clazz service type - * @param predicate service type predicate - * @return the first implementation of the given service type - */ - public static Optional findFirst(Class clazz, Predicate predicate) { - ServiceLoader load = ServiceLoader.load(clazz); - Stream stream = StreamSupport.stream(load.spliterator(), false); - return stream.filter(predicate).findFirst(); - } - - /** - * Finds all implementations of the given service type and creates their instances. - * - * @param clazz service type - * @return implementations' stream of the given service type - */ - public static Stream findAll(Class clazz) { - ServiceLoader load = ServiceLoader.load(clazz); - return StreamSupport.stream(load.spliterator(), false); - } - - /** - * Finds all implementations of the given service type using the given predicate to filter out - * found service types and creates their instances. - * - * @param clazz service type - * @param predicate service type predicate - * @return implementations' stream of the given service type - */ - public static Stream findAll(Class clazz, Predicate predicate) { - ServiceLoader load = ServiceLoader.load(clazz); - return StreamSupport.stream(load.spliterator(), false).filter(predicate); - } -}