《how tomcat work》 搬运工 Chapter 12: StandardContext

一个context代表一个web网站,一个context包含多个wrappers。这个章节介绍了catalina的standardContext。

 

一、StandardContext Configuration 

standardContext Configuration是配置standardContext的。它会读取web.xml以便让standardcontext配置好。StandardContext Configuration会在lifecycle listener上实现,以便在standardContext启动时完成配置,如果失败则不会处理请求

 

二、StandardContext Class's Constructor  

public StandardContext() {   
	super();
  	pipeline.setBasic(new StandardContextValve());
  	namingResources.setContainer(this);
} 

 构造函数最重要的就是对pipeline设置standardContextValve了。

 

三、Starting StandardContext 

start()方法主要是:

  • 启动BEFOTE_START event
  • 设置availability 属性为false
  • 设置configured 属性为false
  • 设置resources
  • 设置loader
  • 设置manager
  • 设置mapper
  • start及将其他组件和StandardContext联系起来
  • start子containers(wrappers)
  • start pipeline
  • start manager
  • 启动START event.这里会设置configuration
  • 在配置成功后,检查configured的属性,如果是true则,调用postWelcomePages函数,加载那些需要提前加载的子wrappers
  • 启动AFTER_START event.

 

四、Invoke Method 

invoked(Request request, Response response)调用时会想检查是否这web application是否被重新加载。

 

五、Support for Reloading 

在tomcat4中,web的重新加载是依靠standardContext中的WebappLoader实例,WebappLoader一个线程检查是否需要重新加载,只需要启动这个线程就可以了。

因为每一个像这样的方法都会开启一个线程,这样会导致资源的消耗,所以在tomcat5中则用backgroundProcess 方法,而处理都只用一个线程。

tomcat5会在基类,baseContainer中创建一个ContainerBackgroundProcessor实例,并开启这个实例,并将一个Container调用他的backgroundProcess 方法和调用他子Container的backgroundProcess 方法。

 

转载于:https://www.cnblogs.com/xuyung/p/4869031.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值