Tapestry 5 自动重载page模板和page类问题
Tapestry 5 自动重载page模板和page类问题
Tapestry5确实可以自动reload page tml模板和page classes,如果你的web.xml的定义是:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>My Tapestry Application</display-name> <context-param> <param-name>tapestry.app-package</param-name> <param-value>org.example.myapp</param-value> </context-param> <filter> <filter-name>app</filter-name> <filter-class>org.apache.tapestry5.TapestryFilter</filter-class> </filter> <filter-mapping> <filter-name>app</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
那么,包org.example.myapp以及子包下面的tml和page class可以自动reload,也就是说,只有在org.example.myapp.pages下面的page classes和在org.example.myapp.components下面的component classes才会自动reload。
但是注意:Tapestry's live class reloading does not work in Tomcat, and it is Tomcat's fault. See http://tapestry.apache.org/tapestry5/tomcat.html。
下面是来自官方的
Live Class and Template Reloading
Template Reloading
When a template changes, all page instances (as well as the hiearchy of components below them) are discarded and reconstructed with the new template. However, classes are not reloaded in this case.
A future version of Tapestry may be more selective, removing only page instances that are affected by the changed file(s).
Class Reloading
On a change to any class inside a controlled package (or any sub-package of a controlled package), Tapestry will discard all page instances, and discard the class loader.
Persistent data on the pages will usually not be affected (as it is stored separately, in the session). This allows you to make fairly significant changes to a component class even while the application continues to run.
Page and Component Packages
Only page and component classes are subject to reload.
Reloading is based on package name; the packages that are reloaded are derived from the application configuration.