Skip to content

How to set custom serializer for ResourceSupport in spring #324

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

Closed
vltsu opened this issue Mar 19, 2015 · 4 comments
Closed

How to set custom serializer for ResourceSupport in spring #324

vltsu opened this issue Mar 19, 2015 · 4 comments

Comments

@vltsu
Copy link

vltsu commented Mar 19, 2015

Hello!
I have the same problem as in #288, and I wrote my own serializer to replace Jackson2HalModule.HalLinkListSerializer. But how to tell spring to use this serializer? I tried to write

public abstract class MyOwnResourceSupportMixIn extends ResourceSupport {
    @Override
    @XmlElement(name = "link")
    @JsonProperty("_links")
    @JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY, using = MyOwnSerializer.class)
}

and set

public class MixInModule extends SimpleModule {
    public MixInModule() {
        setMixInAnnotation(ResourceSupport.class, MyOwnResourceSupportMixIn.class);

and register this MixInModule in spring configuration, but it leads to stackoverflow error.

I see the mention of HalHandlerInstantiator in one of the issues, maybe I should use this method. But can you give me some example of how to use it in spring?

@vivin
Copy link

vivin commented Apr 16, 2015

@vltsu It is possible to do this. Take a look at my comment on #288. You can use the same ideas to accomplish what you are trying to do.

@vltsu
Copy link
Author

vltsu commented Apr 16, 2015

@vivin
Copy link

vivin commented Apr 16, 2015

Cool! Seems to be along similar lines as my solution. I'll add it to SO. I noticed that the main difference is that I didn't extend the module; just the instantiator.

@gregturn
Copy link
Contributor

gregturn commented Mar 5, 2019

Superseded by #833.

@gregturn gregturn closed this as completed Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants