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
2018-01-03 14:10:06 -06:00
2019-09-05 10:31:04 -05:00
2018-12-14 11:02:48 -06:00
2019-03-21 16:32:51 +01:00
2019-03-22 17:32:52 +01:00
2019-03-08 09:32:07 -06:00
2019-03-08 09:32:07 -06:00
2019-09-30 09:13:07 -05:00

image:https://spring.io/badges/spring-hateoas/ga.svg[link=https://spring.io/projects/spring-hateoas]
image:https://spring.io/badges/spring-hateoas/snapshot.svg[link=https://spring.io/projects/spring-hateoas]
image:https://badges.gitter.im/spring-projects/spring-hateoas.png[link=https://gitter.im/spring-projects/spring-hateoas]

image:https://jenkins.spring.io/buildStatus/icon?job=spring-hateoas%2Fmaster&subject=master[link=https://jenkins.spring.io/view/SpringHATEOAS/job/spring-hateoas/]
image:https://jenkins.spring.io/buildStatus/icon?job=spring-hateoas%2F1.0.x&subject=1.0.x[link=https://jenkins.spring.io/view/SpringHATEOAS/job/spring-hateoas/]
image:https://jenkins.spring.io/buildStatus/icon?job=spring-hateoas%2F0.25.x&subject=0.25.x[link=https://jenkins.spring.io/view/SpringHATEOAS/job/spring-hateoas/]


= Spring HATEOAS

This project provides some APIs to ease creating REST representations that follow the https://en.wikipedia.org/wiki/HATEOAS[HATEOAS] principle when working with Spring and especially Spring MVC. The core problem it tries to address is link creation and representation assembly.

== Working with Spring HATEOAS

Since all commits are headlined with its github issue, git will treat it as a comment. To get around this, apply the following configuration to your clone:

[source]
----
git config core.commentchar "/"
----

== Making a release

1. Create a new release (on the main branch).
+
----
% ci/create-release.sh <release version> <next snapshot version>
----
+
2. With the release tagged, push the tagged version to the release-1.0.x branch.
+
----
% git checkout -b release-1.0.x
% git reset --hard <tag>
% git push -f origin release-1.0.x
----

NOTE: You can chain the previous set of commands together using `&&`.

The pipeline will build and release the "release-1.0.x" branch. It will also build a new a new snapshot and stage it on artifactory.
And if it's a `.RELEASE`, the pipeline will push it out to Maven Central.

=== Running CI tasks locally

Since the pipeline uses Docker, it's easy to:

* Debug what went wrong on your local machine.
* Test out a a tweak to your `test.sh` script before sending it out.
* Experiment against a new image before submitting your pull request.

All of these use cases are great reasons to essentially run what Jenkins does on your local machine.

IMPORTANT: To do this you must have Docker installed on your machine.

1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-hateoas-github adoptopenjdk/openjdk8:latest /bin/bash`
+
This will launch the Docker image and mount your source code at `spring-hateoas-github`.
+
2. `cd spring-hateoas-github`
+
Next, run the `test.sh` script from inside the container:
+
2. `PROFILE=none ci/test.sh`

Since the container is binding to your source, you can make edits from your IDE and continue to run build jobs.

If you need to test the `build.sh` script, then do this:

1. `docker run -it --mount type=bind,source="$(pwd)",target=/spring-hateoas-github --mount type=bind,source="/tmp/spring-hateoas-artifactory",target=/spring-hateoas-artifactory adoptopenjdk/openjdk8:latest /bin/bash`
+
This will launch the Docker image and mount your source code at `spring-hateoas-github` and the temporary
artifactory output directory at `spring-hateoas-artifactory`.
+
Next, run the `build.sh` script from inside the container:
+
2. `ci/build.sh`

IMPORTANT: `build.sh` will attempt to push to Artifactory. If you don't supply credentials, it will fail.

NOTE: Docker containers can eat up disk space fast! From time to time, run `docker system prune` to clean out old images.

== Resources

* https://spring.io/projects/spring-hateoas#learn[Reference documentation]
* https://spring.io/guides/gs/rest-hateoas/[Getting started guide]
Description
No description provided
Readme Apache-2.0 7.6 MiB
Languages
Java 99.5%
Shell 0.5%