Wednesday Jul 13, 2011

Jersey - Automatic XML schema generation for WADL

Gerard Davison contributed to Jersey one (last!) thing which is needed for generating client based on returned wadl - he managed to add XML schemas which describe returned (or accepted) types. See more details in his blog post: Auttomatic XML Schema generation for Jersey WADLs.

Thanks Gerard! ..and looking forward to another contribution(s) :-)

Monday 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:

    @Path("root")
    public static class RootResource {
        @Get
        public String get() {
            return "GET";
        }

        @Path("switch")
        @POST
        public void switchMethod(@Context WadlApplicationContext wadlApplicationContext) {
            wadlApplicationContext.setWadlGenerationEnabled(!wadlApplicationContext.isWadlGenerationEnabled());
        }
    }

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

About

Pavel Bucek

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today