官术网_书友最值得收藏!

Filter and interceptors

JAX-RS 2.0 added ContainerRequestFilter and ContainerResponseFilter to modify the request context. It is executed around the method invocation but has already passed the method resolution. On a high level, it can be seen as a CDI interceptor but only at the HTTP layer. These filters do not impact significantly the performance until they do a lot of logic, and there are a few cases where it is a good place to put some logic. One very common example is to validate a security token or log in a user based on the HTTP headers. Don't be surprised to see this kind of component while investigating what your application is doing.

In the same spirit, ReaderInterceptor and WriterInterceptor intercept MessageBodyReader or MessageBodyWriter. They are intended to wrap the input/output streams to add some support such as GZIP compression. However, since we are close to the current I/O, we need to take care to not add too much logic here if the payloads are huge or if the algorithm is complex. In fact, since the stream operations are called very often, a badly implemented wrapper can affect the performance.

主站蜘蛛池模板: 凌海市| 侯马市| 湘潭县| 栖霞市| 凭祥市| 垣曲县| 四会市| 安西县| 瑞昌市| 年辖:市辖区| 印江| 昌黎县| 罗源县| 宿松县| 犍为县| 玉屏| 屯门区| 化德县| 翁牛特旗| 五华县| 汝城县| 五台县| 博客| 丹巴县| 商城县| 杂多县| 呼伦贝尔市| 翁源县| 淅川县| 哈尔滨市| 天台县| 沙洋县| 凤城市| 察哈| 修水县| 云阳县| 三穗县| 太仓市| 延川县| 大石桥市| 莫力|