简体   繁体   中英

RESTEasy Interceptors

I have configured an interceptor for my REST Services as follows

@Before("execution(* com.test.controllers.*.*(..))")
public void logBefore(final JoinPoint joinPoint) { }

I am sending a JSON as my request to my service. And this is logging my request JSON. Now, in the case of an invalid JSON, the web application will throw an exception and will not log the request JSON. Is there a way I can log the request JSON even before it gets parsed?

You can apply @Priority annotation to your interceptor. A collection of built-in priority constants is defined in javax.ws.rs.Priorities .

The interceptor that parses the request JSON use Priorities.ENTITY_CODER = 4000 .If no priority is specified, the default is Priorities.USER = 5000 . The lower the number the higher the priority. Use the @Priority and take any numeric value you wish between 3000 and 4000 like:

private static final int LOG_BEFORE = 3500;

@Priority(LOG_BEFORE)        
public void logBefore(final JoinPoint joinPoint) { }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM