Hi Brad
Thanks for looking into this code. It would be great if several people could have a shared knowledge of what's happening in that
code...The algorithm implementation in CXF may still need some fixes applied to it.
(requested)uri: "/"
template: "/{messageId}"
templateRegexPattern: "/(.*?)(/.*)?"
This is all dictated by the spec. Every occurence of {} template parameter is substituted by /(.*?), and then (/.*)? is added if
it's a limited template (default).
The rationale I believe is that it allows for some methods to point some other methods on subresource locators. For example, if
http://localhost:8081/cxf/rest/test/domain/network/brad/mail/123 were to be processed by a sub locator, then the value of the final
matching group would be '123' and it would be used to find the actual method on the sub locator class.
Hi,
just to follow up from yesterday, I just wanted to clarify the regular
expression stuff.
Having stepped through the code in URITemplate.match the main point of
interest seems to be around line 122:
Matcher m = templateRegexPattern.matcher(uri);
if (!m.matches()) {
return false;
}
As far as I can tell, this is what compares the requested URI to those
declared for each method and therefore dictates what methods are
matched. Given my test class the values I'm seeing the following
variable values for the method readMessage:
(requested)uri: "/"
template: "/{messageId}"
templateRegexPattern: "/(.*?)(/.*)?"
Regex is not exactly my forte but from what I can tell this pattern
would match the template because it is effectively the "/" with zero
or more characters after it, potentially repeated one or more times.
Is that correct?
My expectation here is that it shouldn't match because the method
template specifies that the "/" has a variable "messageId" after it.
With this requirement in mind, shouldn't it be looking for one or more
characters after the "/" which would require the pattern "/(.+?)".
With the pattern set to "/(.*?)" it seems to me that there is no way
to differentiate between the template for listMail ("/") and the
template for readMail ("/{messageId}").
It makes sense. I've actually asked a question on the JAX-RS users list for
some clarification on this issue...
It's most likely that there's a flaw in the CXF implementation of the algorithm
and this needs to be tracked down...
Cheers, Sergey
Apologies if I've got that fundamentally wrong. I don't think my
understanding of capturing groups is what it could be. It does seem to
be matching both of the method templates though.
Brad.
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland