Is Struts Performant?
In my opinion, Struts will improve the performance of most properly-designed Web applications. The facilities provided by Struts must be provided by any significant Web application in some way. Since the implementation strategies for these services are efficient, overall performance improves. Here are some specific design points which contribute to the frameworks efficiency.
1) Struts is not only thread-safe but thread-dependant. The response to a request is handled by a light-weight
Actionobject, rather than an individualservlet. Struts instantiates eachActionclass once, and allows other requests to be threaded through the original object. This core strategy conserves resources and provides the best possible throughput. A properly-designed application will exploit this further by routing related operations through a singleAction.2)
ActionFormbeans minimize subclass code and shorten subclass hierarchies. Another key component in the Struts architecture is automatically populating anyActionFormbean from any request. Without this component, custom code may have to be written and instantiated to populate each class of bean. The careful use of reflection saves resources, which are always finite, allowing them to be put to better use.
3) The Struts tag libraries provide general-purpose functionality. Most any JSP tag need can be met by the bean and logic tags bundled with Struts, and reduce or eliminate the need to write and instantiate additional tags. The Java ServerPage specification includes tag reuse within a JSP, and using the same general purpose tag three times is more performant that using three different tags.
4) Struts components are reusable by the application. Utilities bundled with the framework have uses throughout most applications. TheBeanUtil.populate()method is a good example. This is used to populate form beans from a HTTP request, but can also be used to populate any bean from any type of map. Reusing components reduces overhead and saves resources.
5) Struts i18n strategies reduce the need for redundant JavaServer Pages. By allowing i18n message to be retrieved at runtime, applications that need internationalization can provide a single page where one page for each language would otherwise be needed. Meanwhile, the same messaging system is also used to handle error messages, providing dual use of the same objects.
6) Struts is designed with an open architecture. Struts components are designed so that they can be subclasses by an application to provide additional functionality. This allows developers to extend existing classes rather than add the overhead of creating and integrating new classes. Also, Struts exposes its internal resources to the application. This allows developers to leverage existing components, so they do not have to write and instantiate their own.
7) Struts is lightweight. Similar frameworks often use two or three hundred classes or tags. The entire Struts framework is made up of four tag libraries and four packages. There are only about fifty classes used by the framework, and a like number of tags.
8) Struts is standards compliant. Struts strict observance to standards leverage optimizations present in many containers. For example, field engineers report that Struts use ofJavaBeansis more performant than usingHashMapsfor the same purpose.9) Struts is open source and well documented. This means developers can easily examine the code to identify and resolve any potential bottlenecks
0) Struts is model neutral. Since Struts does not make any assumptions about the backend model, an application can implement that portion in the most efficient way possible. StrutsActionscan call a set of helper classes to access needed data. Once retrieved, Struts reliance onJavaBeansmakes it easy to retain value objects and reduce the number of calls to the Integration and (consequently) Resource layers.
-- Ted Husted, Husted dot Com.
Ted Husted is an independent software consultant specializing in developer training, code reviews, refactoring, and confidential priority support. For more information, visit the Husted dot Com Web site.