If I follow this I can add a ContainerRequestFilter and it gets picked up by Quarkus and runs as expected. However, I'm writing an extension to take advantage of a ContainerRequestFilter written by another team. I'm unsure of how to get Quarkus to use this filter. I've tried adding it as an AdditionalBeanBuildItem
@BuildStep
public void producer(BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(3rdPartyFilter.class));
}
But this doesn't work and the filter doesn't run on requests.
You can take a look at how other extensions do this, for example how the quarkus-smallrye-opentracing
does it.
Essentially all you need is to add a JAX-RS DynamicFeature in the runtime
module of your application.
@Provider
public class QuarkusSmallRyeTracingStandaloneVertxDynamicFeature implements DynamicFeature {
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
context.register(MyFilter.class);
}
public static class MyFilter implements ContainerRequestFilter {
// whatever
}
}
In addition to @geoand's answer, I think you also need to add a @BuildStep in the deployment part of your extension.
import io.quarkus.resteasy.common.spi.ResteasyJaxrsProviderBuildItem;
class MyProcessor {
@BuildStep
ResteasyJaxrsProviderBuildItem createOpentracingFilter() {
return new ResteasyJaxrsProviderBuildItem(MyFilter.class.getName());
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.