SpringBoot几个重要的事件回调、监听机制
(1)、需要配置在META-INF/Spring.factories
1.ApplicationContextInitializer
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
// package org.springframework.context; public interface ApplicationContextInitializer<C extends ConfigurableApplicationContext> {
//监听ioc容器启动
void initialize(C var1);
}
2.SpringApplicationRunListener
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
// package org.springframework.boot; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment; public interface SpringApplicationRunListener {
//监听容器开始
void starting();
//SpringBoot环境准备好
void environmentPrepared(ConfigurableEnvironment environment);
//ioc容器准备好了
void contextPrepared(ConfigurableApplicationContext context);
//容器环境加载完成
void contextLoaded(ConfigurableApplicationContext context); void started(ConfigurableApplicationContext context); void running(ConfigurableApplicationContext context);
//SpringBoot创建完成
void failed(ConfigurableApplicationContext context, Throwable exception);
}
(2)、只需要放到ioc容器中即可
1.ApplicationRunner
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
// package org.springframework.boot; @FunctionalInterface
public interface ApplicationRunner {
void run(ApplicationArguments args) throws Exception;
}
2.CommandLineRunner
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
// package org.springframework.boot; @FunctionalInterface
public interface CommandLineRunner {
void run(String... args) throws Exception;
}
SpringBoot几个重要的事件回调、监听机制的更多相关文章
- 深入理解Spring的容器内事件发布监听机制
目录 1. 什么是事件监听机制 2. JDK中对事件监听机制的支持 2.1 基于JDK实现对任务执行结果的监听 3.Spring容器对事件监听机制的支持 3.1 基于Spring实现对任务执行结果的监 ...
- 【spring源码学习】spring的事件发布监听机制源码解析
[一]相关源代码类 (1)spring的事件发布监听机制的核心管理类:org.springframework.context.event.SimpleApplicationEventMulticast ...
- Spring笔记(7) - Spring的事件和监听机制
一.背景 事件机制作为一种编程机制,在很多开发语言中都提供了支持,同时许多开源框架的设计中都使用了事件机制,比如SpringFramework. 在 Java 语言中,Java 的事件机制参与者有3种 ...
- 【cocos2d-js官方文档】事件分发监听机制(摘录)
简介 游戏开发中一个很重要的功能就是交互,如果没有与用户的交互,那么游戏将变成动画,而处理用户交互就需要使用事件监听器了. 总概: 事件监听器(cc.EventListener) 封装用户的事件处理逻 ...
- SpringBoot事件监听机制源码分析(上) SpringBoot源码(九)
SpringBoot中文注释项目Github地址: https://github.com/yuanmabiji/spring-boot-2.1.0.RELEASE 本篇接 SpringApplicat ...
- SpringBoot事件监听机制及观察者模式/发布订阅模式
目录 本篇要点 什么是观察者模式? 发布订阅模式是什么? Spring事件监听机制概述 SpringBoot事件监听 定义注册事件 注解方式 @EventListener定义监听器 实现Applica ...
- Android 开发中的View事件监听机制
在开发过程中,我们常常根据实际的需要绘制自己的应用组件,那么定制自己的监听事件,及相应的处理方法是必要的.我们都知道Android中,事件的监听是基于回调机制的,比如常用的OnClick事件,你了解它 ...
- JAVA事件监听机制学习
//事件监听机制 import java.awt.*; import java.awt.event.*; public class TestEvent { public static void mai ...
- Java swing(awt):事件监听机制的实现原理+简单示例
(1)实现原理 事件监听机制的实现: 参考图:事件模型_ActionEvent 为了节省资源,系统无法对某个事件进行实时的监听.故实现的机制是当发生某个事件后,处理代码将被自动运行,类似钩子一般.(回 ...
- 简单剖析Node中的事件监听机制(一)
使用js的class类简单的实现一个事件监听机制,不同于浏览器中的时间绑定与监听,类似于node中的时间监听,并且会在接下来的文章中去根据自己的理解去写一下Event模块中的原理. Node.js使用 ...
随机推荐
- git上传到码云
touch README.md git init git add README.md git add "你的文件" git commit -m "first commit ...
- IScroll的那些事——内容不足时下拉刷新
之前项目中的列表是采用的IScroll,但是在使用IScroll有一个问题就是:当内容不足全屏的时候,是木有办法往下拉的,这样就达不到刷新的目的了.[这是本人工作中遇到的,具体例子具体分析,这里只作一 ...
- 04 Zabbix4.0系统配置触发器trigger
点击返回:自学Zabbix之路 点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 04 Zabbix4.0系统配置触发器trigger 请点击查看Zabbix3.0.8版本trig ...
- HTMLUnit web测试
httpClient不能动态执行网页中的js,这样无法获取js生成的动态网页.htmlUnit是个解决方法. if you’re considering web application testing ...
- 通过url传递参数如果汉字乱码采用的方法
urlCodeDeal 方法把汉字编码, 在Jsp界面通过Escape.unescape方法,将编码反编译成汉字. 下面是urlCodeDeal方法: //UrlCode 处理代码 function ...
- 结尾0的个数(问题来源PythonTip)
给你一个正整数列表 L, 输出L内所有数字的乘积末尾0的个数.(提示:不要直接相乘,数字很多,相乘得到的结果可能会很大). 例如: L=[2,8,3,50], 则输出:2 利用2 和 5 思路: 算各 ...
- nginx 中配置多个location并解决js/css/jpg/等的加载问题
2017-11-09 22:07 277人阅读 评论(0) 收藏 举报 分类: linux(1) 版权声明:如有版权问题,请私信我. ECS:阿里云 系统:ubuntu 16.04 我的配置文件位 ...
- JAVA分布式架构的演进
系统架构演化历程-初始阶段架构 初始阶段 的小型系统 应用程序.数据库.文件等所有的资源都在一台服务器上通俗称为LAMP 特征:应用程序.数据库.文件等所有的资源都在一台服务器上. 描述:通常服务器操 ...
- Java_myBatis_XML代理_动态SQL
主要是设计到映射文件的编写: SELECT: <sql id="query_user_where"> <!-- test里面可以编写OGNL表达式 --> ...
- [python网络编程]使用scapy修改源IP发送请求
Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...