Commit Graph

18 Commits

Author SHA1 Message Date
Ben Hale
3a7acf29d7 DATACMNS-388 - Improve declaration of PagedResourceAssembler in JavaConfig.
Based on the discussion in SPR-11004 [0], the declaration of the PagedResourcesAssembler in HateoasAwareSpringDataWebConfiguration will not result in it being autowired using Spring 4.0 in certain circumstances.  This change loosens the declaration so that it can be autowired into declarations that have specific generics declarations.

Original pull request: #51.

[1]: https://jira.springsource.org/browse/SPR-11004
2013-10-27 16:49:50 +01:00
Oliver Gierke
93b2d39cf1 DATACMNS-377 - Prevent page sizes less than one.
PageRequest now actively prevents page sizes less than one. PageableHandlerMethodArgumentResolver falls back to default page size if it detects a page size less than one. It also rejects invalid default configuration using @PageableDefault.
2013-10-07 10:47:25 +02:00
Nick Williams
eb4b801dc9 DATACMNS-353 - Make Spring HATEOAS purely optional.
Extracted the implementation of UriComponentsContributor from PageableHandlerMethoArgumentResolver and SortHandlerMethodArgumentResolver into dedicated subclasses so that we can really make Spring HATEOAS an optional dependency.

The integration tests are now guarded with an assumption to run on Spring 3.2 as Spring 3.1 has issues with JavaConfig and configuration method overrides. We've upgraded to Spring Data Build 1.2 snapshots so that the tests can be run with -Pspring32. This effectively means that the Spring Data Web support can only be used with a current Spring 3.2. Added a note on that in the reference docs and JavaDoc of @EnableSpringDataWebSupport.

Original pull request: #39.
2013-08-22 08:14:58 +02:00
Thomas Darimont
7b5bdd45e6 DATACMNS-304 - JavaDoc fix for PageableArgumentResolver.
The deprecation hint in PageableArgumentResolver now points to PageableHandlerMethodArgumentResolver.

Original pull request: #38.
2013-08-12 09:30:32 +02:00
Oliver Gierke
59a8cd5566 DATACMNS-352 - Aligned setter names for argument resolvers for Pageable and Sort.
PageableHandlerMethodArgumentResolver and SortHandlerMethodArgumentResolver now consistently use set*ParameterName(…) and setQualifierDelimiter(…) for configuration.

Added some more unit tests to verify invalid configuration get rejected.
2013-08-08 12:52:11 +02:00
Thomas Darimont
a63a2bbd75 DATACMNS-351 - Add setFallbackSort(…) to SortHandlerMethodArgumentResolver.
SortHandlerMethodArgumentResolver now has a setFallbackSort(…) to be able to configure the Sort instance to be used if nothing can be resolved from the request and sort default is configured on the controller method.

Renamed name of getDefaults(…) method in SortHandlerMethodArgumentResolver to getDefaultFromAnnotationOrFallback(…) and refactored implementation to be more understandable.

Original pull request: #36
2013-08-07 12:29:05 +02:00
Oliver Gierke
8a02b4ad6e DATACMNS-343 - PageableHandlerMethodArgumentResolver replaces pagination parameters now.
PageableHandlerMethodArgumentResolver now uses replaceQueryParam(…) to make sure the query parameters necessary for pagination don't accidentally get added multiple times.
2013-07-12 12:53:14 +02:00
Oliver Gierke
3f41810b86 DATACMNS-336 - Config classes backing @EnableSpringDataWebSupport are now public. 2013-06-10 14:12:42 +02:00
Oliver Gierke
15c4e34716 DATACMNS-335 - PageableHandlerMethodArgumentResolver now has configurable max page size.
The default is set to 2000.
2013-06-10 14:11:26 +02:00
Oliver Gierke
73b9d60be5 DATACMNS-330, DATACMNS-331 - More improvements on web configuration.
Reverting the registration of the DomainClassConverter as a Spring bean an prefer direct registration against the FormatterRegistry handed into addFormatters(…) of WebMvcConvfigurerAdapter. Otherwise we run into CGLib issues while enhancing the config classes.
2013-05-22 10:18:26 +02:00
Oliver Gierke
16c3c15204 DATACMNS-330, DATACMNS-331 - Improved web configuration support.
Updated backing implementation of @EnableSpringDataWebSupport to use WebMvcConfigurerAdapter instead of WebMvcConfigurationSupport as the latter is a very custom beast in terms of configuration. Let the Spring HATEOAS specific configuration class extend the default one to register additional components. The default one accesses the FormattingConversionService through a qualified autowiring. It issues a warning in case none has been configured and asks the user to enable Spring MVC.

Updated Sonargraph architecture description to allow logging from web config layer.
2013-05-21 17:10:13 +02:00
Oliver Gierke
a93c2bff94 DATACMNS-330, DATACMNS-331 - Advanced web integration.
Added PagedResourcesAssembler to easily convert Page instances into a PagedResource instance and automatically build the required previous/next links based on the PageableHandlerMethodArgumentResolver present in the MVC configuration. The assembler can either be injected into a Spring MVC controller or a controller method. The latter will then assume the controller methods URI to be used as pagination link base.

Added @EnableSpringDataWebSupport to automatically register HandlerMethodArgumentResolvers for Pageable and Sort as well as a DomainClassConverter that will allow the usage of domain types being managed by Spring Data repositories in controller method signatures. In case Spring HATEOAS is present on the classpath, we'll also register a PagedResourcesAssembler for injection as well as the appropriate HandlerMethodArgumentResolver for injection into controller methods.

Adapted Sonargraph configuration accordingly. Upgraded to Spring HATEOAS 0.6.0.BUILD-SNAPSHOT.
2013-05-15 16:03:46 +02:00
Emanuele Blanco
602834f86a DATACMNS-328 - Fixed "fallbackPageable" typo in PageableArgumentResolver.
Pull request: #28.
2013-05-14 16:21:45 +02:00
Oliver Gierke
8a67259aef DATACMNS-236 - Fixed potential NPEs in SortHandlerMethodArgumentResolver. 2013-04-18 12:15:36 +02:00
Oliver Gierke
645a605f58 DATACMNS-304 - Fixed compile error on JDK6.
Changed variable declaration in PageableHandlerMethodArgumentResolver from int to Integer to satisfy JDK6 generics resolution.
2013-03-03 15:28:09 +01:00
Oliver Gierke
e11efede4d DATACMNS-236, DATACMNS-117 - Added (Pageable|Sort)HanderMethodArgumentResolvers.
Added HandlerMethodArgumentResolver implementations for Pageable and Sort exposing a new default set of properties (page, size, sort) to resolve pagination and sorting information from the request. To mimic the legacy behavior we expose a (deprecated) LEGACY constant in PageableHandlerMethodArgumentResolver. Clients should move to the new properties structure ASAP. Added unit tests to verify old and new defaulting behavior.

Introduced new annotations @SortDefault (with @SortDefaults wrapper annotation) and @PageableDefault (superseding the legacy @PageableDefaults). The new annotations have more speaking attribute names and the HMAR implementations transparently alias the generic value attribute into a more semantic one (size).

The HMAR implementations implement Spring HATEOAS' UriComponentsContributor to be able to turn Pageable / Sort instances back into URIs created through the MethodLinkBuilderFactory API in Spring HATEOAS.

Extracted common API between legacy PageableArgumentResolver and PageableHandlerMethodArgumentResolver into common helper class.
Upgraded to Spring Hateoas 0.5.0.BUILD-SNAPSHOT.
2013-02-19 13:09:40 +01:00
Oliver Gierke
e093aead13 DATACMNS-117 - Added PageableHandlerArgumentResolver.
Added PageableHandlerArgumentResolver to supersede the now deprecated PageableArgumentResolver. The latter still stays available for Spring 3.0.x based deployments. Updated reference documentation to mention the newly introduced type as well as possible configuration options.
2013-02-12 17:35:15 +01:00
Oliver Gierke
ac256f9921 DATACMNS-266 - Use new common Maven build infrastructure.
Simplified project setup to be a single module build again. Using Spring Data Build parent POM to simplify project setup. See https://github.com/SpringSource/spring-data-build#spring-data-build-infrastructure
2013-01-16 15:15:24 +01:00