《how tomcat work》 搬运工 Chapter 12: StandardContext
2015-10-11 11:52
591 查看
一个context代表一个web网站,一个context包含多个wrappers。这个章节介绍了catalina的standardContext。
一、StandardContext Configuration
standardContext Configuration是配置standardContext的。它会读取web.xml以便让standardcontext配置好。StandardContext Configuration会在lifecycle listener上实现,以便在standardContext启动时完成配置,如果失败则不会处理请求
二、StandardContext Class's Constructor
构造函数最重要的就是对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 方法。
一、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 方法。
相关文章推荐
- myeclipse 2015 ci 添加tomcat图文教程
- Tomcat 配置
- tomcat无法启动异常
- Apache Tomcat 8.0.9下载、安装、配置和部署(不是最新版本)
- HTML5 WebSocket+Tomcat实现真●Web版即时聊天室(单人+多人)
- ContOS7 安装Tomcat发现service stop时候执行的是service start
- Linux的Tomcat设置默认项目
- Tomcat剖析(四):Tomcat默认连接器(2)
- Linux下Tomcat配置80端口(8080端口被禁用了)
- tomcat 启动了,浏览器访问不了,查看防火墙 Linux
- mac下安装tomcat
- Tomcat 7.0 servlet @WebServlet
- nginx结合tomcat
- 提升tomcat服务器性能的七条经验
- 关于Ajax跨域访问问题的一种解决办法
- Windows平台下tomcat+java的web程序持续占cpu问题调试
- tomcat 连接池配置
- Target runtime Apache Tomcat v8.0 is not defined.错误解决方法
- eclipse,myeclipse,tomcat
- Tomcat优化