Commit Graph

18 Commits

Author SHA1 Message Date
Oliver Gierke
1efb5a53bf #310 - Added missing package-info.java files. 2015-02-27 15:03:27 +01:00
Oliver Gierke
313afe1cc7 #293 - HypermediaSupportBeanDefinitionRegistrar also augments RestTemplates.
We now also augment HttpMessageConverters for RestTemplate Spring beans.
2015-02-10 14:13:29 +01:00
Oliver Gierke
5882fcf0d6 #219 - HAL setup now registers a more strict HttpMessageConverter.
Previously we registered a special HttpMessageConverter with a custom ObjectMapper to deploy the HAL customizations. That converter was added to Spring MVC registered HandlerAdapters and registered as the first converter.

In case Spring MVC handled a request with Accept header */* or no Accept header at all, this meant that this converter kicked in and served HAL even for objects that don't need the customizations.

We now restrict the applicability of that special HttpMessageConverter to subtypes of ResourceSupport so that it will only be chosen if the object to render is of such type.
2014-07-25 10:24:30 +02:00
Oliver Gierke
d4d788d9e0 #205 - Jackson2ModuleRegisteringBeanPostProcessor now looks up dependent beans lazily.
We now only lookup the beans, Jackson2ModuleRegisteringBeanPostProcessor needs to post-process other beans if the post-processing is really needed. This avoids premature initialization of those dependent beans.
2014-06-24 16:09:21 +02:00
Oliver Gierke
8436e9ed4e #165 - Removed support for Jackson 1.x. 2014-03-21 17:45:58 +01:00
Oliver Gierke
20befe9a58 #134 - Fixed initialization of HttpMessageConverters for HAL.
The Jackson(2)ModuleRegisteringBeanPostProcessor now uses postProcess*Before*Initialization to make sure, afterPropertiesSet() has not been called on the target components which might have propagated the original HttpMessageConverters into other internal components.

With this fix, adding the HttpMessageConverter for HAL is added before the call and thus will be propagated to downstream components.
2014-03-19 14:16:34 +01:00
Oliver Gierke
dfa30398b6 #130 - Removed @Inherited annotation from @EnableHypermediaSupport. 2013-12-20 18:59:27 +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
Oliver Gierke
6acf17e730 #47, #60 - Added RelProvider implementation pluralizing using the Evo Inflector algorithm.
See http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html for details of the algorithm.
2013-04-29 12:18:54 +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
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
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
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
87537a4def #32 - @EnableEntityLinks is now inherited and documented. 2012-12-19 14:32:06 +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