Hi John thanks for this example...
On Thu, Oct 7, 2010 at 10:57 PM, John Klassa <[email protected]> wrote: > > I'm trying to build a URI in code, using features of CXF. My resource > class and methods are annotated thusly: > > @Path("/project") > public class ProjectResource > // ... > @GET > @Path("/{type}/{name}") > public Response serveContent (...) > @GET > @Path("/{type}/{name}/{state}") > @Produces({"text/plain", "application/xml", "application/json"}) > public Response serveContent (...) > @GET > @Path("/{type}/{name}/{state}-{target}") > public Response serveContent (...) > > Basically, you've got a "project" which has a "type" and a "name", and then > you might want info about: > > 1. the project as a whole: /project/mytype/myproj > 2. a state within the project: /project/mytype/myproj/mystate > 3. a state transition within the project: > /project/mytype/myproj/mystate0-mystate1 > > [Note that I chose to model #3 as "old-new" rather than "old/new" because > there isn't really a hierarchy here; it's more that the transition itself is > a resource, and so joining the pieces with a "-" seemed more natural.] > > To that end, when I attempt to construct a URI for a particular resource > (in order to put a link to it inside some other resource, for example), CXF > seems to want to build a generic URI out of my path components, using > slashes as the separator. It never inserts the dash, even in the event that > enough parameters have been specified to warrant one. > > Am I misunderstanding the functionality here? Should it be possible to > have CXF construct a URI from the best-matching pattern in a resource method > annotation? That is, if I pass values into some variant of: > > UriBuilder > .fromResource(SomeResource.class) > .path(xxx) > .build(yyy) > > should it be possible to get a URI that has the dash in it, in my case? > > it should definitely work, what values do you provide for path(...) ? cheers, Sergey
