Commit Graph

13 Commits

Author SHA1 Message Date
Oliver Gierke
88da0672ab #125 - Polished curies in HAL and HAL rendering in general.
Both _links and _embedded are now only rendered if there's actual content to be rendered. The curies link is now always rendered as array as specified.
2013-12-28 21:02:27 +01:00
Oliver Gierke
5c737d4b53 #110 - Fixed the collection of values in HalEmbeddedBuilder.
HalEmbeddedBuilder now favors the collection rel to lookup already registered embeddeds.
2013-12-19 13:02:37 +01:00
Oliver Gierke
137e7c390f #128 - Severe refactoring regarding LinkDiscoverers.
The LinkDiscoverer interface is now a Plugin<MediaType> to allow selecting a discoverer per media type. We also provide a LinkDiscoverers wrapper around a PluginRegistry for easier injection.

Dropped DefaultLinkDiscoverer as the above mentioned changed prohibits the usage of a discoverer without a media type. Clients that previously used DefaultLinkDiscoverer should switch to JsonPathLinkDiscoverer with a custom JsonPath expression and media type.

@EnableHypermediaSupport now supports multiple HypermediaType values set to be able to set up support for multiple hypermedia formats. Admittedly, the only currently supported type is HAL but we prepare for the addition of other (e.g. Collection/JSON or the like). We changed the infrastructure setup taken care of by @EnableHypermediaSupport to not enrich all ObjectMapper instances with our HAL modules but explicitly register an ObjectMapper with the application context and then registering a custom MappingJackson(2)HttpMessageConverter with the HandlerAdapter instances present in the ApplicationContext. We skip the registration if an already registered MJ2HMC has an ObjectMapper already supporting the Spring HATEOAS mixins.

Removed some compiler warnings.
2013-12-19 13:01:35 +01:00
Oliver Gierke
9eacd07203 #126, #123 - Added support for HAL curies.
Introduced CurieProvider interface as well as a DefaultCurieProvider that can be registered as Spring Bean to enable Links being rendered in a curie namespace and an additional curie link exposing the metadata of how to lookup the rel definition.

Deprecated Jackson 1 integration. Added helper class to find out whether a relation type is defined by the IANA.
2013-12-17 11:23:30 +01:00
Eric Bottard
cb6dd51e04 #99 - HalLinkListSerializer now generate stable link lists.
We're now using a LinkedHashMap when creating link lists.
2013-07-16 17:21:58 +02:00
Oliver Gierke
4d4a43b88f #84 - Made constructor in Resource package private.
This change is to essentially prevent people from subclassing Resource and call the default constructor which wrecks the assumption of content never being null. For custom resources extend ResourceSupport.

Added missing license header in ResourcesMixin.
2013-06-12 11:01:51 +02:00
Dietrich Schulten
693faae0fe #81, #83 - Fixed potential NullPointerExceptions in HalEmbeddedBuilder. 2013-06-12 10:00:11 +02:00
Oliver Gierke
0df0f2aab8 #63 - Use collection relation types for embedded collections.
When embedding values into HAL representations we now correctly expose the collection relation type as exposed by RelProvider.getCollectionResourceRelFor(…). Added EmbeddedHalBuilder to ease building these kinds of nested maps easily and use the commonly shared code between Jackson 1 and 2 implementations.
2013-05-07 19:08:03 +02:00
Oliver Gierke
254339c3b2 #47, #60 - Implemented RelProvider registration into HAL serializers.
Added @Relation annotation to be able to define the relations that shall be exposed. The annotation can be used on domain classes or ResourceSupport subtypes to define the relations that shall be used to build links pointing to them.

Introduced RelProvider implementations that use the plain domain class name plus an appended List by default (DefaultRelProvider, fallback) as well as an AnnotationRelProvider that will inspect @Relation on the domain type. Added a DelegatingRelProvider that is based on a Spring Plugin PluginRegistry to allow adding RelProvider implementations transparently. Polished AnnotationRelProvider (added annotation caching) and corrected ControllerRelProvider to lookup relation types from Controller classes. Added BeanDefinition setup to HypermediaSupportBeanDefinitionRegistrar to setup a PluginRegistry of RelProviders and the wrapping DelegatingRelProvider to become the primary auto wiring candidate.

Moved RelProvider registration into Jackson HandlerInstantiator implementations. Made the BeanPostProcessors for Jackson ObjectMapper customization aware of the BeanFactory to lookup the DelegatingRelProvider instance to hand them into the Jackson HandlerInstantiators.

TODOs:
- More tests
- Correctly register ControllerRelProviders
2013-04-29 12:18:32 +02:00
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
db4f96a4e0 #29 - Fixed obsolete inline rendering of rel in HAL links. 2013-03-06 18:39:47 +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 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