Commit Graph

696 Commits

Author SHA1 Message Date
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
Greg Turnquist
f0c2019f75 #1090 - Polishing. 2019-09-30 08:52:10 -05:00
Greg Turnquist
2357d8e143 #1090 - Test against Spring Framework 5.2.1 snapshots. 2019-09-30 08:33:25 -05:00
Greg Turnquist
9199bb9950 #1090 - Continue development on 1.0.1.BUILD-SNAPSHOT. 2019-09-30 08:31:03 -05:00
Greg Turnquist
5408014b3c #1090 - Releasing Spring HATEOAS 1.0.0.RELEASE. 2019-09-30 08:30:59 -05:00
Greg Turnquist
688315905d #1090 - Update CHANGELOG. 2019-09-30 08:11:48 -05:00
Greg Turnquist
e332b1b7c0 #1079 - Upgrade to Spring Framework 5.2.0.RELEASE. 2019-09-30 08:08:35 -05:00
Greg Turnquist
0e7bafc9c1 #1085 - Upgrade to Spring Plugin 2.0.0.RELEASE. 2019-09-30 08:07:03 -05:00
Oliver Drotbohm
507f7de0c3 #1075 - Explicitly use classpath protocol for base names of MessageResolver resource bundles.
We now explicitly equip the resource bundle base name with a "classpath:" prefix so that the resource lookup also works in Boot web applications in which the ResourceLoader setup is tweaked to prefer ServletContext resources.
2019-09-26 16:54:19 +02:00
Greg Turnquist
f15740fb25 #1038 - Update documentation and testing for ALPS.
Also make the ALPS types support deserialization using @JsonCreator-based private constructor calls.
2019-09-26 09:28:45 -05:00
Oliver Drotbohm
30ddf1873c #1080 - Improved configuration setup and documentation on EntityLinks.
We now explicitly only enable EntityLinks in WebMVC environments. This is also now reflected properly in the reference documentation.
2019-09-26 15:21:35 +02:00
Oliver Drotbohm
26a0dd8794 #1088 - Upgrade to Jackson 2.10 GA. 2019-09-26 14:40:54 +02:00
Oliver Drotbohm
d88a995ba8 #1089 - Upgrade to Reactor Dysprosium GA. 2019-09-25 10:16:13 +02:00
Oliver Drotbohm
c7065cacde #1088 - Upgrade to Jackson 2.10 preview 3. 2019-09-24 10:37:26 +02:00
Oliver Drotbohm
dbf1ee88f3 #1086 - Upgrade to Jackson BOM 2.9.9.20190807. 2019-09-23 14:54:20 +02:00
Oliver Drotbohm
3e805b0c30 #1085 - Upgrade to Spring Plugin 2.0 snapshots. 2019-09-23 14:54:06 +02:00
Colin Young
04d295abfe #1028 - Fix example in docs to reflect requirement for _prompt for property I18N. 2019-09-23 13:13:52 +02:00