From: P. L. <two...@gm...> - 2011-02-14 21:09:35
|
Hi, I'm having trouble using a @Path annotation that uses a regular expression. I'm adding authorization code to an already existing set of resources/subresources. My goal is to add a sub-resource to all resources without having to modify all the existing resources. Here's the idea: @Path("/top/{name}") public class TopResource { @Path("/sub") public SubResource getSub() { return new SubResource(); } @GET ... } public class SubResource { @GET ... } These are the existing resources. I'd like to add a "/auth" sub resource to *both* of them. Ideally, I don't want to modify both of them and make then extend some kind of AbstractResource. So my solution is this: @Path("/{resource:.*}/authz") public class AuthzResource { @PathParam("resource") private String resource; @GET ... } The result is that every existing and future resource now suddenly has an ".../authz" sub resource. It works, but it's inconsistent. Depending on the path, I either get a 404 or the @GET method is invoked on my AuthzResource. Here are the cases I've found: "/top/{name}/authz" --> ok "/top/{name}/sub/authz" --> 404 "Could not find resource for relative ..." It works for some sub-resources but not all. I my approach "supposed" to work? Cheers, Philippe |