Java Reference
In-Depth Information
unauthenticated users executing any of your JAX-RS components. So, if you have a custom
authentication filter, you probably want that filter to be executed first. Another example is
the combination of our GZIP encoding example with a separate WriterInterceptor that
encrypts the message body. You probably don't want to encrypt a GZIP-encoded representa-
tion. Instead you'll want to GZIP-encode an encrypted representation. So ordering is import-
In JAX-RS, filters and interceptors are assigned a numeric priority either through the @Pri-
ority annotation or via a programmatic interface defined by Configurable . The JAX-RS
runtime sorts filters and interceptors based on this numeric priority. Smaller numbers are first
in the chain:
package javax . annotation ;
public @interface Priority {
int value ();
The @Priority annotation is actually reused from the injection framework that comes with
JDK 7. This annotation would be used as follows:
import javax.annotation.Priority
javax.annotation.Priority ;
import ;
@Priority ( Priorities . AUTHENTICATION )
public class
class BearerTokenFilter
BearerTokenFilter implements
implements ContainerRequestFilter {
The @Priority annotation can take any numeric value you wish. The Priorities class spe-
cifies some common constants that you can use when applying the @Priority annotation:
package javax . ws . rs ;
public final
final class
class Priorities
Priorities {
private Priorities () {
// prevents construction
* Security authentication filter/interceptor priority.
Search WWH ::

Custom Search