tomcat4 reload 的实现原理

1.在ContainerBase的setLoader中,loader.setContainer(this);
2.调用了WepappLoader的setContainer() 
        if ((this.container != null) && (this.container instanceof Context)) {  //如果是上下文容器
            setReloadable( ((Context) this.container).getReloadable() );
            ((Context) this.container).addPropertyChangeListener(this);
        }
3.在setReloadable(boolean reloadable)中启动线程 持续的检查WEB-INF目录下面的类文件和JAR文件的时间戳  threadStart();
4.threadStart 启动同类的start()方法:产生新的一个线程,调用run()reload class, 产生threadStart()
5.run()中notifyContext();WebappContextNotifier notifier = new WebappContextNotifier();
        (new Thread(notifier)).start();
6.WebappContextNotifier为内部类,只有run()一个方法,执行((Context) container).reload(); 调用StandardContext的reload()方法
7. StandardContext的reload()方法的业务逻辑:
   7.1 Shut down our session manager
   7.2 Shut down the current version of all active servlets
   7.3 Shut down application event listeners
   7.4 Clear all application-originated servlet context attributes
   7.5 Shut down filters
   7.6 Shut down our application class loader
   7.7 Restart our application class loader
   7.8 Restart our application event listeners and filters
   7.9 Restore the "Welcome Files" and "Resources" context attributes
   7.10 Restart our currently defined servlets  :((Lifecycle) wrapper).start();
   7.11 Reinitialize all load on startup servlets: loadOnStartup(children);
   7.12 Restart our session manager

8.loadOnStartup(Container children[])-->wrapper.load()-->StandardWarpper loadServlet();

从代码上看,servlet是动态的全部先卸载,然后全部加载。


转载于:https://my.oschina.net/rainingcn/blog/42708

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值