Hello Marc,
what could I do with the resource objects? - If I want to use them, I
have to now to which class I have to cast them. If the resource class is
no put under another resource class, I will get a ClassCastException.
How does this ease the URI construction? What were requests to the list?
(sorry I didn't get them)
My request to this was to go to the parent of the actual URI reference.
This is not really esay with this approach: I have to iterate the keys,
check, if another key is avaiable in the iterator, and then I could add
it to the path. This would be much easier be add a method
UriBuilder.parent(), which could throw an IllegalStateException (or
another), if this URI represents the (virtual) root directory of the
host. I think we should not prohibit the parent resource at the root
resource class, because it should be possible to reach another root
resource class of the same runtime environment instance.
best regards
Stephan
Marc Hadley schrieb:
> Issue 7[1]:
>
> "To help with URI construction it would be useful for a resource class
> to be able to access the list of resources whose sub-resource locators
> were used to find the resource class."
>
> This has come up several times on the users list recently, I propose
> to add a new method to UriInfo as follows:
>
> /**
> * Get a map of relative URI to resource class instance. Each key
> represents
> * a partial path that matched a resource class, a sub-resource method or
> * a sub-resource locator. Each value is the instance of the resource
> class
> * for the corresponding key. When iterating the map, the keys are
> ordered
> * according to request URI matching order, with the root resource first.
> * E.g.:
> *
> * <pre>@Path("foo")
> *public class FooResource {
> * @GET
> * public String getFoo() {...}
> *
> * @Path("bar")
> * @GET
> * public String getFooBar() {...}
> *
> * @Path("baz")
> * public BazResource getFooBaz() {...}
> *}</pre>
> *
> * <p>A request <code>GET /foo</code> would return a map with a single
> key:
> * "foo" whose value is an instance of FooResource</p>
> *
> * <p>A request <code>GET /foo/bar</code> would return a map with two
> keys
> * in the following order: "foo" whose value is an instance of
> * <code>FooResource</code> and "bar" whose value is an instance of
> * <code>FooResource</code></p>
> *
> * <p>A request <code>GET /foo/baz</code> would return a map with two
> keys
> * in the following order: "foo" whose value is an instance of
> * <code>FooResource</code> and "baz" whose value is an instance of
> * <code>BazResource</code></p>
> *
> * @return a map of URI to resource class instance.
> */
> public Map<URI, Object> getResourceAncestry();
>
> Any objections, enhancements ?
>
> Marc.
>
> [1] https://jsr311.dev.java.net/issues/show_bug.cgi?id=7