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

SmartLifecycle should provide default methods [SPR-17188] #21723

Closed
spring-issuemaster opened this issue Aug 16, 2018 · 2 comments
Closed

SmartLifecycle should provide default methods [SPR-17188] #21723

spring-issuemaster opened this issue Aug 16, 2018 · 2 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Aug 16, 2018

Yanming Zhou opened SPR-17188 and commented

Normally the motivation of Using SmartLifecycle instead of Lifecycle is make it auto startup, so we should return true by default, and most SmartLifecycle doesn't care about concurrent shutdown, we should provide a default stop method to avoid misuse shutdown order.

default boolean isAutoStartup() {
     return true;
}
default void stop(Runnable callback) {
     this.stop();
     callback.run();
}

Affects: 5.0.8

Issue Links:

  • #21699 Use default methods on Smart/GenericApplicationListener

Referenced from: pull request #1929

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 16, 2018

Juergen Hoeller commented

Good idea! I'm taking this even one support further, also covering the Phased implementation with a default value and documenting the default implementations, along the lines of our recent SmartApplicationListener revision (#21699).

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Aug 16, 2018

Juergen Hoeller commented

I'm using a default phase of Integer.MAX_VALUE in line with the existing SmartLifecycle implementations, as a default phase for SmartLifecycle beans (different from the assumed phase 0 for regular Lifecycle beans which therefore come first by default).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.