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

Improve @ConditionalOnEnabledEndpoint to be used on any component #12945

Closed
snicoll opened this issue Apr 23, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@snicoll
Copy link
Member

commented Apr 23, 2018

If a component is solely used in the context of an endpoint, there is no easy way to make it available only said component is enabled. The main reason behind that is that the logic in @ConditionalOnEnabledEndpoint requires the return type to be an endpoint (or an extension).

snicoll added a commit to snicoll/spring-boot that referenced this issue Apr 23, 2018

Improve @ConditionalOnEnabledEndpoint to be used on any component
This commit adds an `endpoint` attribute so that the condition can be
used on arbitrary components, not only endpoints or extensions.

Closes spring-projectsgh-12945
@snicoll

This comment has been minimized.

Copy link
Member Author

commented Apr 23, 2018

I've a proposal in 0d96b2a that complexifies the API a bit. It also opens a case that would lead to a very weird scenario:

@Bean
@ConditionalOnEnabledEndpoint(endpoint = MyOtherEndpoint.class)
public MyEndpoint myEndpoint() { ... }

The sample above would ignore management.endpoint.my.enabled and only rely on management.endpoint.myother.enabled.

Also, the annotation attribute defaulting to Endpoint is weird (perhaps Object would be better ?)

@philwebb

This comment has been minimized.

Copy link
Member

commented Apr 23, 2018

I quite like Void.class for class defaults that aren't considered.

@philwebb

This comment has been minimized.

Copy link
Member

commented Apr 23, 2018

I think the change is sensible and I'm not too worried about the scenario you mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.