-
Notifications
You must be signed in to change notification settings - Fork 474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 36: Collection handling and deserializers for JSON-HAL #47
Conversation
according to hal collections are supposed to be serialized as _embedded with a topical relation (see https://groups.google.com/forum/?fromgroups=#!topic/hal-discuss/bCzydTlHB3M )
need to find a way to handle "optional" relation property in hal
some more tests and they should be ready
} | ||
|
||
// save the relation in case the link does not contain it | ||
relation = jp.getText(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the effect here? You store the value but then don't use it going forward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in json hal the relation does not have to be in the link so the original idea was to set it on the read link.
but currently Link is basicly imutable. i wanted to open an issue to discuss that. thanks for reminding me.
Immutable types are a virtue, not a bug :). We can get that sorted out, I think. You could simply create a new interface RelProvider {
String getSingleResourceRel(Class<?> type);
String getCollectionResourceRel(Class<?> type);
} If the serializer implementations are injection aware (accepting such a I've quickly tried to adapt your code accordingly but it seems that by default the ( So what if we were be able to provide a |
unfortunately getting spring managed beans (or any pre created instance) into jackson is a pain. I'll try to go the way with a custom handler instantiator (it works, but is a bit buggy right now). As fallback I might use a class level annotation. something like |
I don't think we need to rely on direct Spring DI into the (de)serializers. Assume you get the I've started work on a general |
An annotation based |
not totally. Jackson checks if a The blog post you mentioned created a I would suggest two |
Feel free to go ahead. I think you're more into Jackson than I am. We can discuss stuff then. Just wanted to make sure we think (and implement) in the same direction ;). |
configuration possibility by using handler instantiators.
added relation resolution on a "by object" base. resolvers have to be configured on the handler instatiators (nested inside the module). The module can't do this as it has no access to the real objectmapper. |
greater reusability to for example annotate methods or properties
I've tried to rebase the changes onto current master but failed unfotunately. I got an initial set of your work working again in the In the worst case, simply remove the HAL modules in the current codebase, take f5a6441 and build your latest version of that on top of that. I'll have a look at that then… |
Reverter RelProvider API to work with classes instead of objects so that it becomes general purpose again. Moved Resource extraction logic into helper class. Polished AnnotationRelProvider (added annotation caching), added DefaultRelProvider to simply default to the simply class name and corrected ControllerRelProvider to lookup relation types from Controller classes. Added DelegatingRelProvider to delegate to RelProvider implementations in a PluginRegistry. Added BeanDefinition setup to HypermediaSupportBeanDefinitionRegistrar to setup a PluginRegistry of RelProviders and the wrapping DelegatingRelProvider to become the primary auto wiring candidate. 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 - Add RelProvider implementation based on the Evo inflector to build plurals (http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html)
…ector algorithm. See http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html for details of the algorithm.
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.
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
… Inflector algorithm. See http://www.csse.monash.edu.au/~damian/papers/HTML/Plurals.html for details of the algorithm.
According to the spec and the mailing list, collections of resources are supposed to be serialized in the "_embedded" property with relations.
This pull request does the following:
A piece of Information about the deserializers: currently the only way for a deserializer to figure out the content type of a Resources instance is by evaluating the Jackson BeanProperty. This type resolution is not perfect as it does not handle other available sources of Type information (Jackson annotations on interfaces for example)
See: FasterXML/jackson-databind#165
Should fix #36