知识库--StandardContext + Reloading(60)
来源:互联网 发布:好压 mac 编辑:程序博客网 时间:2024/06/05 10:22
Support for Reloading
The StandardContext class defines the reloadable property to indicate whether reloading of the application is enabled. When reloading is enabled, the application will be reloaded if the web.xml file changes or if one of the files in the WEB-INF/classes directory is recompiled.
The StandardContext class depends on its loader to reload the application. In Tomcat 4 the WebappLoader class, the implementation class of Loader in StandardContext,* has a thread that checks the timestamps of all class and JAR files in the WEB-INF directory*. All you need to do to start this thread is associate the WebappLoader with the StandardContext by calling its setContainer method. Here is the implementation of the setContainer method of the WebappLoader class in Tomcat 4:
public void setContainer(Container container){ //Deregister from the old Container if any if((this.container != null) && (this.container instanceof Context)) ((Context)this.container).removePropertyChangeListener(this); //Process this property change Container odlContainer = this.container; this.container = container; support.firePropertyChange("container",oldContainer,this.container); //Register with the new Container if any if((this.container != null) && (this.container instanceof Context)){ setReloadable(((Context)this.container).getReloadable())); ((Context)this.container).addPropertyChangeListener(this); }}
Take a look at the last if block. If the container is a context, the setReloadable method will be called. This means, the value of the reloadable property of the WebappLoader instance will be the same as the value of the reloadable property of the StandardContext instance.
Here is the setReloadable method implementation of the WebappLoader class:
public void setReloadable(boolean reloadable){ //Process this property change boolean oldReloadable = this.reloadable; this.reloadable = reloadable; support.firePropertyChange("reloadable",new Booleann(oldRreloadable),new Boolean(this.reloadable)); //Start or stop our background thread if required 是否重新加载 if(!started) return; if(!oldReloadable && this.reloadable){ threadStart(); }else if(oldReloadable && !this.reloadable){ threadStop(); }}
If the reloadable property changes from false to true, the threadStart method is called. If it changes from true to false, the threadStop method is called. The threadStart method starts a dedicated thread that continuously checks the timestamps of the class and JAR files in WEB-INF. The threadStop method stops this thread.//检查时间戳
- 知识库--StandardContext + Reloading(60)
- 知识库--StandardContext+backgroundProcess(60)
- 知识库--StandardContext(57)
- Tomcat从零开始(十八)——StandardContext
- Tomcat源码解析(三):StandardContext
- hot-reloading
- hot-reloading
- 知识库--StandardContextMapper(60)
- 知识库--Lifecycle (44)
- 知识库--SimpleLoader (46)
- 知识库--Logger (46)
- 知识库--WebappLoader(47)
- 知识库--WebappClassLoader(47)
- 知识库--Session(47)
- 知识库--Sessions(48)
- 知识库--StandardSession (49)
- 知识库--PersistentManagerBase(50)
- 知识库--Realm(51)
- ubuntu12.04与VM Virtual&nbs…
- 简单字符串排序
- linux文件锁
- [JNI]开发之旅(6)JNI函数中访问java类中对象的属性
- HEOI2016排序-解题报告
- 知识库--StandardContext + Reloading(60)
- 【LeetCode】 415. Add Strings
- 6. ZigZag Conversion
- 3dsmax初体验
- iOS 录视频,相册选择视频,视频压缩,存储本地文件,播放,上传
- 关于Jquery 获取表单FORM所有元素进行AJAX提交
- 收缩数据库
- 【leetcode】7. Reverse Integer
- 矩阵中的路径