Package google.registry.request
Class RequestHandler<C>
java.lang.Object
google.registry.request.RequestHandler<C>
- Type Parameters:
C
- request component type
- Direct Known Subclasses:
BackendRequestHandler
,BsaRequestHandler
,FrontendRequestHandler
,PubApiRequestHandler
,ToolsRequestHandler
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:
@Component interface ServerComponent { HelloAction helloAction(); }
The rules for component methods are as follows:
- Methods whose raw return type does not implement
Runnable
will be ignored - Methods whose raw return type does not have an
@Action
annotation are ignored
Security Features
-
Constructor Summary
ModifierConstructorDescriptionprotected
RequestHandler
(javax.inject.Provider<? extends RequestComponentBuilder<C>> requestComponentBuilderProvider, RequestAuthenticator requestAuthenticator) Constructor for subclasses to create a new request handler for a specific request component. -
Method Summary
Modifier and TypeMethodDescriptionstatic <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.void
handleRequest
(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse rsp) Runs the appropriate action for a servlet request.
-
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 singleRequestHandler
and re-use it across requests.- Parameters:
requestComponentBuilderProvider
- a DaggerProvider
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 theRequestAuthenticator
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.- Throws:
IOException
-