Dropwizard 0.8 update filter bug
I am upgrading from v0.7.1 to v0.8 and found that the Jersey filter functionality we are using is out of date. Next line:
environment.jersey().getResourceConfig().getContainerRequestFilters().add(new FilterAuthentication());
(pretty much identical to the DW manual )
now gives a compiler error:
"The method
getContainerRequestFilters ()is undefined for the Type
ResourceConfig"
Please can someone point me in the right direction on how to update this feature. Many thanks
source to share
Dropwizard 0.8.x uses Jersey 2.x. Most of the methods have ResourceConfig
changed. For Jersey 2, you can use the register
general purpose method used to bind any JAX-RS component.
Dropwizard also has a method register
bound to jersey()
, so we don't need to call getResourceConfig()
as it jersey().register()
forwards the config register
.
So any of these will work
env.jersey().register(...);
env.jersey().getResourceConfig().register(...);
Also see Jersey API 2 ResourceConfig
source to share