Pavel Bucek's Weblog

  • May 23, 2011

Enable/Disable WADL generation in runtime - Jersey 1.7

We've received request about giving more control related to WADL generation, but not that much (no authentication or this kind of features) in runtime. This can be useful for example when you have more than one application deployed and you want to disable WADL generation for all of them - as some security measure. How is it done? You can inject WadlApplicationContext and use its methods - isWadlGenerationEnabled() and setWadlGenerationEnabled(boolean).

Use of this is self explanatory, but note that you won't be able to enable WADL for application which disables WADL in web.xml (see ResourceConfig.FEATURE_DISABLE_WADL). Where you can inject this? Almost everywhere, for example to your WebApplicationListener or even into resource class:

    public static class RootResource {
        public String get() {
            return "GET";
        public void switchMethod(@Context WadlApplicationContext wadlApplicationContext) {

As title suggest, this functionality was added in Jersey 1.7.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.