Commit Graph

26 Commits

Author SHA1 Message Date
Oliver Gierke
8d5424a6db #305 - Dependency upgrades.
Spring Framework 3.2.9 -> 3.2.13
Jackson 2.4.1 -> 2.4.3
JSONPath 0.9.1 -> 1.2.0
Slf4j 1.7.7 -> 1.7.10
Evo Inflector 1.2 -> 1.2.1

Adapted HalLinkDiscoverer to stricter checking of JSONPath expression.
2015-02-26 15:08:05 +01:00
Oliver Gierke
a90e2f32c3 #286 - EmbeddedWrappers now allows empty collections if a rel or type is provided.
EmbeddedWrappers.wrap(Object, String) now allows empty collections. Also a new emptyCollectionOfType(Class<?>) was introduced to allow the RelProvider kick in and dynamically resolve the lazily.

Added more details to the JavaDoc of EmbeddedWrapper to make clear that we either expect a static rel returned or a type to resolve the rel from. Make HalEmbeddedBuilder detect invalid implementations and reject them although that should never occur if users use EmbeddedWrappers factory.
2015-02-10 14:49:43 +01:00
Jeff Stano
3ca6fa5504 #229 - Added support for curies in HalEmbeddedBuilder.
HalEmbeddedBuilder now takes an optional CurieProvider to create namespaced rels for embeddededs.

Original pull request: #233.
2014-12-02 09:20:49 +01:00
Oliver Gierke
0b4b3c1ad9 #199 - Refactorings in HalEmbeddedBuilder.
We now provide a dedicated EmbeddedWrappers API that HalEmbeddedBuilder uses to transparently handle the collection enforcement etc. It also allow manually hand in EmbeddedWrapper instances to enforce a certain behavior independent of the global settings in HalEmbeddedBuilder.

Simplified HalResourcesSerializer in Jackson2Hal module as we now don't have to deploy custom serializers for the embedded elements anymore.

Supersedes some of the API introduced for #195.
2014-06-12 10:46:30 +02:00
Oliver Gierke
20bfa86c5f #195 - HalEmbeddedBuilder now considers RelAware on objects added.
This change introduces a RelAware interface for objects to implement which want to enforce a particular rel to be used in the _embedded clause. This is useful if the objects being added are not categorized by type but rather by their role in the context of the main object.
2014-06-10 10:46:46 +02:00
Oliver Gierke
8436e9ed4e #165 - Removed support for Jackson 1.x. 2014-03-21 17:45:58 +01:00
Oliver Gierke
ec41d78828 #158 - HalEmbeddedBuilder now uses AopUtils.getTargetClass().
To correctly resolve the rel for a proxied class we need to build up relation types for, HalEmbeddedBuilder now uses Spring's AopUtils.getTargetClass(), which will use the object's getTargetClass() method in case it implements TargetClassAware.
2014-02-27 07:50:26 +01:00
Oliver Gierke
bb0a578701 #135 - HAL embedded resources are now rendered as collection by default.
To get consistent representations rendered for single-item collections and multi-item collections, we now use an enforceEmbeddedCollections flag in the Jackson 2 HAL module. Adapted HalEmbeddedBuilder to respect that setting and exposed it via the HandlerInstantiator for user level customization.

Changed RelProvider.getSingleResourceRel(…) to getItemResourceRel(…).
2014-01-24 14:52:57 +01:00
Oliver Gierke
c790a5d834 #137 - Changed Link.isTempalte() to isTemplated(). 2014-01-23 11:46:08 +01:00
Oliver Gierke
719a4b3af3 #142, #137 - CurieProvider can now return multiple curies.
Changed `getCurieInformation(…)` to receive a `Links` instance with the previously added links and is forced to return a collection of curies so that multiple ones can be resolved transparently.

Made Curie value class protected to be able to reuse it from extensions of DefaultCurieProvider. Switched to the custom HATEOAS UriTemplate instance instead of the standard Spring MVC one.

Polished JavaDoc of DefaultCurieProvider. Removed some of the deprecation warnings that were introduced by the upgrade to Jackson 2.3. Polished (read: reactivated) some test cases and slightly changed the internals of UriTemplate works. Added TemplateVariables.asList().
2014-01-21 14:25:43 +01:00
Oliver Gierke
6e9caf2556 #137 - Merged Link and LinkTemplate.
Link now exposes additional methods like isTemplate(), getTemplateVariables() and expand(…).
2014-01-19 18:38:53 +01:00
Oliver Gierke
83743d80a2 #137 - Initial support for link templates.
Added LinkTemplate domain type that can deal with URI templates as defined in http://tools.ietf.org/html/rfc6570. We currently support /, ?, & and # variables up to level 3 of the spec (multiple parameter definitions). The templates can be expanded to a Link instance.

Added the necessary HAL mixins to render the instances as specified.
2014-01-15 17:04:57 +01:00
Oliver Gierke
bc68707e73 #125 - Prevent curies from being rendered if no link is curied. 2013-12-29 16:20:03 +01:00
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