Class SpiUtils


  • public final class SpiUtils
    extends Object
    Utility methods for Remoting service providers.
    • Method Detail

      • safeHandleClose

        public static <T> void safeHandleClose​(CloseHandler<? super T> handler,
                                               T closed,
                                               IOException exception)
        Safely handle a close notification.
        Type Parameters:
        T - the type of the closed resource
        Parameters:
        handler - the close handler
        closed - the object that was closed
        exception - the close exception, or null if the close succeeded
      • closingCloseHandler

        public static CloseHandler<Object> closingCloseHandler​(Closeable c)
        A close handler which closes another resource.
        Parameters:
        c - the resource to close
        Returns:
        the close handler
      • asyncClosingCloseHandler

        public static CloseHandler<Object> asyncClosingCloseHandler​(HandleableCloseable<?> c)
        A close handler which closes another resource asynchronously.
        Parameters:
        c - the resource to close
        Returns:
        the close handler
      • glueStackTraces

        public static void glueStackTraces​(Throwable exception,
                                           StackTraceElement[] userStackTrace,
                                           int trimCount,
                                           String msg)
        Glue two stack traces together.
        Parameters:
        exception - the exception which occurred in another thread
        userStackTrace - the stack trace of the current thread from Thread.getStackTrace()
        trimCount - the number of frames to trim
        msg - the message to use
      • getServiceOpenTask

        public static Runnable getServiceOpenTask​(Channel newChannel,
                                                  OpenListener listener)
        Get an executor task for opening a service.
        Parameters:
        newChannel - the new service channel
        listener - the service open listener
        Returns:
        the runnable task