【发布时间】:2020-06-01 10:36:13
【问题描述】:
我编写了一个日志过滤器,并使用 ContainerRequestContext 的 setProperty() 函数将某些信息从 ContainerRequestContext 传递到 WriterInterceptorContext。
在使用 Jersey 实现时,我能够检索我使用 getProperty 设置的属性。
但同样不适用于 Apache CXF 2.7。有输入吗?
public class LoggingFilter implements ContainerRequestFilter, ContainerResponseFilter,WriterInterceptor {
@Override
public void filter(ContainerRequestContext reqContext) throws IOException {
reqContext.setProperty("sampleProperty", "sampleValue");
}
@Override
public void aroundWriteTo(WriterInterceptorContext context)
throws IOException, WebApplicationException {
if (context.getProperty("sampleProperty") != null) { -> passes for jersey, fails for Apache CXF 2.0
}
}
【问题讨论】:
标签: java filter jersey jax-rs cxf