jax-rs messagebodywriter with collection

I have defined the following jax-rs MessageBodyWriter:

@Provider
@ApplicationScoped
@Produces(MediaType.APPLICATION_JSON)
public class CustomerMessageBodyWriter implements MessageBodyWriter<Customer>
....
}

Additionally, my rest-endpoint looks like this:

@Path("/api/customers)
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class CustomerService {

    @GET
    @Path("/{customerNumber})
    public Customer getCustomer(@PathParam("customerNumber") String customerNumber) {}

    @GET
    public List<Customer> getCustomers(){}

}

I would like that the CustomerMessageWriter be used for both the Customer and List<Customer> response options, but i cant find away to configure this.

If it helps, I am using resteasy as the jaxrs implementation.


Download jax.rs.messagebodywriter.with.collection.zip
Direct Link


Download


Download jax.rs.messagebodywriter.with.collection.zip
Mediafire


Download


Download jax.rs.messagebodywriter.with.collection.zip
BOX.com


Download

Both comments and pings are currently closed.

Comments are closed.