开发者

JAX-RS: Resolve URI of Linked Resources on the Server

is there a standard way (JAX-RS) to resolve REST URIs to resources on the server side? As I understand the common practices, it's best to provide a full URI as an identifier for resources. If I want to allow somebody to POST/PUT a document like this to create/change a product:

<product>
    [...]
    <categories>
        <category>http://.../rest/categories/12</category>
        <category>http://.../rest/categories/35</category>
    </categories>
</product>

As you can see, the references to the categories are their resource URIs. On the server side I now have to resolve these URIs to the corresponding resources. The simplest approach would 开发者_如何学Gobe to create a client for the service on the server itself and do a standard GET request on these URIs. But I feel like this shouldn't be necessary.

Is there a standard way to do this? Is there a CXF way to do this? Is it better to always provide an additional id as well?

Thanks.

Dominik


I think you are looking for - http://jersey.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/core/ResourceContext.html

It is not from CXF or JAX-RS but from Jersey. I used it to parse documents just as in your example.

Inject it using @Context into your resource to use it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜