Commit Graph

712 Commits

Author SHA1 Message Date
Roland Krüger
d922d6f74c #1190 - Fix typos, document links, and grammatical errors.
Unfinished sentences were marked with ellipsis….
2020-02-03 13:46:35 +01:00
Oliver Drotbohm
09c1baecc9 #1185 - Continue development on 1.0.4.BUILD-SNAPSHOT. 2020-01-15 09:29:09 +01:00
Oliver Drotbohm
0b1999052a #1185 - Releasing Spring HATEOAS 1.0.3.RELEASE. 2020-01-15 09:29:07 +01:00
Oliver Drotbohm
167a36848c #1185 - Update changelog. 2020-01-15 09:28:15 +01:00
Oliver Drotbohm
27b21c8f19 #1184 - Backport dependency upgrades from 1.1.
Backports of:

#1174 - Upgrade to Spring Framework 5.2.3.
#1178 - Upgrade to Jackson 2.10.2.
#1179 - Upgrade to Kotlin 1.3.61.
#1180 - Upgrade to Slf4J 1.7.30.
#1181 - Upgrade to Reactor Dysprosium SR3.
#1182 - Upgrade to JUnit 5.5.2.
2020-01-15 09:24:05 +01:00
Oliver Drotbohm
913ba151b9 #1171 - Fix for potential NullPointerException in UriTemplate.
UriTemplate.with(TemplateVariable) now properly forwards the UriBuilderFactory from the current instance.

Backport of: #1165.
2020-01-14 14:02:56 +01:00
Oliver Drotbohm
3943014ad8 #1170 - Update copyright years to 2020. 2020-01-10 12:29:07 +01:00
Oliver Drotbohm
0fe5bde3fe #1167 - Fix premature initialization of downstream dependencies of WebConverters.
RestTemplateHateoasConfiguration is a BeanPostProcessor and previously used a direct reference to WebConverters which caused downstream dependencies to be initialized once Spring Framework looks up BeanPostProcessors. This renders all of those dependencies ineligible of being post-processed by other BeanPostProcessors in turn.

This is now fixed by using an ObjectProvider<WebConverters> from within RestTemplateHateoasConfiguration instead, so that the initialization is delayed until the processing of the first bean is triggered.

Backport of: #1166.
2020-01-06 22:00:08 +01:00
Oliver Drotbohm
1b16157c09 #1158 - Fixed custom EntityModel serialization for Map payloads.
Using a custom serializer seems to break downstream projects that also register serializers for EntityModel. We're now using extra methods on EntityModel itself that do the trick as well.
2019-12-12 11:15:32 +01:00
Oliver Drotbohm
d1204f3aa1 #1158 - Tweaks to EntityModel to allow deserialization with Map<String, Object> content.
We now keep internal methods in EntityModel that are configured using Jackson annotations so that it'd populate the content with a Map in case Map<String, Content> is defined as payload type.
2019-12-11 18:59:46 +01:00
Oliver Drotbohm
3b18df355f #1158 - Register custom serializers to handle Map based EntityModel instances.
We now register a custom serializer to massage EntityModel instances into dedicated types that – in case of a Map being the content of the entity model – wrap the model into a type that applies the necessary Jackson tweaks to properly unwrap a Map.
2019-12-11 09:41:29 +01:00
Oliver Drotbohm
eab124718b #1156 - Fixed thread-safety issues in AnnotationLinkRelationProvider.
We now use a ConcurrentReferenceHashMap to cache annotation lookups in AnnotationLinkRelationProvider to avoid thread-safety issues.
2019-12-10 15:29:47 +01:00
Oliver Drotbohm
93b6076f5b #1145 - WebFlux Link creation starts with clean query parameters.
We now explicitly remove all query parameters from the base URI we use when creating links from method names.
2019-12-09 16:00:36 +01:00
Oliver Drotbohm
e51a7f7a28 #1151 - Make sure we explicitly expose all media type model properties.
Jackson can be configured to not auto-detect properties on objects to be rendered, requiring them to be explicitly annotated with @JsonProperty to be exposed. In such a configuration setup, some of our model types do not work properly as so far we have expected public properties to be included automatically.

This commit changes that to explicitly include @JsonProperty on all of the getter methods exposed.
2019-12-09 12:17:23 +01:00
Oliver Drotbohm
285af0c7e4 #1153 - WebFluxLinkBuilder now considers the requests context path.
The base URI we create now consists of the requests root URI plus the context path concatenated. On actual UriComponentsBuilder creation we then simply append the path discovered from the method mapping.
2019-12-09 12:17:20 +01:00
Oliver Drotbohm
12ca3d4fbf #1149 - Restore backward compatibility in LinkBuilderSupport.
Reintroduced callback methods that existing implementations of LinkBuilderSupport will have implemented in deprecated form indicating removal for 1.1.
2019-12-09 10:43:35 +01:00
Oliver Drotbohm
6475e6751f #1149 - Further performance improvements in link creation.
The implementation details of WebHandler have been significantly refactored to rather work with structures that allow better cacheability by clearly separating abstractions over the statically available information from the per-invocation aspects. This results in a new HandlerMethodParameter(s) abstraction within WebHandler. BoundMethodParameter has been removed entirely. HandlerMethodParameters are create once then cached for every controller method being linked to.

DummyInvocationUtils now creates a ThreadLocal cache of the proxies created for calls to methodOn(…) as they essentially only act as basis for subsequent calls to the methods on the proxy created which in turn are expected to be handed into a linkTo(…) call which obtains the invocation right away. This avoids overhead in cases methodOn(…) is called multiple times for the same controller from a single controller.

The lookup of the LastInvocationAware was previously routed through the proxy, handled by InvocationRecordingMethodInterceptor. This resulted in a second, reflective call for every link creation. DummyInvocationUtils now provides a dedicated lookup method as it knows about the structure of the proxy it created and thus can unfold the recorded invocation more effectively.

The LinkBuilder type hierarchy now works with UriComponents and only creates a UriComponentsBuilder if it needs to modify the backing link in the first place. This avoids superfluous back and forth between UriComponents and UriComponentsBuilders that involved quite a bit of String parsing and creation.

EncodingUtils now starts from a StandardCharsets.UTF_8 to avoid repeated Charset creation.

The changes result in a ~3x performance compared to 1.0.2.RELEASE:

1.0.2.RELEASE

Benchmark                                         Mode  Cnt         Score        Error  Units
ControllerLinkBuilderBenchmark.noLinkCreation    thrpt   10  39004583,189 ± 751668,181  ops/s
ControllerLinkBuilderBenchmark.pureLinkCreation  thrpt   10     43443,133 ±    783,120  ops/s
ControllerLinkBuilderBenchmark.withLinkCreation  thrpt   10     60201,629 ±   1292,179  ops/s

1.1 / 1.0.3 SNAPSHOT

Benchmark                                         Mode  Cnt         Score        Error  Units
ControllerLinkBuilderBenchmark.noLinkCreation    thrpt   10  39618560,950 ± 612794,310  ops/s
ControllerLinkBuilderBenchmark.pureLinkCreation  thrpt   10    121700,634 ±   1510,415  ops/s
ControllerLinkBuilderBenchmark.withLinkCreation  thrpt   10    121982,085 ±   3344,206  ops/s

noLinkCreation - creates a single RepresentationModel instance but adds no links
pureLinkCreation - creates a single link pointing to a controller method
withLinkCreation - creates a single RepresentationModel instance adding a single link
2019-12-09 08:53:36 +01:00
Greg Turnquist
f3b1899197 #1142 - Continue development on 1.0.3.BUILD-SNAPSHOT. 2019-12-03 09:47:55 -06:00
Greg Turnquist
a636c22715 #1142 - Releasing Spring HATEOAS 1.0.2.RELEASE. 2019-12-03 09:47:53 -06:00
Greg Turnquist
9cacf46bde #1142 - Update CHANGELOG for 1.0.2.RELEASE. 2019-12-03 09:47:23 -06:00
Greg Turnquist
99cb3fee44 #1139 - Polishing. 2019-12-03 09:03:08 -06:00
Oliver Drotbohm
9fcc3fece8 #1140 - Forward global codec settings to decoders in WebClientConfigurer.
We now use new API introduced in Spring Framework 5.2.2 to forward the global configuration settings into the hypermedia decoders we register.
2019-12-03 14:34:32 +01:00
Oliver Drotbohm
fde745ea35 #1139 - Upgrade to Spring Framework 5.2.2 release. 2019-12-03 14:12:06 +01:00
Oliver Drotbohm
3de54e07c3 #1140 - Make sure we don't accidentally drop customizations made to WebClient.
We now use the API introduced in Spring Framework 5.2.2 to customize a WebClient to add hypermedia related en- and decoders without dropping customizations potentially made to the WebClient instance.
2019-12-02 16:56:07 +01:00
Oliver Drotbohm
e8be600331 #1139 - Upgrade to Spring Framework 5.2.2 snapshots. 2019-12-02 16:54:23 +01:00
YAN Wenkun
5f9a554fde #1137 - Fix package name vnderror to vnderrors in migration script. 2019-12-02 12:46:12 +01:00
Oliver Drotbohm
ceb80542ac #1128 - Moved WebConverters bean declaration into common HateoasConfiguration.
RestTemplateHateoasConfiguration depends on a shared bean WebConverters (previously WebMvcConverters). As it can safely be used in both WebFlux and WebMVC scenarios (as it only depends on types from spring-web), we now include a declaration in the shared HateoasConfiguration. This also allows us to remove the just introduced explicit declaration of a WebConverter bean in WebFluxHateoasConfiguration.
2019-12-01 22:57:03 +01:00
Greg Turnquist
20238e26b6 #1128 - Include WebMvcConverters in WebFluxHateoasConfiguration. 2019-12-01 22:56:47 +01:00
Oliver Drotbohm
ef32df0fa1 #1131 - Polishing.
Refactored existing unit tests to use the newly introduced test fixture type. Refactored ticket references to use the current style.
2019-11-28 15:03:43 +01:00
Oliver Drotbohm
d035f53d62 #1131 - Make UriTemplate smarter to avoid reencoding of given URI strings.
UriTemplate now uses UriBuilderFactory (DefaultUriBuilderFactory in particular) to expand templates. We inspect the given source URI string, try to decode it and configure the factory to only encode values if the decoded String is shorter than the source one as that indicates it already contains encoded characters.

The UriBuilderFactory is held as transient value as its implementations are usually not serializable in the first place. Added the necessary logic to recreate the factory instance on deserialization.

Added all expansion tests given in the original ticket as unit tests.
2019-11-28 15:03:22 +01:00
Oliver Drotbohm
a03c789990 #1127 - Avoid double encoding in UriTemplate.
We now directly use UriComponentsBuilder in UriTemplate.expand(…) to avoid potential double encoding in the base URI.
2019-11-28 11:15:55 +01:00
Oliver Drotbohm
e352d0f621 #1128 - Avoid reference to spring-webmvc in configuration for RestTemplate.
RestTemplateHateoasConfiguration previously referred to HypermediaWebMvcConfigurer which is turn depending on WebMvcConfigurer, a type living in spring-webmvc. The very former would still get active in WebFlux as the web stack is selected based on the presence of either DispatcherServlet or DispatcherHandler. This is now resolved by using a WebMvcConverter indrection to handle the configuration tweaks avoiding the reference to interfaces from spring-webmvc.

Introduced an ArchUnit based test that Spring HATEOAS code only depends on Spring types containing references to reactive types from either the ….reactive package or classes starting with WebFlux.
2019-11-28 10:56:59 +01:00
Oliver Drotbohm
77b7adbe0f #1126 - Polishing. 2019-11-22 12:02:34 +01:00
Oliver Drotbohm
e7d69e3228 #1126 - Fixed generics declaration in RepresentationModelAssemblerSupport.
We constrained the RepresentationModel type parameter in a way that non of the RepresentationModel subclasses we provide aren't usable with it. That's now fixed by loosing that restriction to an arbitrary type.
2019-11-22 12:02:26 +01:00
Oliver Drotbohm
5cccb80143 #1124 - Shortcut ignored property lookups to prevent NullPointerExceptions. 2019-11-18 21:01:06 +01:00
Oliver Drotbohm
52a7f45bf2 #1123 - Polishing.
Removed unnecessary log output from integration tests.
2019-11-18 20:59:55 +01:00
Oliver Drotbohm
d59f336547 #1123 - Switch to ConcurrentReferenceHashMap to cache UriTemplate instances.
We now use Spring's ConcurrentReferenceHashMap to keep instances of UriTemplate cached but at the same time allow the cache entries to be garbage collected if necessary.
2019-11-18 20:59:43 +01:00
Greg Turnquist
474eeeec47 #1112 - Continue development on 1.0.2.BUILD-SNAPSHOT. 2019-11-03 11:05:45 -06:00
Greg Turnquist
1e429ee3b6 #1112 - Releasing Spring HATEOAS 1.0.1.RELEASE. 2019-11-03 11:05:40 -06:00
Greg Turnquist
7f3987136f #1111 - Add 1.0.1.RELEASE to changelog.txt. 2019-11-03 10:53:01 -06:00
Greg Turnquist
a6647dccbc #1110 - Upgrade to Reactor Dysprosium-SR1. 2019-11-03 10:23:50 -06:00
Greg Turnquist
8b813e794a #1108 - Upgrade to Spring Framework 5.2.1.RELEASE. 2019-11-03 10:17:54 -06:00
Oliver Drotbohm
b9058bffe3 #1104 - Add migration for ResourceAssemblerSupport -> RepresentationModelAssemblerSupport.
Backport of #1103.
2019-10-25 09:02:36 +02:00
Greg Turnquist
befbd6b5b2 #1098 - Institute checks for client-only setups.
Gather client- and server-side settings into one "stack". Move all logic of checking this into the enum itself.

Backported to 1.0.x.
2019-10-24 14:41:55 -05:00
luvarqpp
b9743eb9a4 #1101 - Migrate HAL_JSON_UTF8 to HAL_JSON.
org.springframework.hateoas.MediaTypes.HAL_JSON_UTF8 value was removed and only HAL_JSON is present. UTF8 is considered as default encoding for application/hal+json type.

Backported to 1.0.x.
2019-10-23 16:31:22 -05:00
Greg Turnquist
c703414d22 #1100 - Update CI to use JDK 13 for edge testing.
Backported to 1.0.x.
2019-10-23 12:44:55 -05:00
Martin Otten
552adbd0fd #1097 - Polishing some grammatical and spelling errors.
Backported to 1.0.x.
2019-10-21 08:49:50 -05:00
luvarqpp
c85a627071 #1091 - Polishing.
Fixed single char typo

Backported to 1.0.x.
2019-09-30 10:16:05 -05:00
Greg Turnquist
7910989858 #1090 - Polishing. 2019-09-30 09:13:07 -05:00
Greg Turnquist
e15f9c245f #1090 - Create 1.0.x branch. 2019-09-30 09:09:01 -05:00