当前位置: 动力学知识库 > 问答 > 编程问答 >

java - JAX-RS resource interfaces when server implemented asynchronously

问题描述:

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?

分享给朋友:
您可能感兴趣的文章:
随机阅读: