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

I use the filter ContainerRequestFilteras follows:

 
@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 {
    // ...
  }
} 

This allows you to automatically bind the filter to recreation resources @SomeFilterAnn. This also works for sub-resources, unlike DynamicFeaturedescribed here .

I need, however, to do some advanced configuration for mine SomeFilterand wonder what is the jax-rs way to do this, i.e. use @Context/ @Provideror some CXF or WildFly 8.2 mechanism (but not RESTEasy and Jersey) or another way to provide access to the configuration logic.

+2
source share

Source: https://habr.com/ru/post/1613052/


All Articles