Hi Heiko & Bill,
Heiko Braun wrote:
> (Bill Burke:)
>
> I was looking at the definition of Matrix parameters:
>
> RFC 2396 again, sec. 3.3:
>
> " The path may consist of a sequence of path segments separated by a
> single slash "/" character. Within a path segment, the characters
> "/", ";", "=", and "?" are reserved. Each path segment may include
> a
> sequence of parameters, indicated by the semicolon ";" character.
> The parameters are not significant to the parsing of relative
> references. "
>
>
> What I think this means is that you may have matrix parameters embedded
> within any path segment of a URI. If this is true, then this has
> implications on various contracts within JSR-311.
>
Yes.
>
> * URIBuilder assumes that Matrix parameters only happen once and at the
> last path segment.
>
More specfically the "final segment of the current URI path". So it is
possible to do this:
URI u = UriBuilder.fromUri("
http://localhost/").
path("p1").matrixParam("a", "x").
path("p2").matrixParam("a", "y").build();
which will result in the following URI:
http://localhost/p1;a=x/p2;a=y
but it is not possible to go back to "p1" path segment and add
additional matrix parameters after a further path segment has been
added. Although i suppose one could add a path segment (".."), then
another to replace segment "p1", and then canonicalize the built URI.
> * matrix parameter names could be repeated throughout the URI and thus
> @MatrixParam could be ambiguous.
>
Good point. Currently in the RI the most recent matrix parameters take
precedence, and i suspect it is buggy and recent means for the whole URI
path rather than the left hand side of the path that has been matched so
far.
>
> ******
>
> On a different, but related note, I think it would be interesting to
> allow injection of a javax.ws.rs.core.PathSegment object for a @UriParam
>
>
> @Path("{seg}/more/stuff/follows")
> public String get(@UriParam("seg") PathSegment param) {...}
>
That would make sense, i suppose more generally a path segment can be
identified by any unique template variable member, for example:
"{a},{b}/more"
both "a" and "b" could identify the same path segment.
>
> This way, for a specific segment, the app developer can pull out matrix
> parameters specific to that path segment.
>
> What's a usecase? Well, I'm prototyping something that gives access to
> a specific database and some entities will have composite keys that I
> want to map into a URI
>
> /customerdb/customers/id;name=Bill;ssn=6666666666/picture
>
> Would be:
>
> @Path("{db}/{entity-name}/{key}/{property}")
> @GET
> public JPEG get(@UriParam("db") String db,
> @UriParam("entity-name") String entity,
> @UriParam("key") PathSegment key,
> @UriParam("property) String property) {...}
>
Yes, i like that. Although currently it is not possible to get the URI
template variables and values from the PathSegment.
Perhaps, more generally, related to this is the updated URI template
specification [1].
I am wondering if there is a larger sub-set of this that can be used for
matching than we currently use. I have not had time to look in more
detail...
It might be possible to express the matrix parameters as an optional
template variable, and then use a Java type that parses the parameters
[*] i.e. we may no longer need @MatrixParam.
However, i still like the idea of 'stripping' out the matrix parameters
when matching, or in this case when not explicitly referenced so they
"don't get in the way".
Paul.
[1]
http://bitworking.org/projects/URI-Templates/draft-gregorio-uritemplate-02.html
[*] It may also help with expressing optional suffice parameters like
".xml" or ".html" for managing distinct and canonical URIs.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>
--
| ? + ? = To question
----------------\
Paul Sandoz
x38109
+33-4-76188109