Class RequestHandler<C>

Type Parameters:
C - request component type
Direct Known Subclasses:
BackendRequestHandler, BsaRequestHandler, FrontendRequestHandler, PubApiRequestHandler, ToolsRequestHandler

public class RequestHandler<C> extends Object
Dagger-based request processor.

This class creates an HTTP request processor from a Dagger component. It routes requests from your servlet to an @Action annotated handler class.

Component Definition

Action instances are supplied on a per-request basis by invoking the methods on C. For example:

 interface ServerComponent {
   HelloAction helloAction();

The rules for component methods are as follows:

  1. Methods whose raw return type does not implement Runnable will be ignored
  2. Methods whose raw return type does not have an @Action annotation are ignored

Security Features

  • Constructor Details

    • RequestHandler

      protected RequestHandler(javax.inject.Provider<? extends RequestComponentBuilder<C>> requestComponentBuilderProvider, RequestAuthenticator requestAuthenticator)
      Constructor for subclasses to create a new request handler for a specific request component.

      This operation will generate a routing map for the component's @Action-returning methods using reflection, which is moderately expensive, so a given servlet should construct a single RequestHandler and re-use it across requests.

      requestComponentBuilderProvider - a Dagger Provider of builder instances that can be used to construct new instances of the request component (with the required request-derived modules provided by this class)
      requestAuthenticator - an instance of the RequestAuthenticator class
  • Method Details

    • create

      public static <C> RequestHandler<C> create(Class<C> component, javax.inject.Provider<? extends RequestComponentBuilder<C>> requestComponentBuilderProvider, RequestAuthenticator requestAuthenticator)
      Creates a new RequestHandler with an explicit component class for test purposes.
    • handleRequest

      public void handleRequest(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp) throws IOException
      Runs the appropriate action for a servlet request.