Hi

On Mon, Feb 21, 2011 at 7:41 PM, KARR, DAVID (ATTSI) <[email protected]> wrote:
> I'm now at the point where I'm going to need to generate HATEOAS URLs in
> my responses.  These will refer to other operations in my controller.
> What features does CXF provide to make it easier to generate those URLs?
> I looked in the doc and I didn't see any obvious pointers to this.
>
> This would include generating the "root" URL for the controller, along
> with the extra path for a particular method, and plugging in any
> required or optional parameters.
>

JAX-RS UriInfo and UriBuilder is what JAX-RS provides. UriInfo will
give the base URI builder, ex :

UriBuilder builder = uriInfo.getBaseUriBuilder();

ex, if you have a services.war deployed then this buider will
encapsulate a URI like http://localhost:8080/services.
Next you can do say

builder.path(Controller.class).build()

This will represent the root URI which can be used to match the
controller resource.
UriBuilder has methods like path(Method) which can be used to capture
a path segment a given resource method handles, etc...

The other option is to delegate to the XSLTJAXBProvider which will
pass the UriInfo details to the custom template as the xslt
parameters...

cheers, Sergey

Reply via email to