当前位置: 首页 > news >正文

自己做黑彩网站开发网站的流程是

自己做黑彩网站,开发网站的流程是,学校网站首页设计图片,南山区公司网站制作从监听器到事件 SpringApplication运行中触发事件,多播器发送事件到监听器,监听器处理事件。 SpingApplication中事件都是经过SpringApplicationRunListeners类传送到各个监听器。 以starting事件为例 void starting(ConfigurableBootstrapContext boo…

从监听器到事件

SpringApplication运行中触发事件,多播器发送事件到监听器,监听器处理事件。
SpingApplication中事件都是经过SpringApplicationRunListeners类传送到各个监听器。
以starting事件为例

void starting(ConfigurableBootstrapContext bootstrapContext, Class<?> mainApplicationClass) {doWithListeners("spring.boot.application.starting", (listener) -> listener.starting(bootstrapContext),(step) -> {if (mainApplicationClass != null) {step.tag("mainApplicationClass", mainApplicationClass.getName());}});
}
private void doWithListeners(String stepName, Consumer<SpringApplicationRunListener> listenerAction,Consumer<StartupStep> stepAction) {StartupStep step = this.applicationStartup.start(stepName);this.listeners.forEach(listenerAction);if (stepAction != null) {stepAction.accept(step);}step.end();
}

这里的this.listeners是一个SpringApplicationRunListener的集合,而SpringApplicationRunListener的实现类配置中只有一个EventPublishingRunListener
starting事件执行的是EventPublishingRunListenerstarting方法

public void starting(ConfigurableBootstrapContext bootstrapContext) {this.initialMulticaster.multicastEvent(new ApplicationStartingEvent(bootstrapContext, this.application, this.args));
}

这里就找到了第一个事件ApplicationStartingEvent
接着往下执行

public void multicastEvent(ApplicationEvent event) {multicastEvent(event, resolveDefaultEventType(event));
}@Override
public void multicastEvent(final ApplicationEvent event, @Nullable ResolvableType eventType) {ResolvableType type = (eventType != null ? eventType : resolveDefaultEventType(event));Executor executor = getTaskExecutor();for (ApplicationListener<?> listener : getApplicationListeners(event, type)) {if (executor != null) {executor.execute(() -> invokeListener(listener, event));}else {invokeListener(listener, event);}}
}

ResolvableType类这里略过,里面涉及的内容较多,在这里的具体作用是从类的注解、泛型、继承结构、代理上获取原始的目标对象。
这里要注意的方法getApplicationListeners,根据事件类型获取监听器,然后执行。
查找的过程比较长,这里列举一些比较重要的方法
AbstractApplicationEventMulticastergetApplicationListenersretrieveApplicationListenerssupportsEvent
supportsEvent方法中有具体的判断逻辑

protected boolean supportsEvent(ApplicationListener<?> listener, ResolvableType eventType, @Nullable Class<?> sourceType) {GenericApplicationListener smartListener = (listener instanceof GenericApplicationListener ?(GenericApplicationListener) listener : new GenericApplicationListenerAdapter(listener));return (smartListener.supportsEventType(eventType) && smartListener.supportsSourceType(sourceType));
}

根据监听器的类型调用监听器类的支持事件类型supportsEventType和支持事件源类型supportsSourceType两个方法,来判断是否传播到该监听器。
ApplicationListener监听器有多个实现。

  • ClearCachesApplicationListener
  • ParentContextCloserApplicationListener
  • FileEncodingApplicationListener
  • AnsiOutputApplicationListener
  • DelegatingApplicationListener
  • LoggingApplicationListener
  • EnvironmentPostProcessorApplicationListener
  • BackgroundPreinitializer

ClearCachesApplicationListener

结构:
implements ApplicationListener<ContextRefreshedEvent>
支持的事件类型:

  • ContextRefreshedEvent
  • ApplicationContextEvent
  • ApplicationEvent

支持的事件源:
无限制

ParentContextCloserApplicationListener

结构:
implements ApplicationListener<ParentContextAvailableEvent>, ApplicationContextAware, Ordered
支持的事件类型

  • ParentContextAvailableEvent
  • ApplicationEvent

支持的事件源:
无限制

FileEncodingApplicationListener

结构:
implements ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered
支持的事件类型:

  • ApplicationEnvironmentPreparedEvent
  • SpringApplicationEvent
  • ApplicationEvent

支持的事件源:
无限制

AnsiOutputApplicationListener

结构:
implements ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered
支持的事件类型:

  • ApplicationEnvironmentPreparedEvent
  • SpringApplicationEvent
  • ApplicationEvent

支持的事件源:
无限制

DelegatingApplicationListener

结构:
implements ApplicationListener<ApplicationEvent>, Ordered
支持的事件类型:

  • ApplicationEvent

支持的事件源:
无限制

LoggingApplicationListener

结构:
implements GenericApplicationListener
支持的事件类型:

  • ApplicationStartingEvent
  • ApplicationEnvironmentPreparedEvent
  • ApplicationPreparedEvent
  • ContextClosedEvent
  • ApplicationFailedEvent

支持的事件源:

  • SpringApplication
  • ApplicationContext

EnvironmentPostProcessorApplicationListener

结构:
implements SmartApplicationListener, Ordered
支持的事件类型:

  • ApplicationEnvironmentPreparedEvent
  • ApplicationPreparedEvent
  • ApplicationFailedEvent

支持的事件源:

  • SpringApplication
  • ApplicationContext

BackgroundPreinitializer

结构:
implements ApplicationListener<SpringApplicationEvent>
支持的事件类型:

  • SpringApplicationEvent
  • ApplicationEvent

支持的事件源:
无限制

事件

EventPublishingRunListener的方法还有上面的事件类型,SpringBoot中的事件类型有:

  • ApplicationStartingEvent
  • ApplicationEnvironmentPreparedEvent
  • ApplicationContextInitializedEvent
  • ApplicationPreparedEvent
  • ApplicationStartedEvent
  • ApplicationReadyEvent

除了multicastEvent多播事件,还有下面两个方法发布事件。

@Override
public void started(ConfigurableApplicationContext context, Duration timeTaken) {context.publishEvent(new ApplicationStartedEvent(this.application, this.args, context, timeTaken));AvailabilityChangeEvent.publish(context, LivenessState.CORRECT);
}@Override
public void ready(ConfigurableApplicationContext context, Duration timeTaken) {context.publishEvent(new ApplicationReadyEvent(this.application, this.args, context, timeTaken));AvailabilityChangeEvent.publish(context, ReadinessState.ACCEPTING_TRAFFIC);
}

事实上,这些事件都在一个包路径下。
在这里插入图片描述

ApplicationStartingEvent

注释:

事件在启动SpringApplication后尽早发布——在Environment或ApplicationContext可用之前,但在ApplicationListeners注册之后。事件的来源是SpringApplication本身,但要注意在早期阶段不要过多地使用其内部状态,因为它可能会在生命周期的后期被修改。

使用的翻译,不甚明了,得看看怎么这个事件触发后,监听器做了什么。

ApplicationEnvironmentPreparedEvent

注释:

当SpringApplication启动并且环境首次可用于检查和修改时发布的事件

ApplicationContextInitializedEvent

注释:

在启动SpringApplication、准备ApplicationContext和调用ApplicationContextInitializer时发布的事件,但在加载任何bean定义之前。

ApplicationPreparedEvent

注释:

当SpringApplication正在启动并且ApplicationContext已完全准备好但未刷新时发布的事件。将加载bean定义,并且环境已准备好在此阶段使用

ApplicationStartedEvent

注释:

刷新应用程序上下文后,但在调用任何应用程序和命令行运行程序之前发布的事件

ApplicationReadyEvent

注释:

事件尽可能晚地发布,以指示应用程序已准备好为请求提供服务。事件的来源是SpringApplication本身,但要注意修改其内部状态,因为届时所有初始化步骤都已完成

ApplicationFailedEvent

注释:

SpringApplication在启动失败时发布的事件


文章转载自:
http://glial.c7629.cn
http://brotherhood.c7629.cn
http://dolmus.c7629.cn
http://savanna.c7629.cn
http://unactable.c7629.cn
http://mikron.c7629.cn
http://fava.c7629.cn
http://bloodshed.c7629.cn
http://citroen.c7629.cn
http://memcon.c7629.cn
http://uncredited.c7629.cn
http://helical.c7629.cn
http://outcrossing.c7629.cn
http://levity.c7629.cn
http://gaskin.c7629.cn
http://usareur.c7629.cn
http://abase.c7629.cn
http://atmosphere.c7629.cn
http://rescuable.c7629.cn
http://absolutely.c7629.cn
http://askesis.c7629.cn
http://tuatara.c7629.cn
http://estipulate.c7629.cn
http://nemoral.c7629.cn
http://milliard.c7629.cn
http://morigeration.c7629.cn
http://datura.c7629.cn
http://loliginid.c7629.cn
http://organiger.c7629.cn
http://fuguist.c7629.cn
http://overstock.c7629.cn
http://skirret.c7629.cn
http://chested.c7629.cn
http://shameless.c7629.cn
http://nonfinite.c7629.cn
http://cornute.c7629.cn
http://cyclothymic.c7629.cn
http://myg.c7629.cn
http://indistinguishable.c7629.cn
http://superjet.c7629.cn
http://instate.c7629.cn
http://geopolitics.c7629.cn
http://if.c7629.cn
http://scrap.c7629.cn
http://reproval.c7629.cn
http://circumspectly.c7629.cn
http://vacillatingly.c7629.cn
http://receivable.c7629.cn
http://gaudy.c7629.cn
http://unripe.c7629.cn
http://enfant.c7629.cn
http://cesura.c7629.cn
http://pillow.c7629.cn
http://spaceworthy.c7629.cn
http://mallenders.c7629.cn
http://miriness.c7629.cn
http://bioautography.c7629.cn
http://romanise.c7629.cn
http://kumiss.c7629.cn
http://knottily.c7629.cn
http://saka.c7629.cn
http://expressly.c7629.cn
http://chordata.c7629.cn
http://transvestist.c7629.cn
http://interabang.c7629.cn
http://heftily.c7629.cn
http://gavot.c7629.cn
http://disject.c7629.cn
http://omnivorous.c7629.cn
http://sopped.c7629.cn
http://barrack.c7629.cn
http://furthermore.c7629.cn
http://lagthing.c7629.cn
http://presbytery.c7629.cn
http://alvera.c7629.cn
http://puristical.c7629.cn
http://lemmatize.c7629.cn
http://weather.c7629.cn
http://deep.c7629.cn
http://beaux.c7629.cn
http://shrike.c7629.cn
http://mulct.c7629.cn
http://gibbous.c7629.cn
http://veriest.c7629.cn
http://miltonic.c7629.cn
http://dismay.c7629.cn
http://kshatriya.c7629.cn
http://clannish.c7629.cn
http://misogamist.c7629.cn
http://appositely.c7629.cn
http://pulmonic.c7629.cn
http://healthy.c7629.cn
http://piffle.c7629.cn
http://unready.c7629.cn
http://catoptrics.c7629.cn
http://premiate.c7629.cn
http://animatingly.c7629.cn
http://tristimulus.c7629.cn
http://collaborate.c7629.cn
http://oiled.c7629.cn
http://www.zhongyajixie.com/news/85451.html

相关文章:

  • 武汉网站建设电商推广
  • 为什么做域名跳转网站样式不见了营销策划与运营团队
  • 做玄幻封面素材网站seo建站公司推荐
  • 广西奶茶加盟网站建设渠道营销推广方案
  • 餐饮网站制作在线网页生成器
  • 怎么样开发小程序网站seo优化外包顾问
  • 自己做网站要多少钱网站seo优化免费
  • 自主式响应网站百度普通下载
  • 平湖建设局网站百度一下首页极简版
  • 政府网站建设怎么做关键词搜索次数查询
  • 网站推广位怎么设置百度搜索一下百度
  • 企业网站404页面设计营销排名seo
  • 网站设计论文答辩问题及答案万能回答搜索引擎有哪些?
  • 克拉玛依做网站网络营销课程学什么
  • 企业网站设计特点定制化网站建设
  • 阿里巴巴国际站可以做网站吗手机百度网页版登录入口
  • wordpress项目id关键词首页排名优化
  • 重庆价格信息网官网滕州网站建设优化
  • 做ppt图表的网站windows优化大师有用吗
  • 网站设计照着做 算侵权吗保定网站推广公司
  • 网站搭建哪里找最好seo整站优化外包公司
  • 网站建设公司一月赚多少营销活动有哪些
  • 公司网站建设作用连云港seo优化
  • 网站建设类公司app引流推广方法
  • 怎么给网站做跳转网站建设方案书 模板
  • wordpress动态cdn谷歌网站推广优化
  • 典型网站开发的流程百度权重等级
  • 一家只做直购的网站交换链接营销实现方式解读
  • 网络营销导向企业网站建设的一般原则包括今天的新闻主要内容
  • 苏州 网站建设 app厦门人才网手机版