雨燕框架启动流程

0,

  此处说明一下web.xml 的加载顺序:

  context-param -> listener -> filter -> servlet ,而同个类型之间的实际程序调用的时候的顺序是根据对应的mapping的顺序进行调用的。

直接加载,这几个bean

SpringContextUtil
propertyConfigurer
SwiftServiceAutowiredProcessor
memcachedClient
redisShardClient
asynService

再引入各个项目的datasource和springcustom的xml文件

<import resource="classpath:datasource-*.xml" />
<import resource="classpath:springcustom-*.xml" />
启动bean扫描

扫描serviceImpl的类

<context:component-scan base-package="com.liepin.**.service" />

扫描biz实现类
<context:component-scan base-package="com.liepin.**.biz" />

扫描dao实现类
<context:component-scan base-package="com.liepin.**.dao" />

不知道
<context:component-scan base-package="com.liepin.**.idp" />

调度任务
<context:component-scan base-package="com.liepin.**.schedule" />

web的过滤器
<context:component-scan base-package="com.liepin.**.filter" />

异常解决类
<context:component-scan base-package="com.liepin.**.resolver" />

监听器类
<context:component-scan base-package="com.liepin.**.listener" />

服务降级类
<context:component-scan base-package="com.liepin.**.fallback" />

还加载了几个利用spring aop的监控模块cat

1,在web.xml配置监听器ContextLoaderListener(listener-class) 
ContextLoaderListener的作用就是启动Web容器时,自动装配ApplicationContext的配置信息。因为它实现了ServletContextListener这个接口,在web.xml配置这个监听器,启动容器时,就会默认执行它实现的方法。 

create();预加载cat

super.contextInitialized(event);调用父类的ContextLoaderListener的contextInitialized的放,里面调用contextLoader的initWebApplicationContext方法,这个方法里面就会帮你实例化上面注册的bean

跟着来启动swiftApplicationContext的启动方法

SwiftApplicationContext是雨燕的接口,配置中心,初始化过程

configComponent();

  • // 配置日志,调一下日志等级
  • configLog();
  • // 约定检查,这不太清楚
  • checkUp();
  • // 加载组件,加载拦截器,异常处理器,服务层,降级层这些组件
  • configComponent();
  • // 加载RPC
  • RPCFactory.init();
  • // 加载流量心跳
  • HttpHeartbeatManager.get();
  • // 监控
  • MonitorRegister.init();

// 加载RPC

  • RPCFactory.init();为空,但初始化的时候加载静态模块
  • static {
  • // 预加载
  • ServiceMetadataManager.getInstance().load();
  • }
  • loadLib加载依赖的client包
  • 加载的时候include,把他的服务和接口信息,放进一个serviceMetadataMap 保持 ,根据用户名new一个RPChandle放进serviceRPCHandleMap
  • prepareServiceProxy()调用RpcFactory的getService方法,第一次肯定没有,会根据serviceMetadataMap 和 serviceRPCHandleMap创建一个serviceInterceptor,自此全部代理类生成完毕

添加流量心跳

// 监控
MonitorRegister.init();


SwiftDispatcherServlet   继承了  spring的dispatchservlet

 @Override
    protected void initDispatchBean() {
        super.initDispatchBean();

        routerStarted();

        registerShutdownHook();
    }
  • 先调用父类的inti函数
  • 开启路由,注册到zk
  • 注册相关钩子
原文地址:https://www.cnblogs.com/vhyc/p/10585015.html