Could anyone explain to me what a JAX-RS Provider is and what ‘@Provider’ annotation does? I have been reading documentation but I cant get it.
If there are resource cla
To do certain activities such as Filtering-Request/Response, Exception Handling, the JAX-RS has its own default implementation logic. However, it allows users to provider thier own implementation as well.
To provide our own implementation we need to implement the appropriate classes by specifying them with @Provider annotation.
JAX-RS will do a round of scanning to find the existance of any such user-defined implementation by seaching for @Provider annotation.
For example:
...
@Provider
public class AppExceptionMapper implements ExceptionMapper {
...
...
@Provider
@PreMatching
public class RESTRequestResponseFilter implements ContainerRequestFilter, ContainerResponseFilter {
...