Provides integration with using Ebean with JAX-RS.

Ebean JAX-RS Module

Provides integration with using Ebean with JAX-RS.

Specifically it integrates Ebean's JSON and XML marshalling and unmarshalling support and provides some integration to make it easier to use Entity Beans with JAX-RS.

Generally you need to:

The com.avaje.ebean.jaxrs package needs to be registered with JAX-RS so that it finds Ebean's JaxrsJsonProvider. This provides the JSON Marshalling and Unmarshalling of entity beans.

If you use custom Media types then you might need to subclass the JaxrsJsonProvider and register it with those media types.

Typically developers will extend the AbstractEntityResource object which has built in support for many typical functions such as find by id, find all, insert, update, delete and delete many by ids.

EXAMPLE 1: Simple fetch

...
@Path("/customer{uriOptions:(:[^/]+?)?}/")
@Produces({MediaType.APPLICATION_JSON, "text/json"})
public class CustomerJsonResource extends AbstractEntityResource {

    public CustomerJsonResource() {
        super(Customer.class);
    }

    /**
     * Return the customer but with more related information including its
     * shippingAddress, billingAddress and list of contacts.
     */
    @GET 
    @Path("{id}/full")
    public Customer findFull(@PathParam("id") String id) {
        
        return server.find(Customer.class)
            .select("id, name")
            .fetch("shippingAddress")
            .fetch("billingAddress")
            .fetch("contacts", "firstName, lastName, phone")
            .setId(id)
            .findUnique();
    }
...