org.springframework.context.event.ContextStoppedEvent Java Examples
The following examples show how to use
org.springframework.context.event.ContextStoppedEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplicationEventListener.java From Almost-Famous with MIT License | 6 votes |
@Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ApplicationEnvironmentPreparedEvent) { LOGGER.debug("初始化环境变量"); } else if (event instanceof ApplicationPreparedEvent) { LOGGER.debug("初始化完成"); } else if (event instanceof ContextRefreshedEvent) { LOGGER.debug("应用刷新"); } else if (event instanceof ApplicationReadyEvent) { LOGGER.debug("应用已启动完成"); } else if (event instanceof ContextStartedEvent) { LOGGER.debug("应用启动,需要在代码动态添加监听器才可捕获"); } else if (event instanceof ContextStoppedEvent) { LOGGER.debug("应用停止"); } else if (event instanceof ContextClosedEvent) { ApplicationContext applicationContext = ((ContextClosedEvent) event).getApplicationContext(); grpcClient = applicationContext.getBean(GrpcClient.class); grpcClient.close(); LOGGER.debug("应用关闭"); } }
Example #2
Source File: ApplicationEventListener.java From Almost-Famous with MIT License | 6 votes |
@Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ApplicationEnvironmentPreparedEvent) { LOG.debug("初始化环境变量"); } else if (event instanceof ApplicationPreparedEvent) { LOG.debug("初始化完成"); LOG.debug("初始GameData策划数据"); ConfigManager.loadGameData(this.configPath); } else if (event instanceof ContextRefreshedEvent) { LOG.debug("应用刷新"); } else if (event instanceof ApplicationReadyEvent) { LOG.debug("应用已启动完成"); } else if (event instanceof ContextStartedEvent) { LOG.debug("应用启动,需要在代码动态添加监听器才可捕获"); } else if (event instanceof ContextStoppedEvent) { LOG.debug("应用停止"); } else if (event instanceof ContextClosedEvent) { ApplicationContext context = ((ContextClosedEvent) event).getApplicationContext(); rpcClient = context.getBean(RpcClient.class); rpcClient.close(); LOG.error("应用关闭"); } else { } }
Example #3
Source File: ApplicationEventListener.java From Almost-Famous with MIT License | 6 votes |
@Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ApplicationEnvironmentPreparedEvent) { LOG.debug("初始化环境变量"); } else if (event instanceof ApplicationPreparedEvent) { LOG.debug("初始化完成"); LOG.debug("初始GameData策划数据"); String path = ApplicationEventListener.class.getResource("/gamedata").getFile(); ConfigManager.loadGameData(path); } else if (event instanceof ContextRefreshedEvent) { LOG.debug("应用刷新"); } else if (event instanceof ApplicationReadyEvent) { LOG.debug("应用已启动完成"); } else if (event instanceof ContextStartedEvent) { LOG.debug("应用启动,需要在代码动态添加监听器才可捕获"); } else if (event instanceof ContextStoppedEvent) { LOG.debug("应用停止"); } else if (event instanceof ContextClosedEvent) { ApplicationContext applicationContext = ((ContextClosedEvent) event).getApplicationContext(); grpcClient = applicationContext.getBean(GrpcClient.class); grpcClient.close(); LOG.debug("应用关闭"); } }
Example #4
Source File: AstrixFrameworkBean.java From astrix with Apache License 2.0 | 6 votes |
@Override public void onApplicationEvent(ApplicationContextEvent event) { if (event instanceof ContextRefreshedEvent && !servicePublisherStarted) { // Application initialization complete. Export astrix-services. if (isServer()) { this.astrixContext.startServicePublisher(); } servicePublisherStarted = true; } else if (event instanceof ContextClosedEvent || event instanceof ContextStoppedEvent) { /* * What's the difference between the "stopped" and "closed" event? In our embedded * integration tests we only receive ContextClosedEvent */ destroyAstrixContext(); } }
Example #5
Source File: ApplicationEventListener.java From SpringBoot-Base-System with GNU Lesser General Public License v3.0 | 6 votes |
/** * 应用程序启动过程监听 * * @time 2018年4月10日 下午5:05:33 * @version V1.0 * @param event */ @Override public void onApplicationEvent(ApplicationEvent event) { // 在这里可以监听到Spring Boot的生命周期 if (event instanceof ApplicationEnvironmentPreparedEvent) { // 初始化环境变量 log.debug("初始化环境变量"); } else if (event instanceof ApplicationPreparedEvent) { // 初始化完成 log.debug("初始化环境变量完成"); } else if (event instanceof ContextRefreshedEvent) { // 应用刷新,当ApplicationContext初始化或者刷新时触发该事件。 log.debug("应用刷新"); } else if (event instanceof ApplicationReadyEvent) {// 应用已启动完成 log.debug("应用已启动完成"); } else if (event instanceof ContextStartedEvent) { // 应用启动,Spring2.5新增的事件,当容器调用ConfigurableApplicationContext的 // Start()方法开始/重新开始容器时触发该事件。 log.debug("应用启动"); } else if (event instanceof ContextStoppedEvent) { // 应用停止,Spring2.5新增的事件,当容器调用ConfigurableApplicationContext // 的Stop()方法停止容器时触发该事件。 log.debug("应用停止"); } else if (event instanceof ContextClosedEvent) { // 应用关闭,当ApplicationContext被关闭时触发该事件。容器被关闭时,其管理的所有 // 单例Bean都被销毁。 log.debug("应用关闭"); } else { } }
Example #6
Source File: KSBConfigurer.java From rice with Educational Community License v2.0 | 5 votes |
@Override public void onApplicationEvent(ApplicationEvent applicationEvent) { if (applicationEvent instanceof ContextRefreshedEvent) { doAdditionalContextStartedLogic(); } else if (applicationEvent instanceof ContextStoppedEvent) { doAdditionalContextStoppedLogic(); } }
Example #7
Source File: MetricServer.java From realtime-analytics with GNU General Public License v2.0 | 5 votes |
@Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ContextStartedEvent) { this.startStandAlone(); } else if (event instanceof ContextClosedEvent || event instanceof ContextStoppedEvent) { this.stopStandAlone(); } }
Example #8
Source File: ApplicationContextClosedListener.java From sofa-rpc-boot-projects with Apache License 2.0 | 5 votes |
@Override public void onApplicationEvent(ApplicationEvent event) { if ((event instanceof ContextClosedEvent) || (event instanceof ContextStoppedEvent)) { providerConfigContainer.unExportAllProviderConfig(); serverConfigContainer.closeAllServer(); } }
Example #9
Source File: SpringBootPlatform.java From spring-boot-keycloak-server-example with Apache License 2.0 | 5 votes |
public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ApplicationReadyEvent) { Runnable startupHook = getPlatformField(Runnable.class, "startupHook"); if (startupHook != null) { startupHook.run(); } } else if (event instanceof ContextStoppedEvent) { Runnable shutdownHook = getPlatformField(Runnable.class, "shutdownHook"); if (shutdownHook != null) { shutdownHook.run(); } } }
Example #10
Source File: SystemStopEventHandler.java From seezoon-framework-all with Apache License 2.0 | 4 votes |
@Override public void onApplicationEvent(ContextStoppedEvent event) { NDCUtils.push(); printKeyLoadMessage(); }
Example #11
Source File: ContextEventListener.java From tutorials with MIT License | 4 votes |
@Order(1) @EventListener(classes = { ContextStartedEvent.class, ContextStoppedEvent.class }) public void handleMultipleEvents() { System.out.println("Multi-event listener invoked"); }
Example #12
Source File: SpringBootPlatform.java From spring-boot-keycloak-server-example with Apache License 2.0 | 4 votes |
@Override public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) { return ApplicationReadyEvent.class.equals(eventType) || ContextStoppedEvent.class.equals(eventType); }
Example #13
Source File: AbstractApplicationContext.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public void stop() { getLifecycleProcessor().stop(); publishEvent(new ContextStoppedEvent(this)); }
Example #14
Source File: AbstractApplicationContext.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void stop() { getLifecycleProcessor().stop(); publishEvent(new ContextStoppedEvent(this)); }
Example #15
Source File: AbstractApplicationContext.java From spring-analysis-note with MIT License | 4 votes |
@Override public void stop() { getLifecycleProcessor().stop(); publishEvent(new ContextStoppedEvent(this)); }
Example #16
Source File: LocalstackAutoConfiguration.java From spring-localstack with Apache License 2.0 | 4 votes |
@EventListener({ContextStoppedEvent.class, ContextClosedEvent.class}) public void cleanContext() { if (localstackDocker != null) { localstackDocker.stop(); } }
Example #17
Source File: EurekaRegisterHandler.java From TarsJava with BSD 3-Clause "New" or "Revised" License | 4 votes |
@EventListener(ContextStoppedEvent.class) public void onApplicationEvent(ContextStoppedEvent ev) { close(); }
Example #18
Source File: AbstractApplicationContext.java From java-technology-stack with MIT License | 4 votes |
@Override public void stop() { getLifecycleProcessor().stop(); publishEvent(new ContextStoppedEvent(this)); }
Example #19
Source File: ContextStopListener.java From ext-opensource-netty with Mozilla Public License 2.0 | 4 votes |
@Override public void onApplicationEvent(ContextStoppedEvent event) { System.err.println("============Stop 执行=========== "); }