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使用 ...
随机推荐
- day22 time模块
表示方式有三种 时间戳 给机器看的 float格式 格式化的字符传 给人看的 格式化时间 元祖 计算用的 结构化时间 1 # 时间戳时间 2 # 返回一个时间戳,表示从1970.1.1日到现在的秒数 ...
- MT【212】合作共赢
一次会议有1990位数学家参加,每人至少有过1327位合作者,求证:可以找到4位数学家,他们中每一个都合作过. 解答:记与$v_i$合作过的数学家构成集合$A_i(i=1,2,\cdots,1990) ...
- AtCoder Regular Contest 063 F : Snuke’s Coloring 2 (线段树 + 单调栈)
题意 小 \(\mathrm{C}\) 很喜欢二维染色问题,这天他拿来了一个 \(w × h\) 的二维平面 , 初始时均为白色 . 然后他在上面设置了 \(n\) 个关键点 \((X_i , Y_i ...
- 转载:OSG::Quat(四元数)用法
转自:http://blog.163.com/dj_zone/blog/static/4908931320098294047820/ osg::Quat To set the attitude of ...
- java.sql.SQLException: Prepared or callable statement has more than 2000 parameter markers及解决方案
1. 问题 最近在项目中修bug的时候,碰到这样一个错误: Caused by: java.sql.SQLException:Prepared or callable statement has mo ...
- gcc-linaro-arm-linux-gnueabihf交叉编译器配置
系统Ubuntu14.04 版本:gcc 版本 4.7.3 20130328 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2013.04-20130415 ...
- 线程的加入.join()
格式:以加入A线程为例 线程对象B.join() 无参数,则A线程一直暂停,直到B线程运行结束. 线程对象B.join(时间t) 有参数,则A线程每隔t时间暂停一次,直到B线程运行结束. 关于 ...
- Mysql占用CPU过高如何优化,如何解决
2017-02-28 15:13 331人阅读 评论(0) 收藏 举报 MySQL占用CPU过高如何优化 一次生产DB服务器的 超负荷运行问题解决: 1.查看生产DB服务器top列表, 执行 to ...
- 使用Nessus漏扫
Nessus号称是世界上最流行的漏洞扫描程序,全世界有超过75000个组织在使用它.该工具提供完整的电脑漏洞扫描服务,并随时更新其漏洞数据库.Nessus不同于传统的漏洞扫描软件,Nessus可同时在 ...
- ElasticSearch入门介绍一
ElasticSearch 关于es的几个概念: 集群:多个运行es节点可以组成一个集群,它们拥有相同的cluster.name. 节点:运行es的实例 索引:相当于数据库database,一个集群可 ...