Phil Zoio Discusses Bringing Java 5 Features to Struts with Strecks 1.0
The aim of Strecks is address perceived inadequacies of the original Struts programming model while still allowing full backward compatibility of applications. Strecks works with the most recent general availability Struts versions (1.2.8 and 1.3.5), but at the same time allows developers to work with advanced features expected from modern web frameworks. Strecks is aimed at developers who:
- have a significant existing investment in the current version of Struts, either in terms of knowledge or existing code
- are not currently ready or willing to take the pain of migrating to the forthcoming Struts 2.0 (based on WebWork) or another web framework
- want to take advantage of advanced features not available in vanilla Struts but increasingly so in other frameworks
InfoQ sat down with Strecks lead Phil Zoio to discuss the new project. First Zoio described the motivation for Strecks:
I was commissioned to work on a new project around August last year, and did not have a choice on the web framework, as it was mandated to be in Struts. Struts would not have been my choice at the time, so over the course of the project I added a few extensions which made the framework easier and more productive for me to use. After the project was complete, I decided to invest some effort into reworking these changes into something which I felt would be helpful for other developers in the same position as I was. In the process, I've also added a couple features which I don't think are present in any other mainstream framework. One example is the ability to extract common presentation logic into reusable action controllers, and another the ability to add enhancements using annotations which are fully self-describing.Zoio was then asked about the difficulties in bringing Java 5 support to Struts:
Quite a few things helped make the task easier. First, because Struts is quite a simple layer over basic Servlet/JSP dispatch model, I still had quite a few degrees of freedom to work with in adding functionality without ending up with anything overly complex. Secondly, by targeting JDK 5 only and making heavy use of annotations, Strecks takes advantage of opportunities for productivity gains not fully exhausted by Struts or other frameworks targeting a wider range of JDK versions. I've had to accept a few limitations in the framework imposed by the original Struts implementation choices, but some restrictions were easier to overturn. The best example is the requirement that a Struts action instance should be shared by multiple threads and not store request-specific state. Removing this restriction from Strecks opened up possibilities for dependency injection and a generally simpler action programming model.
Struts certainly needed some fairly radical changes to bring it more up to date. I'm not convinced, however, that the change they did eventually go for - adopting the WebWork code base - was either necessary or in the interests of the Struts or WebWork user communities as a whole.
Strecks extends the life of Struts by adding many Java 5 features developers have been wanting. Zoio was asked about where he sees Struts going in the years to come in comparison to the rise of Ajax and frameworks such as GWT:
Its very difficult to say. The key question over the next few years is whether pure Ajax frameworks or frameworks which contain a mixture of "traditional" elements enhanced by Ajax will come to dominate web application development. The purpose of traditional web frameworks in the pre-Ajax world is to allow for coherent, maintainable web applications, but the jury is still out as to whether these are fundamentally equipped to allow for coherent, maintainable web applications primarily based on Ajax functionality. The current generation of frameworks can handle small enhancements easily enough (e.g. auto suggest, dynamic drop downs, etc.). However, projects with ambitious interactivity requirements and bigger budgets will inevitable lean towards the use of pure Ajax style frameworks, and in these cases, frameworks such as Struts may be relegated at best to a supporting role. The challenge for frameworks like Struts will be to increase the range of common Ajax-style requirements they can easily accomodate. They need to find the right ways to add Ajax functionality, so that these additions don't just feel like "bolt ons" which don't add much real value over simply using Ajax libraries side-by-side and independently. The better they are able to do this, the greater is the range of projects in the future for which they will still be suitable. Although Strecks hasn't yet tackled Ajax, it is still quite well positioned in this respect, because Ajax type functionality (e.g. integration with tools like DWR) can be elegantly slotted in using custom action controllers, with application-specific hooks available to the action bean classes via annotations.
Pre-Ajax frameworks still have real advantages, not least of which is that they are well understood and simple to use. For as long as there is a spectrum of requirements, ranging from simple to highly interactive, I think there is plenty of room for both types of frameworks, and I expect this to be the case for the forseeable future.
Randy Shoup Jul 03, 2015