|
22 | 22 | import java.util.ArrayList;
|
23 | 23 | import java.util.Collection;
|
24 | 24 | import java.util.Date;
|
25 |
| -import java.util.LinkedHashMap; |
26 | 25 | import java.util.LinkedHashSet;
|
27 | 26 | import java.util.List;
|
28 | 27 | import java.util.Locale;
|
|
50 | 49 | import org.springframework.context.ApplicationListener;
|
51 | 50 | import org.springframework.context.ConfigurableApplicationContext;
|
52 | 51 | import org.springframework.context.HierarchicalMessageSource;
|
53 |
| -import org.springframework.context.Lifecycle; |
54 | 52 | import org.springframework.context.LifecycleProcessor;
|
55 | 53 | import org.springframework.context.MessageSource;
|
56 | 54 | import org.springframework.context.MessageSourceAware;
|
@@ -955,7 +953,7 @@ protected void doClose() {
|
955 | 953 | }
|
956 | 954 |
|
957 | 955 | // Stop all Lifecycle beans, to avoid delays during individual destruction.
|
958 |
| - this.getLifecycleProcessor().stop(); |
| 956 | + getLifecycleProcessor().onClose(); |
959 | 957 |
|
960 | 958 | // Destroy all cached singletons in the context's BeanFactory.
|
961 | 959 | destroyBeans();
|
@@ -1177,40 +1175,17 @@ public Resource[] getResources(String locationPattern) throws IOException {
|
1177 | 1175 | //---------------------------------------------------------------------
|
1178 | 1176 |
|
1179 | 1177 | public void start() {
|
1180 |
| - this.getLifecycleProcessor().start(); |
| 1178 | + getLifecycleProcessor().start(); |
1181 | 1179 | publishEvent(new ContextStartedEvent(this));
|
1182 | 1180 | }
|
1183 | 1181 |
|
1184 | 1182 | public void stop() {
|
1185 |
| - this.getLifecycleProcessor().stop(); |
| 1183 | + getLifecycleProcessor().stop(); |
1186 | 1184 | publishEvent(new ContextStoppedEvent(this));
|
1187 | 1185 | }
|
1188 | 1186 |
|
1189 | 1187 | public boolean isRunning() {
|
1190 |
| - for (Lifecycle lifecycle : getLifecycleBeans().values()) { |
1191 |
| - if (!lifecycle.isRunning()) { |
1192 |
| - return false; |
1193 |
| - } |
1194 |
| - } |
1195 |
| - return true; |
1196 |
| - } |
1197 |
| - |
1198 |
| - /** |
1199 |
| - * Return a Map of all singleton beans that implement the |
1200 |
| - * Lifecycle interface in this context. |
1201 |
| - * @return Map of Lifecycle beans with bean name as key |
1202 |
| - */ |
1203 |
| - private Map<String, Lifecycle> getLifecycleBeans() { |
1204 |
| - ConfigurableListableBeanFactory beanFactory = getBeanFactory(); |
1205 |
| - String[] beanNames = beanFactory.getSingletonNames(); |
1206 |
| - Map<String, Lifecycle> beans = new LinkedHashMap<String, Lifecycle>(); |
1207 |
| - for (String beanName : beanNames) { |
1208 |
| - Object bean = beanFactory.getSingleton(beanName); |
1209 |
| - if (bean instanceof Lifecycle) { |
1210 |
| - beans.put(beanName, (Lifecycle) bean); |
1211 |
| - } |
1212 |
| - } |
1213 |
| - return beans; |
| 1188 | + return getLifecycleProcessor().isRunning(); |
1214 | 1189 | }
|
1215 | 1190 |
|
1216 | 1191 |
|
|
0 commit comments