@Override
public WebTarget provide() {
// no need for try-catch - unlike for @*Param annotations, any issues with @Uri would usually be caused
// by incorrect server code, so the default runtime exception mapping to 500 is appropriate
final ExtendedUriInfo uriInfo = getContainerRequest().getUriInfo();
final Map<String, Object> pathParamValues = Maps.transformValues(uriInfo.getPathParameters(),
new Function<List<String>, Object>() {
@Override
public Object apply(List<String> input) {
return input.isEmpty() ? null : input.get(0);
}
});
JerseyUriBuilder uriBuilder = new JerseyUriBuilder().uri(this.uri).resolveTemplates(pathParamValues);
final ManagedClient managedClient = client.get();
if (!uriBuilder.isAbsolute()) {
final String customBaseUri = managedClient.customBaseUri;
final String rootUri = customBaseUri.isEmpty() ? uriInfo.getBaseUri().toString() : customBaseUri;
uriBuilder = new JerseyUriBuilder().uri(rootUri).path(uriBuilder.toTemplate());
}
return managedClient.instance.target(uriBuilder);