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

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.

主站蜘蛛池模板: 灵石县| 吴堡县| 明水县| 榆树市| 黄平县| 吉木萨尔县| 韩城市| 祁连县| 汽车| 馆陶县| 苍南县| 清流县| 泽州县| 共和县| 合作市| 阿拉善盟| 太仆寺旗| 房产| 呈贡县| 龙海市| 河西区| 井研县| 桂林市| 靖安县| 策勒县| 龙南县| 偏关县| 微山县| 南岸区| 长治县| 安仁县| 洛浦县| 临猗县| 上蔡县| 达尔| 新干县| 思茅市| 玉门市| 龙井市| 离岛区| 克什克腾旗|