Removing an added provider in Jersey

被刻印的时光 ゝ 提交于 2019-12-12 18:10:01

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17794372/removing-an-added-provider-in-jersey

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