Commit Graph

73 Commits

Author SHA1 Message Date
Alexander Bätz
47b50266b8 #47, #60 - First draft on extended HAL integration.
Collections are now rendered as _embedded in combination with a topic relation (https://groups.google.com/forum/?fromgroups=#!topic/hal-discuss/bCzydTlHB3M
). Adapted deserializers accordingly.
2013-04-29 12:17:41 +02:00
Oliver Gierke
1d1d959143 #47, #60 - Added provider interface for relation types by entity type. 2013-04-29 12:17:16 +02:00
Oliver Gierke
27e43f4a2a #47 - Fixed pom formatting. 2013-04-29 11:56:27 +02:00
Oliver Gierke
2c49f397da #56 - LinkBuilderSupport.slash(…) now handles fragments correctly. 2013-03-08 17:49:45 +01:00
Oliver Gierke
db4f96a4e0 #29 - Fixed obsolete inline rendering of rel in HAL links. 2013-03-06 18:39:47 +01:00
Oliver Gierke
6bc906971a #26, #39 - Fixed potential transitive assertion error in UrComponentsBuilder.
If a String piped into LinkBuilderSupport.slash(…) is empty, the call to UriComponentsBuilder.fromUriString(…) fails with an assertion exception. We now guard against this specific case by returning the current builder instance in case an empty String (potentially returned from the toString() method of the object handed in) would be handed to the UriComponentsBuilder.

The issue was introduced by commit 84efebc7a6.
2013-03-04 16:04:19 +01:00
Oliver Gierke
f568845146 #52 - ControllerLinkBuilder builds absolute URIs again.
Commit 8039c306e9 introduced a glitch in ControllerLinkBuilderFactory that caused URIs created not being absolute ones anymore. This commit fixes that glitch.
2013-03-01 12:20:11 +01:00
Oliver Gierke
0db1916dde #50 - Add HAL JSON Module to handler adapters.
In case no ObjectMapper bean has been configured explicitly, the Spring MVC infrastructure registers HttpMessageConverters directly and does not declare them as Spring beans. Thus we now also inspect RequestMappingHandlerAdapter and AnnotationMethodHandlerAdapter instances for their HttpMessageConverters and transparently augment the ObjectMappers backing potentially registered Jackson converters.
2013-02-28 22:50:07 +01:00
Oliver Gierke
8aad5cf83b #50 - Only register LinkDiscoverer if JsonPath is on the classpath. 2013-02-28 22:47:18 +01:00
Oliver Gierke
84efebc7a6 #26, #39 - Added support for request parameters to ControllerLinkBuilder.
We now transparently handle "?foo=bar" expressions passed into ….slash(…). Added method to return UriComponentsBuilder to allow more fine grained control over the URI to be built if needed. The dummy method invocations handled to ….linkTo(…) now transparently adds the values handed in for parameters annotated with @RequestParam.

Most of the commit is highly inspired by Dietrich Schultens work at [0]. I just reworked and polished it slightly as we had too many merge conflicts due to related changes in the meantime.

[0] 1ebdc9025a
2013-02-23 22:34:21 +01:00
Oliver Gierke
d152bcb7d1 #54 - Added support for RFC5988 link headers.
Introduced new Links container element to group a list of links and allow parsing an RFC5988 compatible String representation of links into it. The parsing mechanism is currently regarding the rel attribute only.

Added valueOf(…) factory methods to allow Spring MVC to pick the types up out of the box.
2013-02-20 14:44:08 +01:00
Oliver Gierke
3976ae168b #50 - Added @EnableHypermediaSupport annotation.
The annotation registers supporting application components as Spring beans based on the configured hypermedia type. Currently supported are the default rendering as well as HAL. We register a matching LinkDiscoverer implementation as well as the appropriate Jackson modules (if present on the classpath) to support HAL.

Upgraded to Spring 3.1.4 to benefit from fix to prevent multiple invocations of ImportBeanDefinitionRegistrars (see SPR-9939 / SPR-9925).
2013-02-18 19:30:51 +01:00
Oliver Gierke
35ad18839e #53 - Set up Slf4j logging and excluded Commons Logging. 2013-02-18 19:30:01 +01:00
Oliver Gierke
8039c306e9 #52 - Introduced UriComponentsContributor SPI.
Introduced UriComponentsContributor interface to allow components to enhance the UriComponentsBuilder used while building links point in to controller methods.

Moved logic from ControllerLinkBuilder into ControllerLinkBuilderFactory as we now potentially need access to Spring injected components. Might be necessary to get rid of the static LinkBuilder implementations entirely.
2013-02-18 19:14:35 +01:00
Oliver Gierke
72837210ee #51 - Added HalLinkDiscoverer.
Added LinkDiscoverer implementation that discovers Links from HAL style representations. Extracted AbstractLinkDiscovererUnitTest to define expected behavior for LinkDiscoverers in general.
2013-02-15 11:25:45 +01:00
Alexander Chilingaryan
29b433445c #46 - AnnotationMappingDiscoverer now deals with missing method mapping.
If a method level @RequestMapping is not carrying a value we now fall back to the type level mapping as Spring MVC does. Before the fix, providing no mapping lead to an ArrayIndexOutOfBoundsException.
2013-02-14 18:10:42 +01:00
Ansgar Konermann
1bd90991bd #48 - Set source encoding to UTF-8 explicitly. 2013-02-14 17:53:04 +01:00
Spring Buildmaster
8c78b30a92 #19 - Prepare next development iteration. 2013-01-28 06:48:13 -08:00
Spring Buildmaster
7c34e9bc98 #19 - Release version 0.4.0.RELEASE. 2013-01-28 06:48:11 -08:00
Oliver Gierke
bea4fa803a #19 - Updated changelog. 2013-01-28 13:49:26 +01:00
Oliver Gierke
6371c1d7e7 Upgrade to Spring Plugin 0.8.0.RELEASE. 2013-01-28 13:38:48 +01:00
Oliver Gierke
0bd6657dd5 #43 - Improved contract in ControllerEntityLinks.
Fixed StackOverflowError in ControllerEntityLinks by delegating to the proper methods now. Clarified contract in EntityLinks interface. Added further unit tests to make sure the implementation behaves like the interface specifies.

Fixes #43.
2013-01-23 16:27:29 +01:00
Alex Coyle
6b7256edad #41, #42 - Allow ResourceAssemberSupport to be used without Identifiable.
Extracted Identifiable related code into an IdentifiableResourceAssemblerSupport to be able to use ResourceAssemblerSupport without the need of the domain object to implement Identifiable.
2013-01-22 14:09:26 +01:00
Oliver Gierke
3f8b90e2b5 #33 - ControllerLinkBuilder now regards X-Forwarded-Host header.
When setting up the builder we now set the host to the value held in the X-Forwarded-Host [0] header if present. This allows to render appropriate URIs in reverse proxy scenarios. This is essentially an extension of ServletUriComponentsBuilder that will be fixed in there eventually. See SPR-10110 [1] for details.

[0] http://tools.ietf.org/html/draft-ietf-appsawg-http-forwarded-10
[1] https://jira.springsource.org/browse/SPR-10110
2012-12-19 17:34:47 +01:00
Oliver Gierke
25f68fa208 Polished EntityLinks documentation (previously non-existent). 2012-12-19 14:38:56 +01:00
Oliver Gierke
87537a4def #32 - @EnableEntityLinks is now inherited and documented. 2012-12-19 14:32:06 +01:00
Oliver Gierke
531dd8f5ed #18 - Added support for creating links from method mappings.
ControllerLinkBuilder(Factory) now has a linkTo(Method method, Object… parameters) and linkTo(Object dummyMethodInvocationResult) method to either inspect the given method or the result of the dummy method invocation that can be created through DummyInvocationUtils.methodOn(…). So for the following controller:

@Controller
@RequestMapping("/people")
class PersonController {
  
  @RequestMapping(value = "/{person}", method = RequestMethod.GET)
  public HttpEntity<PersonResource> show(@PathVariable Long person) { … }
}

you could now do:

Link link = linkTo(methodOn(PersonController.class).show(2L)).withSelfRel();
assertThat(link.getHref(), is("/people/2")));

The code is highly inspired by the code Dietrich Schulten (@dschulten) provided in his pull requests but radically reduced to the core functionality. I also didn't add support for JAX-RS in the first place, but this is definitely a topic going forward.
2012-12-19 13:10:31 +01:00
Oliver Gierke
220366b240 Method links. 2012-12-19 10:40:15 +01:00
Oliver Gierke
0e0bf16957 #31 - Introduced LinkDiscoverer to extract Link instances from representations.
LinkDiscoverer exposes an API to find Links by their relation types in representations. Added JSONPath based base class and a DefaultLinkDiscoverer that finds Links based on the default rendering of our Jackson mappings.
2012-12-15 19:07:03 +01:00
Oliver Gierke
f3ab76cfd2 #25 - Fixed typo in project description in pom.xml. 2012-12-15 19:06:35 +01:00
Alexander Bätz
7af38348a9 #29 - Added support for HAL-style representation of Links.
Added Jackson 1 and 2 modules to render Link objects in a HAL-compliant way. Introduced custom Jackson mixins to avoid introducing new value objects for the representation model. 

The rendering can be activated by simply registering Jackson1HalModule or Jackson2HalModule with the Jackson ObjectMapper.
2012-11-20 12:39:48 +01:00
Oliver Gierke
c7396c24a9 Cleaned up hashCode() method in PagedResources. 2012-11-18 18:58:07 +01:00
Oliver Gierke
a1b706c21c Added assertions based on EntityLinks interface. 2012-11-18 18:57:43 +01:00
Oliver Gierke
40b486cb43 #27 - Added support for Jackson 2.
Added Jackson 2 dependencies. Doubly annotated representation model classes with both Jackson 1 and Jackson 2 annotations. Added Integration tests for Jackson 2 marshaling provided by Jon. Polished template.mf.
2012-11-16 21:32:47 +01:00
Oliver Gierke
04be1871c3 Introduced EntityLinks abstraction.
EntityLinks allow accessing LinkBuilders or even Link instance based on components exposing REST resources for a particular domain type. The core implementation is ControllerEntityLinks that assumes a particular URI structure so that it can derive the URIs to be asked for per domain type. The domain type managed will be inspected from the @ExposesResourceFor annotation on a controller class. We provide a factory bean to allow configuring instances of ControllerEntityLinks based on a mapping annotation and LinkBuilderFactory.

Added infrastructure to activate automatic discovery of EntityLinks implementations through @EnableEntityLinks. This will automatically register ControllerEntityLinks instances for Spring MVC controllers annotated with @ExposesResourceFor as well as JAX-RS resources if JAX-RS is on the classpath. The mechanism essentially registers a DelegatingEntityLinks instance leveraging the Spring Plugin PluginRegistry mechanism to delegate to the actual EntityLinks instance actually registered for the entity type. It will become the primary EntityLinks bean in the ApplicationContext so that they can be autowired into client components safely.
2012-10-29 15:21:28 +01:00
Oliver Gierke
b8add74fc1 Improvements to LinkBuilder API.
Renamed UriComponentsLinkBuilder to LinkBuilderSupport and moved it from mvc into core package. slash(Object object) now transparently unwraps Identifiables<?>.
2012-10-29 15:02:21 +01:00
Spring Buildmaster
c4bfc8ea72 #8 - Prepare next development iteration 2012-10-09 03:41:43 -07:00
Spring Buildmaster
5a916cefc2 #8 - Release version 0.3.0.RELEASE 2012-10-09 03:41:41 -07:00
Oliver Gierke
dc36bb26fe Fixed links representation in readme.md. 2012-10-09 12:39:06 +02:00
Oliver Gierke
232abb2c72 #8 - Updated changelog for 0.3.0.RELEASE.
Added missing stuff for 0.2.0.RELEASE as well.
2012-10-09 12:36:45 +02:00
Oliver Gierke
3ace0cfc76 #10 - Upgraded to Jackson 1.9.10. 2012-10-09 12:36:14 +02:00
Oliver Gierke
e89242c9f0 #14 - Added test cases showing that de-/serialization is working. 2012-09-17 17:42:10 +02:00
Ricardo Gladwell
9e728b4660 #13 - Introduced LinkBuilder implementation inspecting JAX-RS @Path annotation.
Refactored LinkBuilder(Factory) classes to extract reusable code into common superclass for ControllerLinkBuilder and JaxRsLinkBuilder.
2012-09-13 17:42:54 +02:00
Oliver Gierke
acdb0c8a5b #11 - Revert to List for links in ResourceSupport.
The order of the links needs to be stable across different requests. Thus we have to revert to List instead of a Set.
2012-09-12 12:51:28 +02:00
Ricardo Gladwell
fc4eebd128 #12 - Introduced interfaces for LinkBuilder(Factory) to improve testability.
LinkBuilder and LinkBuilderFactory interface extracted from ControllerLinkBuilder for easier mocking and so that alternative implementations (such as for CXF) can be created.
2012-09-12 12:43:02 +02:00
Oliver Gierke
c5ee47cce4 Resources - Make returned content Collection immutable. 2012-08-30 14:19:16 +02:00
Oliver Gierke
dab25f25fc Resources - Switched from Collection to Iterable for source content. 2012-08-30 14:19:16 +02:00
Oliver Gierke
b33231ffaa Polished Javadoc of ControllerLinkBuilder. 2012-08-30 14:19:09 +02:00
Oliver Gierke
91a6e99e3f Renamed ResourceProcessor.{enrich(…) -> process(…)}. 2012-08-27 19:08:11 +02:00
Oliver Gierke
15a2092cf7 Moved back to Resource{Enricher -> Processor} to allow exchanging the Resource. 2012-08-24 21:46:17 +02:00