问题描述:

I have a JAX-RS application with resources defined in interfaces, so that I can share these interfaces between the server and clients. Currently my interface looks like:

@Path("/widget")

interface Widget {

@PUT

@Path("/{id}")

MyResponse put(@PathParam("id") long id);

}

Now, I would like to use asynchronous server-side processing, thus writing my server-side controller using:

public void put(long id, @Suspended AsyncResponse asyncResponse) { ... }

But clearly this means that the controller can no longer implement the resource interface.

I am loathed to change the interface, as clients are already consuming this, and the threading model within the service should be opaque to clients. Furthermore, clients should still have an easy way of extracting the MyResponse, which they will not have if I change the interface to match the service implementation.

What is the recommended approach in this scenario?

相关阅读:
Top