How can I provide configuration to JAX-RS @Provider annotated ContainerRequestFilter?

假如想象 提交于 2019-12-23 17:42:33

问题


I'm using ContainerRequestFilter filter like this:

@NameBinding
@Target({TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface SomeFilterAnn {}

@SomeFilterAnn
@Provider
public class SomeFilter implements ContainerRequestFilter {
  private static final Logger LOG = LoggerFactory.getLogger(SomeFilter.class);

  @Override
  public void filter(ContainerRequestContext requestContext) throws IOException {
    // ...
  }
} 

It makes possible to bind the filter to rest resources by @SomeFilterAnn automatically. This works also for sub-resources in opposite to DynamicFeature issue described here.

I need however to do some advanced configuration to my SomeFilter and wonder what is the jax-rs way to do it - ie. use @Context/@Provider or some CXF or WildFly 8.2 mechanism (but no RESTEasy nor Jersey) or other way to provide access to configuration logic.

来源:https://stackoverflow.com/questions/33329853/how-can-i-provide-configuration-to-jax-rs-provider-annotated-containerrequestfi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!