Package dev.relism.flash.extension
Annotation Interface Inject
A service this handler needs, filled in once when the handler is bound.
public final class ListUsers extends RequestHandler {
@Inject private UserService users;
@Override public Object handle(Request req, Response res) { return users.findAll(); }
}
This is how a handler takes a service. onInit stays for what has to be computed at
boot, or for a service that may not be there (find).
What it does, exactly
- Filled inside
bind, beforeonInit, once per handler instance when the route is registered. Never per request: the request path reads a field. - Every annotated field of the handler and of its bases up to
RequestHandleris filled,privateincluded. - The service is looked up by the field's declared type, exactly — not a supertype, not a generic parameter. A type nothing provides fails the boot, naming the field.
- A
staticfield is refused: it would be shared by every handler. Afinalone is refused too: it is written after construction, and a reader may have folded it.