Class MethodHttpHandlerInvoker

java.lang.Object
eu.cloudnetservice.driver.network.http.HttpHandler
eu.cloudnetservice.driver.network.http.annotation.parser.MethodHttpHandlerInvoker

final class MethodHttpHandlerInvoker extends HttpHandler
A http handler which delegates its calls to a method invocation, resolving the parameters for that from the preprocessed http context.
Since:
4.0
  • Field Details

    • instance

      private final Object instance
    • handlerMethod

      private final MethodHandle handlerMethod
    • handlerParameterTypes

      private final Class<?>[] handlerParameterTypes
    • supportedMethods

      private final Collection<String> supportedMethods
  • Constructor Details

  • Method Details

    • genericHandleForMethod

      @NonNull private static @NonNull MethodHandle genericHandleForMethod(@NonNull @NonNull Method method) throws IllegalAccessException
      Converts the given method into a generic method handle which can be used to invoke the method without the exact arguments or return type known to the caller.
      Parameters:
      method - the method to convert.
      Returns:
      a method generic method handle for the given method.
      Throws:
      IllegalAccessException - if method access checking fails.
    • handle

      public void handle(@NonNull @NonNull String path, @NonNull @NonNull HttpContext context) throws Throwable
      Handles a http request whose path (and other supplied attributes) while registering is matching the requested path of the client. A request is only processed by one handler at a time, giving the handler full control about changing the context. Changes to the context will be reflected into other handlers and vise-versa.
      Specified by:
      handle in class HttpHandler
      Parameters:
      path - the full path of the client request.
      context - the current context of the request.
      Throws:
      Throwable - if any exception occurs during the request handling.
      NullPointerException - if the given path or context is null.
    • buildInvocationArguments

      @NonNull private @NonNull Object[] buildInvocationArguments(@NonNull @NonNull String path, @NonNull @NonNull HttpContext context)
      Constructs the arguments array which will be passed to the method which is actually handling the associated request.
      Parameters:
      path - the full path of the client request.
      context - the current context of the request.
      Throws:
      NullPointerException - if the given path or context is null.
      AnnotationHttpHandleException - if any exception occurs while resolving the arguments.