#398 - Remove unnecessary URI conversion in ControllerLinkBuilderFactory.

ControllerLinkBuilderFactory now forwards the source UriComponents to the ControllerLinkBuilder instead of turning it into a URI and a UriComponentsBuilder in turn.

Original pull request: #422.
This commit is contained in:
Kevin Conaway
2016-01-07 08:28:37 -05:00
committed by Oliver Gierke
parent dd0f9e8905
commit 7174015746
4 changed files with 26 additions and 1 deletions

View File

@@ -49,6 +49,11 @@ public abstract class LinkBuilderSupport<T extends LinkBuilder> implements LinkB
this.uriComponents = builder.build();
}
public LinkBuilderSupport(UriComponents uriComponents) {
Assert.notNull(uriComponents);
this.uriComponents = uriComponents;
}
/*
* (non-Javadoc)
* @see org.springframework.hateoas.LinkBuilder#slash(java.lang.Object)

View File

@@ -60,6 +60,15 @@ public class ControllerLinkBuilder extends LinkBuilderSupport<ControllerLinkBuil
}
/**
* Creates a new {@link ControllerLinkBuilder} using the given {@link UriComponents}.
*
* @param uriComponents must not be {@literal null}.
*/
ControllerLinkBuilder(UriComponents uriComponents) {
super(uriComponents);
}
/**
* Creates a new {@link ControllerLinkBuilder} with a base of the mapping annotated to the given controller class.
*
* @param controller the class to discover the annotation on, must not be {@literal null}.

View File

@@ -137,7 +137,7 @@ public class ControllerLinkBuilderFactory implements MethodLinkBuilderFactory<Co
}
UriComponents components = applyUriComponentsContributer(builder, invocation).buildAndExpand(values);
return new ControllerLinkBuilder(UriComponentsBuilder.fromUriString(components.toUriString()));
return new ControllerLinkBuilder(components);
}
/*