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

@ShutDown as opposite to @Startup #35848

Closed
HerrDerb opened this issue Sep 11, 2023 · 4 comments · Fixed by #35869
Closed

@ShutDown as opposite to @Startup #35848

HerrDerb opened this issue Sep 11, 2023 · 4 comments · Fixed by #35869
Labels
area/arc Issue related to ARC (dependency injection) kind/enhancement New feature or request
Milestone

Comments

@HerrDerb
Copy link
Contributor

HerrDerb commented Sep 11, 2023

Description

With @Startup, I can register a method to be executed when the startup event is fired. The alternative is to @Observes the StartupEvent directly.

For the shutdown event, I currently need to @Observes ShutdownEvent env. While it does work, I mostly don't have any use of the event object. This also leads to some code smells, as I have a unused parameter. (Usually marked by sonarcloud)

Implementation ideas

Therefor it would be nice to have, similar to the startup event, a shotdown annotation @ShutDown which registers the method to the ShutdownEvent. This would be short handed and leads to cleaner code.

@HerrDerb HerrDerb added the kind/enhancement New feature or request label Sep 11, 2023
@geoand geoand added area/arc Issue related to ARC (dependency injection) and removed triage/needs-triage labels Sep 11, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Sep 11, 2023

/cc @Ladicek (arc), @manovotn (arc), @mkouba (arc)

@HerrDerb HerrDerb changed the title @ShutDown as oposit to @Startup @ShutDown as opposite to @Startup Sep 11, 2023
@manovotn
Copy link
Contributor

I am not opposed to this since we already have @Startup anyway. Just a side note - Quarkus events are just extending the CDI events which work very much the same and also have no other use than as a marker payload. So while I understand the code smell argument, in some scenarios it was deliberately designed this way (and not just in this case for CDI does behave similarly for observing context activation/deactivation events for instance).

Shutdown - https://github.com/jakartaee/cdi/blob/master/api/src/main/java/jakarta/enterprise/event/Shutdown.java
Startup - https://github.com/jakartaee/cdi/blob/master/api/src/main/java/jakarta/enterprise/event/Startup.java

@mkouba
Copy link
Contributor

mkouba commented Sep 12, 2023

Hm, but we'll need a bit different semantics for @Shutdown. I mean the @Startup annotation can be declated on a bean class in which case we initialize the bean (and call the @PostConstruct callback). What should happen in case of @Shutdown declared on a bean class? Should we only support @Shutdown declared on a method?

mkouba added a commit to mkouba/quarkus that referenced this issue Sep 12, 2023
- to mark a business method that should be executed during application
shutdown
- resolves quarkusio#35848
mkouba added a commit to mkouba/quarkus that referenced this issue Sep 12, 2023
- to mark a business method that should be executed during application
shutdown
- resolves quarkusio#35848
@quarkus-bot quarkus-bot bot added this to the 3.5 - main milestone Sep 13, 2023
@HerrDerb
Copy link
Contributor Author

@mkouba Cool, thank you very much 🙂👍

franz1981 pushed a commit to franz1981/quarkus that referenced this issue Sep 13, 2023
- to mark a business method that should be executed during application
shutdown
- resolves quarkusio#35848
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Feb 8, 2024
- to mark a business method that should be executed during application
shutdown
- resolves quarkusio#35848
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/arc Issue related to ARC (dependency injection) kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants