Providers are simply a way to extend and customize the JAX-RS runtime. You can think of them as plugins that (potentially) modify the behavior of the runtime environment in order to fulfill a set of goals (defined by the program).
Providers do not match resource classes; they exist, conceptually, at the level between resource classes and the JAX-RS implementation. If this helps, you can think of them in the same light as device drivers (existing between the user and the kernel space). This is a broad generalization.
There are three classes of vendors defined by the current JAX-RS specification. The commonality between them is that all providers must be identified by the @Provider annotation and follow certain rules for declaring a constructor. In addition, different types of providers may have additional annotations and will implement different interfaces.
Suppliers noun
These providers control the mapping of data representations (e.g. XML, JSON, CSV) with their Java object equivalents.
Context providers
These providers control the context that resources can access through the @Context annotations.
Exception providers
These providers control the mapping of Java exceptions to the JAX-RS Response instance.
Your runtime will have many predefined providers that will be responsible for implementing the basic level of functionality (for example, to map to and from XML, translate the most common exceptions, etc., etc.). You can also create your own suppliers as needed.
The JAX-RS specification is a good reference for reading these different types of providers and what they do (see chapter 4).
Perception Nov 26 2018-12-12T00: 00Z
source share