質問

I am using com.yammer.dropwizard.config.Environment addProvider method to register providers in Jersey.I have a custom provider too which does a task similar to Dropwizards own MessageBodyWriterProvider.

Jersey seems to select the inbuilt MessageBodyWriter instead of my custom one.So I figured that if I remove the inbuild provider which is registered and register my own it will work properly.

Is there a way to remove the already added provider with the class name or other way?

役に立ちましたか?

解決

environment.getJerseyResourceConfig().getSingletons()

returns a mutable Set<Object> of all the resources and providers registered with Jersey. A simple iteration over this with an instanceOf check should be enough.

The related method getProviderSingletons won't work because it is returning a new set. And removing from that set won't remove from the original.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top