Skip to content

Interface inheritance

Ahmad K. Bawaneh edited this page Dec 28, 2019 · 2 revisions

Interface inheritance

A request factory interface can extend from other interfaces that does or does not have the request factory annotation. this means that we can generate a single request factory for multiple jax-rs interfaces, or we can generate a request factory for jax-rs interfaces when we dont have access to the source code to add the @RequestFactory annotation. each inherited interface can have it own @Path annotation.

Sample :

@RequestFactory
public interface SomeService extends FirstService, SecondService {

    @Path("some-path")
    SomeResponse someRequest();
}
@Path("first-root-path")
public interface FirstService {
    @Path("first-path")
    SomeResponse firstRequest();
}
@Path("second-root-path")
public interface SecondService {
    @Path("second-path")
    SomeResponse secondRequest();
}

So this will generate a factory for all service methods from all three services, where FirstService and SecondService could be coming from an external dependency.