Experts,
I'd like to propose to get two new properties added to Target[1]
1. baseURI (type: URI)
Every Target points to a specific HTTP resource. However resources are
often can be considered to be part of a given RESTful
application/service. It should be possible in most cases to report what
was a base Target/URI this given Target originated from.
Rules:
All Targets created from absolute URIs (via Client or Target.path()
factory methods) must report that absolute URI as the base URI.
In all other cases it must be an original absolute URI which led to the
creation of the top-level Target.
Examples:
Target t = client.target("
http://service");
assertEquals("
http://service", t.getBaseURI());
assertEquals("
http://service/1", t.path("
http://service/1").getBaseURI());
Target t2 = t.path("2");
assertEquals("
http://service", t2.getBaseURI());
2. prevTarget (type: Target)
It should be possible to start from a current Target and revert back to
the original Target which initiated the chain. Similarly how one can
express a process "from this Target to the next Target", one should be
able to express "from this Target to the previous Target".
This makes Target a more 'capable' and allows for tracing all the
intermediate Targets. To some extent this can be compared to
UriInfo.getMatchedURIs property...
Rules:
All Targets created from absolute URIs must return null;
Those created from Target.path(relativePath); return the previous Target.
Examples:
Target t = client.target("
http://service");
assertNull(t.getPrevTarget());
Target t2 = t.path("2");
assertSame(t, t2.getPrevTarget());
assertSame(t2, t2.path("3").getPrevTarget());
Comments ?
Sergey
[1]
http://java.net/projects/jax-rs-spec/sources/git/content/src/jax-rs-api/src/main/java/javax/ws/rs/client/Target.java?rev=bdee7808db117198b8e611551a12a099bcf6b103
Cheers, Sergey