How can I provide configuration to JAX-RS @Provide

2019-07-10 17:11发布

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.

0条回答
登录 后发表回答