Interface ResourceMethodResolver


public interface ResourceMethodResolver
Contract for matching incoming HTTP requests with appropriate Resource Methods (Java methods to invoke to handle requests).

A Resource Method is a Java Method with an HTTP method annotation applied, e.g. GET, POST, ServerSentEventSource, ...

Standard threadsafe implementations can be acquired via these factory methods:

It is likely that one or more of the above implementations is sufficient for your application and test suite.

However, should a custom implementation be necessary, documentation is available at https://www.soklet.com/docs/request-handling#resource-method-resolution.

Author:
Mark Allen
  • Method Details

    • resourceMethodForRequest

      Given an HTTP request, provide a matching Resource Method to invoke.

      An unmatched Resource Method generally indicates an HTTP 404.

      Parameters:
      request - the HTTP request
      serverType - the type of server that's handling the request
      Returns:
      the matching Resource Method, or Optional.empty() if no match was found
    • getResourceMethods

      Vends the set of all Resource Methods registered in the system.
      Returns:
      the set of all Resource Methods in the system
    • fromClasspathIntrospection

      Acquires a threadsafe ResourceMethodResolver implementation which locates Resource Methods by examining a lookup table of Java Method declarations that are annotated with GET, POST, ServerSentEventSource, etc.

      This implementation requires that your application be compiled with the SokletProcessor annotation processor, as shown below:

      javac -parameters -processor com.soklet.SokletProcessor ...[rest of javac command elided]

      The returned instance is guaranteed to be a JVM-wide singleton.

      Returns:
      a ResourceMethodResolver which performs classpath introspection against the annotation processor's lookup table
    • withClasses

      Acquires a threadsafe ResourceMethodResolver implementation which locates Resource Methods by examining the provided classes.

      This method is guaranteed to return a new instance.

      Parameters:
      classes - the classes to inspect for Resource Methods
      Returns:
      a ResourceMethodResolver backed by the given classes
    • withMethods

      Acquires a threadsafe ResourceMethodResolver implementation which locates Resource Methods by examining the provided methods.

      This method is guaranteed to return a new instance.

      Parameters:
      methods - the methods to inspect for Resource Method annotations
      Returns:
      a ResourceMethodResolver backed by the given methods