I am using JAX-RS
for my web services. I have common functionality and would like to use inheritance. I am providing simple CRUD operations. I have defined an i
What you've described above looks good. Here are the rules for JAX-RS inheritance which based on what you've provided you are adhering.
From JAX-RS spec §3.6:
JAX-RS annotations MAY be used on the methods and method parameters of a super-class or an implemented interface. Such annotations are inherited by a corresponding sub-class or implementation class method provided that method and its parameters do not have any JAX-RS annotations of its own. Annotations on a super-class take precedence over those on an implemented interface. If a subclass or implementation method has any JAX-RS annotations then all of the annotations on the super class or interface method are ignored. E.g.:
public interface ReadOnlyAtomFeed {
@GET @Produces("application/atom+xml")
Feed getFeed();
}
@Path("feed")
public class ActivityLog implements ReadOnlyAtomFeed {
public Feed getFeed() {...}
}
In the above, ActivityLog.getFeed
inherits the @GET
and @Produces
annotations from the interface.
Conversely:
@Path("feed")
public class ActivityLog implements ReadOnlyAtomFeed {
@Produces("application/atom+xml")
public Feed getFeed() {...}
}
In the above, the @GET
annotation on ReadOnlyAtomFeed.getFeed
is not inherited by ActivityLog
.getFeed