spring-projects/spring-hateoas

Provide a way to set resource relations through annotations

sdeleuze opened this issue · 1 comments

As raised on stack overflow, it could be very useful to provide a way to define resource relations just with annotated Pojo + regular Spring MVC controllers returning Pojo instances, without having to extend ResourceSupport or wrapping it into a Resource<Foo> container.

This is maybe already possible with the @Relation annotation, but I did not find any example or documentation about this.

If this is already possible, could you give me a quick example in order to allow me to contribute a documentation PR that will explain how to use the pure Pojo + @Relation approach?

If it is currently no possible, should it be possible to add such functionality as an alternative to Foo extends ResourceSupport and Resource<Foo> ones? Since annotations are static, I guess it will perhaps not cover all the use cases covered by the current Resource based approach, but that should be enough for a lot of use cases and I think that could awesome for our users to support this alternative way of dealing with relations.

Any thoughts?

According to this http://docs.spring.io/spring-hateoas/docs/current/reference/html/#fundamentals.obtaining-links.builder.methods the default relprovider should handle the Relation annotation, but in my case it didn't worked :(
I had to register a custom relationrelprovider which implements this behavior.