Search

28.2. PreProcessInterceptor

download PDF
The org.jboss.resteasy.spi.interception.PreProcessInterceptor runs after a JAX-RS resource method is located, but before the method is invoked. They can only be used on the server, but you must still annotate them with @ServerInterceptor. They can be used to implement security features or to preempt the Java request. The RESTEasy security implementation uses these interceptors to abort requests prior to invocation if the user does not pass authorization. The RESTEasy caching framework uses them to return cached responses, to avoid invoking methods multiple times. The interceptor interface is as follows:
    public interface PreProcessInterceptor
    {
       ServerResponse preProcess(HttpRequest request, ResourceMethod method) throws Failure, WebApplicationException;
    }

PreProcessInterceptors run in sequence and do not wrap the actual JAX-RS invocation. To illustrate:
    for (PreProcessInterceptor interceptor : preProcessInterceptors) {
       ServerResponse response = interceptor.preProcess(request, method);
       if (response != null) return response;
    }
    executeJaxrsMethod(...);
If the preProcess() method returns a ServerResponse then the underlying JAX-RS method will not be invoked and the runtime will process the response and return to the client.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.