Commit Graph

716 Commits

Author SHA1 Message Date
Oliver Drotbohm
75c8a3fbe8 #1178 - Upgrade to Jackson 2.10.2. 2020-01-15 08:14:54 +01:00
Oliver Drotbohm
d5220315e9 #1177 - Upgrade to JaCoCo 0.8.5. 2020-01-15 08:08:59 +01:00
Oliver Drotbohm
9a28e6324e #1176 - Upgrade to AssertJ 3.14. 2020-01-15 08:06:59 +01:00
Oliver Drotbohm
ebb78bdb67 #1174 - Upgrade to Spring Framework 5.2.3. 2020-01-15 08:05:35 +01:00
Oliver Drotbohm
ad3e35bdf1 #1165 - Fix for potential NullPointerException in UriTemplate.
UriTemplate.with(TemplateVariable) now properly forwards the UriBuilderFactory from the current instance.
2020-01-14 14:03:36 +01:00
Oliver Drotbohm
60cf2a828e #1116 - Revisit factory methods of RepresentationModel.
This commit introduces ….of(…) factory methods on all RepresentationModel types as well as Link. RepresentationModel.of(…) transparently creates a EntityModel or CollectionModel depending on the value handed into the method.
2020-01-14 13:46:55 +01:00
Oliver Drotbohm
37896bc244 #786 - Added documentation for HTTP Problem Details media type support. 2020-01-13 22:46:19 +01:00
Oliver Drotbohm
17644464d9 #786 - Redesign of the support for the HTTP Problem spec (RFC-7807).
Problem has been redesigned for immutability. Extensions to the payload body are now implemented by wrapping a either an object exposing the properties to add in turn or a plain Map.

Added infrastructure configuration to make sure that Problem instances returned from controller methods (even if wrapped into a ResponseEntity<?>) cause the ContentType header to be set to application/problem+json. HyperMediaMappingInformation now allows to customize the root domain type to signal serialization support for.

Few cleanups regarding the ObjectMapper setup in test cases.
2020-01-13 22:46:04 +01:00
Oliver Drotbohm
0d25b2e66e #1169 - Update copyright years to 2020. 2020-01-10 12:26:41 +01:00
Oliver Drotbohm
ffbed21254 #1166 - 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.
2020-01-06 21:56:07 +01:00
Oliver Drotbohm
ebe7038a48 #1157 - 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 10:03:21 +01:00
Oliver Drotbohm
5502bfdf85 #1159 - HalConfiguration now exposes whether to enforce arrays in embedded clauses.
The flag to control this had been directly configured on the HalHandlerInstantiator which wasn't accessible to users in the first place. Refined the setup and forwarding of the bean factory into HalHandlerInstantiator so that non-Spring-HATEOAS Jackson serializer lookups are routed through the Spring container potentially picking up prototype bean definitions.
2019-12-11 22:10:13 +01:00
Oliver Drotbohm
aef81d1e57 #1157 - 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:56:28 +01:00
Oliver Drotbohm
8cf23aa721 #1157 - 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:36:21 +01:00
Greg Turnquist
a084686156 #786 - Deprecate VndErrors and VndError. 2019-12-10 10:07:28 -06:00
Greg Turnquist
20bff3e26f #786 - Implement vendor neutral error handling with RFC-7807. 2019-12-10 10:00:23 -06:00
Greg Turnquist
4f3be119c0 #775 - Clean up VndError implementation to match spec.
* Handle single, multiple, and nested errors.
* Retain backward compatibility with existing constructors.
2019-12-10 09:56:11 -06:00
Oliver Drotbohm
6bb2310682 #1155 - 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:23:06 +01:00
Oliver Drotbohm
a2290c692a #1132 - HAL link relation rendering now applies Jackson's PropertyNamingStrategy.
The rendering of HAL's link relations now applies Jackson's PropertyNamingStrategy if one is configured except it's a IANA link relation. This behavior can be opt out from by setting HalConfiguration.withApplyPropertyNamingStrategy(false).

LinkRelation now has a ….map(…) method allowing the post-processing of it given a Function<String, String>. By default, that's applied to all relations that are not IANA ones. HalLinkRelation applies this transformation to only the local part of the relation. Tweaked IanaLinkRelations.isIanaLinkRelation(…) to do a simple ….contains(…) check first before we stream over all values to apply a case insensitive check.
2019-12-10 11:29:21 +01:00
Oliver Drotbohm
8f1f355c9f #1154 - 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:02:07 +01:00
Oliver Drotbohm
26c44dcc98 #1152 - Allow adding path segments to links created via WebFluxLinkBuilder.
WebFluxLinkBuilder now allows to call ….slash(…) in symmetry to other LinkBuilder implementations.
2019-12-09 12:10:10 +01:00
Oliver Drotbohm
8e96eafb37 #1150 - 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:10:07 +01:00
Oliver Drotbohm
f6e2b3b3b4 #1147 - Polishing.
Some cleanups in test cases.
2019-12-09 09:38:42 +01:00
Oliver Drotbohm
7744bda4b1 #1147 - 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 09:38:19 +01:00
Oliver Drotbohm
452189edd8 #1148 - 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-06 14:27:27 +01:00
Greg Turnquist
9f05bea8ab #1138 - Polishing. 2019-12-03 09:03:33 -06:00
Oliver Drotbohm
8befce38e4 #1134 - 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:33:51 +01:00
Oliver Drotbohm
86ad689f5d #1138 - Upgrade to Spring Framework 5.2.2 release. 2019-12-03 14:11:30 +01:00
Oliver Drotbohm
3127c97ba9 #1134 - 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:52:47 +01:00
Oliver Drotbohm
f6a4e65006 #1138 - Upgrade to Spring Framework 5.2.2 snapshots. 2019-12-02 16:52:47 +01:00
YAN Wenkun
3d6e845509 #1133 - Fix package name vnderror to vnderrors in migration script. 2019-12-02 12:45:09 +01:00
Oliver Drotbohm
a630a43c28 #1119 - 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:58:02 +01:00
Greg Turnquist
17543fc4fa #1119 - Include WebMvcConverters in WebFluxHateoasConfiguration. 2019-12-01 22:57:55 +01:00
Oliver Drotbohm
5ae89bcb2c #593 - 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:01:16 +01:00
Oliver Drotbohm
d98e678c59 #593 - 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:00:37 +01:00
Oliver Drotbohm
d3ece765bc #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:14:57 +01:00
Oliver Drotbohm
5f016d6c9e #1119 - 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:53:12 +01:00
Oliver Drotbohm
5444e14017 #1122 - Polishing. 2019-11-22 12:00:15 +01:00
Oliver Drotbohm
3d9fe3893f #1122 - 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:00:04 +01:00
Oliver Drotbohm
aa9e449841 #1121 - Shortcut ignored property lookups to prevent NullPointerExceptions. 2019-11-18 20:53:20 +01:00
Oliver Drotbohm
fc42597091 #1118 - Polishing.
Removed unnecessary log output from integration tests.
2019-11-18 20:29:19 +01:00
Oliver Drotbohm
d0198d5ff5 #1118 - 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:27:54 +01:00
Greg Turnquist
37e1f501cf #1111 - Add 1.0.1.RELEASE to changelog.txt. 2019-11-03 10:53:21 -06:00
Greg Turnquist
667a4f4970 #1109 - Upgrade to Reactor Dysprosium-SR1. 2019-11-03 10:22:50 -06:00
Greg Turnquist
1506dfd154 #1107 - Upgrade to Spring Framework 5.2.1.RELEASE. 2019-11-03 10:16:37 -06:00
Oliver Drotbohm
4b814e8e14 #1103 - Add migration for ResourceAssemblerSupport -> RepresentationModelAssemblerSupport. 2019-10-25 09:00:52 +02:00
Greg Turnquist
cf0c606ef4 #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.
2019-10-24 14:11:17 -05:00
luvarqpp
f45aabe8ac #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.
2019-10-23 16:29:21 -05:00
Greg Turnquist
cbae7db2f1 #1100 - Update CI to use JDK 13 for edge testing. 2019-10-23 12:44:25 -05:00
Martin Otten
8c6dfc922c #1097 - Polishing some grammatical and spelling errors. 2019-10-21 08:46:32 -05:00