Skip to content
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

Enable the Siren hypermedia without the usage of the internal Spring HATEOAS SPI #47

Closed
ingogriebsch opened this issue Jul 29, 2020 · 5 comments
Assignees
Labels
type:improvement To make things better
Milestone

Comments

@ingogriebsch
Copy link
Owner

ingogriebsch commented Jul 29, 2020

We currently enable the Siren hypermedia type as soon as the library is available on the classpath. But it is the only way until spring-projects/spring-hateoas#1304 is solved.

Related issues:

Check the comments of the mentioned issues as well to understand how to integrate the custom mediatype (how about spring.factories, HypermediaMappingInformation, MediaTypeConfigurationProvider?).

@ingogriebsch ingogriebsch added the type:bug Something isn't working label Jul 29, 2020
@ingogriebsch ingogriebsch self-assigned this Jul 29, 2020
@ingogriebsch ingogriebsch changed the title Enable Siren hypermedia type only if wanted Enable the Siren hypermedia type only if wanted/configured Jul 29, 2020
@gregturn
Copy link

@ingogriebsch

Long story short, you only need to implement HypermediaMappingInformation and ensure that bean is on the classpath. You can drop your implementation of MediaTypeConfigurationProvider and spring.factories.

This should also be easy to test.

@gregturn
Copy link

As for "is SIREN wanted", I would use its existence on the classpath as the signal of it being wanted.

spring-projects/spring-hateoas#1304, in its original form, was not going to have an enabling signal. We ONLY do that for the provided media types inside Spring HATEOAS because those types are ALWAYS on the classpath.

@ingogriebsch
Copy link
Owner Author

ingogriebsch commented Jul 29, 2020

@gregturn Thanks for the hints!

I need to think a moment about how to handle the (auto-)configuation part. I also don't like to use @component. But using a spring.factories file inside the library would IMO mix up responsibilities a little bit. spring.factories is a Spring Boot mechanism as far as I understand. But the library itself is not (the same counts for Spring HATEOAS itself, correct?) and should therefore be usable without Spring Boot. So referencing the @Configuration class which implements HypermediaMappingInformation in a spring.factories which is part of the library itself feels... not right.

Therefore introducing an auto-configuration and/or starter jar is maybe the way to go?! 🤔

@gregturn
Copy link

Actually, spring.factories is pure Spring Framework.

To prove my point, Spring HATEOAS is consumed by Spring Boot, not the other way around. Spring HATEOAS doesn't have the luxury of using some of Boot's tools and instead leans on lower level stuff.

@ingogriebsch
Copy link
Owner Author

ingogriebsch commented Jul 30, 2020

Ah, because SpringFactoriesLoader is part of the Core framework!

Nevertheless, adding org.springframework.boot.autoconfigure.EnableAutoConfiguration to the spring.factories in such a library IMO results in mixing up the used frameworks and the responsibilities. That is what I wanted to say and what I'm struggling with.

@ingogriebsch ingogriebsch changed the title Enable the Siren hypermedia type only if wanted/configured Enable the Siren hypermedia without the usage of the internal Spring HATEOAS SPI Jul 31, 2020
@ingogriebsch ingogriebsch added enhancement and removed type:bug Something isn't working labels Jul 31, 2020
@ingogriebsch ingogriebsch added this to the 1.0.0-M2 milestone Jul 31, 2020
@ingogriebsch ingogriebsch added type:improvement To make things better and removed enhancement labels Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:improvement To make things better
Projects
None yet
Development

No branches or pull requests

2 participants