Hi Brad,
On May 8, 2008, at 2:58 AM, Brad wrote:
> Hi,
>
> apologies for jumping in here but I just wanted to get some
> clarification. Just as a bit of background, I originally discussed
> this as regards CXF with Sergey who was kind enough to raise the issue
> here. This CXF JIRA entry might give some more background on the
> problem:
>
> https://issues.apache.org/jira/browse/CXF-1572
>
> Anyway, if I read this correctly the conclusion being drawn here is
> that the spec doesn't support differentiation between URLs where
> literals are mixed in with {variables}. For example, that it cannot
> distinguish between /{a}/{b}/{c}/d and /{a}/{b}/{c}/d/{e}.Is that
> correct?
>
No, literals can be mixed in. See below for a test-case with the RI.
Another example i have is a template as follows:
@Path("({lx},{ly}),({ux},{uy})")
that represents the lower and upper down of the complex space to
render the Mandelbrot set.
> I'm not try to criticise anyone or knock the work thats been done
> here, the JSR as a whole is excellent and we are happy to be using it.
> My only thought is that for a spec supporting REST technology where
> the URL is a major part of the concept. Shouldn't that sort of thing
> be supported?
>
> I hope that doesn't sound too critical. I appreciate the effort that
> has been put into this JSR for the benefit of the community and people
> like me who are getting value from it.
>
Thanks for taking the time to provide feedback. Criticism is good :-)
it will help is improve the specification.
Paul.
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.container.httpserver.HttpServerFactory;
import com.sun.net.httpserver.HttpServer;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
public class Main {
@Path("/")
public static class Foo {
@GET
@Path("/{a}/{b}/{c}/d")
public String getABCD(
@PathParam("a") String a,
@PathParam("b") String b,
@PathParam("c") String c
) {
return a + b + c;
}
@GET
@Path("/{a}/{b}/{c}/d/{e}")
public String getABCDE(
@PathParam("a") String a,
@PathParam("b") String b,
@PathParam("c") String c,
@PathParam("e") String e
) {
return a + b + c + e;
}
}
public static void main(String[] args) throws Exception {
HttpServer server = null;
try {
server = HttpServerFactory.create("
http://localhost:
9998/");
server.start();
Client c = Client.create();
WebResource r = c.resource("
http://localhost:9998/");
System.out.println(r.path("1/2/3/d").get(String.class));
System.out.println(r.path("1/2/3/d/4").get(String.class));
} finally {
server.stop(0);
}
}
}