Example: MessageBodyReader and MessageBodyWriter Interceptors

WARNING - TOPIC NOT WRITTEN - TOPIC ID: 2913

This topic has not yet been written. The content below is from the topic description.
Lets look at an example: @Provider @ServerInterceptor public class MyHeaderDecorator implements MessageBodyWriterInterceptor { public void write(MessageBodyWriterContext context) throws IOException, WebApplicationException { context.getHeaders().add("My-Header", "custom"); context.proceed(); } } Here we have a server side interceptor that adds a header value to the response. You see that it is annotated with @Provider and @ServerInterceptor. It must modify the header before calling context.proceed() as the reseponse may be committed after the MessageBodyReader runs. Remember, you MUST call context.proceed(). If you don't, your invocation will not happen.