Interface SafeCallerBuilder<T>

  • Type Parameters:
    T -

    @NonNullByDefault
    public interface SafeCallerBuilder<T>
    Builder to create a safe-call wrapper for another object.
    Author:
    Simon Kaufmann - Initial contribution
    • Method Detail

      • build

        T build()
        Creates a dynamic proxy with the according properties which guards the caller from hanging implementations in the target object.
        Returns:
        the dynamic proxy wrapping the target object
      • withTimeout

        SafeCallerBuilder<T> withTimeout​(long timeout)
        Sets the timeout
        Parameters:
        timeout - the timeout in milliseconds.
        Returns:
        the SafeCallerBuilder itself
      • withIdentifier

        SafeCallerBuilder<T> withIdentifier​(Object identifier)
        Specifies the identifier for the context in which only one thread may be occupied at the same time.
        Parameters:
        identifier - the identifier much must have a proper hashcode()/equals() implementation in order to distinguish different contexts.
        Returns:
        the SafeCallerBuilder itself
      • onException

        SafeCallerBuilder<T> onException​(Consumer<Throwable> exceptionHandler)
        Specifies a callback in case of execution errors.
        Parameters:
        exceptionHandler -
        Returns:
        the SafeCallerBuilder itself
      • onTimeout

        SafeCallerBuilder<T> onTimeout​(Runnable timeoutHandler)
        Specifies a callback in case of timeouts.
        Parameters:
        timeoutHandler -
        Returns:
        the SafeCallerBuilder itself
      • withAsync

        SafeCallerBuilder<T> withAsync()
        Denotes that the calls should be executed asynchronously, i.e. that they should return immediately and not even block until they reached the timeout.

        By default, calls will be executed synchronously (i.e. blocking) until the timeout is reached.

        Returns:
        the SafeCallerBuilder itself