dev@jsr311.java.net

Matrix Params question and concern

From: Heiko Braun <hbraun_at_redhat.com>
Date: Sat, 15 Dec 2007 19:41:24 +0100

(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.


* URIBuilder assumes that Matrix parameters only happen once and at the
last path segment.

* matrix parameter names could be repeated throughout the URI and thus
@MatrixParam could be ambiguous.


******

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) {...}


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) {...}