this code works fine with XML and JSON formats:
@GET
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{offset}/{limit}")
public Collection<PujInstitutionRoleEntity> selectAll(
@PathParam("offset") int offset, @PathParam("limit") int limit) {
return facade.readAll(PujInstitutionRoleEntity.class, offset, limit);
}
this other code doesn't work for JSON formats:
public abstract class PujGenericResource<T extends AbstractArenaEntity, PK> {
protected abstract PujEntityFacade<T> getFacade();
private final Class<T> genericType;
@SuppressWarnings("unchecked")
@GET
@Produces( { MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("{offset}/{limit}")
public T[] selectAll(@PathParam("offset") int offset,
@PathParam("limit") int limit) {
Collection<T> results = getFacade().readAll(genericType, offset, limit);
T[] response =
results.toArray((T[]) Array.newInstance(genericType, results
.size()));
return response;
}
-----------
This means I am forced to repeat myself copying the method for all
resources ... ?