New in Juneau 7.2.1:
Method and argument annotations such as @RestMethod, @Path, etc..., are now inheritable from parent classes and interfaces.
This means you can now define the same Java interface for both your server and client side APIs.
For example, the Pet Store application now defines a top-level PetStore interface:
The PetStoreResource class implements this interface using the normal RestServlet API.
In this particular case, the @RestMethod annotations are specified in the implementation class, although they could be located in the interface as well.
The PetStore interface can be used as the remote proxy interface like so:
The advantages to this design approach are:
- It's much easier to keep server and client side APIs in sync since they're working off the same interface.
- The annotations can be moved into your interface where they won't interfere with the readability of your servlet code.