mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Deprecate refresh(ApplicationContext) and add refresh(ConfigurableAC)
refresh can only ever be called with a ConfigurableApplicationContext and we want to evolve the refresh API to reflect that. This commit takes the first step by overloading refresh(ApplicationContext) with a new refresh(ConfigurationApplicationContext) method and deprecating refresh(ApplicationContext). Where the call to refresh is made, the argument is cast to ApplicationContext to ensure that refresh(ApplicationContext) is called. This ensures that any existing override of the method is still effective. Closes gh-18519
This commit is contained in:
parent
d1867c1b8b
commit
66d4319abd
@ -394,7 +394,7 @@ public class SpringApplication {
|
||||
}
|
||||
|
||||
private void refreshContext(ConfigurableApplicationContext context) {
|
||||
refresh(context);
|
||||
refresh((ApplicationContext) context);
|
||||
if (this.registerShutdownHook) {
|
||||
try {
|
||||
context.registerShutdownHook();
|
||||
@ -741,10 +741,21 @@ public class SpringApplication {
|
||||
/**
|
||||
* Refresh the underlying {@link ApplicationContext}.
|
||||
* @param applicationContext the application context to refresh
|
||||
* @deprecated since 2.3.0 in favor of
|
||||
* {@link #refresh(ConfigurableApplicationContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected void refresh(ApplicationContext applicationContext) {
|
||||
Assert.isInstanceOf(AbstractApplicationContext.class, applicationContext);
|
||||
((AbstractApplicationContext) applicationContext).refresh();
|
||||
Assert.isInstanceOf(ConfigurableApplicationContext.class, applicationContext);
|
||||
refresh((ConfigurableApplicationContext) applicationContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the underlying {@link ApplicationContext}.
|
||||
* @param applicationContext the application context to refresh
|
||||
*/
|
||||
protected void refresh(ConfigurableApplicationContext applicationContext) {
|
||||
applicationContext.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user