Search |
||
Free Module for More Rapid Struts Development with TomcatPosted by budi on April 5, 2005 at 12:27 AM PDT
Both Tomcat and Struts are successful open source projects. The former is a world class servlet/JSP container, the latter a very popular framework for building Model 2 Web applications. And, lots of people use the combination of both. Here is a module that helps develop Struts applications more rapidly. As you may know, you can configure Tomcat to automatically reload an application if the web.xml file has been modified or a class/library has been added/modified. This really saves time because you don't have to reload your application yourself. Even if you are using the Tomcat Admin application, this feature still saves you many clicks of mouse buttons. However, Tomcat cannot be configured to reload a Struts application if the Struts configuration file (struts-config.xml) file has changed. This is unfortunate because the struts-config.xml changes frequently during development. This module, which you can download from BrainySoftware.com, is a Tomcat plugin that does not require you to do anything other than copying it to a directory. It works by overriding the WebappLoader, a Tomcat component responsible for loading Web applications. The Context component in Tomcat supports auto-reload. When this feature is enabled, the WebappLoader's modified method gets called regularly. This method checks if any class under WEB-INF/classes or any JAR file under WEB-INF/lib has been changed. If it has, the modified method returns true and the Context is reloaded. public boolean modified() { to public boolean modified() { which means, the modified method will return true if the struts-config.xml has been modified since the last time it was checked. long strutsConfigLastModified = getStrutsConfigTimestamp(); private String getContextPath() { protected long getStrutsConfigTimestamp() { ServletContext servletContext = ((Context) container).getServletContext(); if (servletContext == null) protected boolean checkStrutsConfig() { I hope you find this useful. (This is also my answer to readers of my "How Tomcat Works" book who, after learning to be better programmers by examining how the Tomcat Development Team designed and developed Tomcat, asked if I had an example of how to extend Tomcat.) »
Related Topics >>
Tools Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|