I am developing an application with Jersey where I have many resources. Although the basic functionality of these resources is different, they use many common methods (for example, list, read, update, etc.). The application runs on the Google App Engine and uses Guice for dependency injection.
My first approach was to have a common AbstactResource that contains all the common logic and, accordingly, is expanded by all other resources that add their required user methods.
public class AbstractResource<T> {
@GET
public ListPage<T> list(@QueryParam("limit") Integer limit,
@QueryParam("start") Integer start) {
}
@GET
@Path("/{id}")
public T get(@PathParam("id") Long id) {
}
And an example resource looks like this:
public class TenantResource extends AbstractResource<Tenant> {
}
. , . , . , AbstractResource AudiatableResource, .
public abstract class AuditableResource<T extends AuditableModel>
extends AbstractResource {
}
, ( AuditableModel).
:
public class PropertyResource extends AuditableResource<Tenant> {
}
, :
WARNING: Return type T of method public T com.pkg.AbstractResource.get(java.lang.Long) is not resolvable to a concrete type
WARNING: Return type T of method public T com.pkg.AbstractResource.getNew() is not resolvable to a concrete type
WARNING: Return type com.pkg.data.ListPage<T> of method public com.pkg.ListPage<T> com.pkg.AbstractResource.list(java.lang.Integer,java.lang.Integer) is not resolvable to a concrete type
, , . , , .