Clone wiki

play-jersey / Home

What it is

play-jersey integrates Jersey into the Play! Framework. This enables you to use JAX-RS 1.1 annotations.

HOW-TO

Install

TODO: how to load the plugin

Activate

Add the plugin into your dependencies.yml:

require:
    - play
    - jersey -> jersey

Also, you need to import the following rule:

GET     /	     module:jersey

Configure

There is one convention that you may override. Per default, all your ressources are found under "/rest". This can be changed by setting "jersey.path":

jersey.path = /api

Use

Put some ressources and/or providers somewhere under your "app" folder. There is no structure forced, but here is a recommendation:

/rest/ressources
/rest/provider

A Ressource may look like this:

@Path("/rest/hello")
public class HelloRessource {
    @GET
    @Produces("application/json")
    public Response helloJson() {
        return Response.ok("Hello").build();
    }

    @GET
    @Produces("application/xml")
    public Response helloXml() {
        return Response.ok("Hello").build();
    }
}

Background

play-jersey is using Jackson to serialize/deserialize your entities. It ships 2 default providers: DefaultJacksonProvider and DefaultJacksonXmlProvider. XML usses Jackson XML Databind, so there is no JAXB involved.

Thanks

Thanks go to Stephane Epardaud who wrote the RESTEasy play plugin. Without his code it would have been much harder to come up with this one.

License

All my code of play-jersey is distributed under the Apache License 2.0

Two jersey specific files are taken from Jersey and adapted to my need - their header is intact and files are marked as beeing CDDL 1.1 with CPE.

Included libraries: Jackson is distributed under the Apache License 2.0 Jersey is distributed under both, the CDDL 1.1 and GPL 2 with classpath exception

Updated