The router

JAX-RS is command-oriented. It means that a request must be bound to a Java method. To do so, the matching takes multiple parameters of the request into account:

  • The patch
  • The Accept header
  • The Content-Type header

Here is the simplified algorithm for routing:

  1. Find the class matching the request based on the path (this is a regex-like logic).
  2. From the class found in step 1, find the method matching the request based on the path. (This is close to step 1 but applied to methods with subresource handling.)
  3. From the methods found in step 2, find the one that will handle the request based on mime types (Accept/Content-Type headers). This level parses the media types to handle the quality of service options (q, qs, and so on) of the ...

Get Java EE 8 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.