http://www.developer.com/

Back to article

Modern Java Frameworks for Web Development


July 28, 2005

When mainstream computer applications moved to client-server architectures, programmers started to look for ways to simplify the development of projects that used similar technologies and were similar in structure. Thus, the foundations for modern software frameworks were laid.

As development for Web-based application servers and their applications expanded, so did the frameworks that supported these technologies. Currently, there are many software frameworks in the enterprise development space especially for the Java J2EE platform.

In this article, I will concentrate on modern Java development frameworks, discuss their features, and the advantages of using them. Also, I will compare several production quality frameworks, such as Struts, Spring, and Hibernate and go over basic similarities and underlying concepts.

I will briefly examine enterprise development environments or toolkits that were developed to support these frameworks, such as Borland JBuilder, Eclipse, and BEA Workbench. Keep in mind that there are books written on each of the frameworks, and it is impossible to describe in depth all aspects or features of them in any article space. However, I will try to discuss the most widely used concepts.

Common Ground

Almost all modern Web-development frameworks follow the Model-View-Controller (MVC) design. Business logic and presentation are separated and a controller of logic flow coordinates requests from clients and actions taken on the server. This approach has become the de facto of Web development. The underlying mechanics of each framework are of course different, but the APIs that developers use to design and implement their Eeb applications are very similar. The difference also lies in the extensions that each framework provides, such as tag libraries, Java Server Faces, or Java Bean wrappers.

All frameworks use different techniques to coordinate the navigation within the Web application, such as the XML configuration file, java property files, or custom properties. All frameworks also differ in the way the controller module is implemented. For instance, EJBs may instantiate classes needed in each request, or Java reflection can be used to dynamically invoke an appropriate action classes. Also, frameworks may differ conceptually. For example, one framework may define the user request and response (and error) scenario, and another may only define a complete flow from one request to multiple responses and subsequent requests.

Java frameworks are similar in the way they structure data flow. After request, some action takes place on the application server, and some data populated objects are always sent to the JSP layer with the response. Data is then extracted from those objects, which could be simple classes with setter and getter methods, java beans, value objects, or some collection objects. Modern Java frameworks also simplify a developer's tasks by providing automatic Session tracking with easy APIs, database connection pools, and even database call wrappers. Some frameworks either provide hooks into other J2EE technologies, such as JMS (Java Messaging Service) or JMX, or have these technologies integrated. Server data persistence and logging also could be part of a framework.

Enterprise Development Environments

Some frameworks became very popular within the Web developer community and enterprise development space. As these frameworks matured into stable releases, commercial IDE (integrated development environment) toolmakers started to build support for them into their products. Some even went as far as to develop whole products based on the concepts of the framework. For example, BEA WebLogic Workshop is build around the Struts framework.

Borland JBuilder has built-in support for Struts and features JSF and JSTL support as well.



Click here for a larger image.

The Eclipse platform became a very popular development tool, partly because of its plug-in base and partly because of its Web framework support. Numerous plug-ins to Eclipse or even entire distributions of Eclipse-based IDEs appeared. Many of the plug-ins were designed for Struts framework development, such as MyEclipse (www.myeclipse.org) or M7 (www.m7.com).

Most of the IDEs feature graphical flow and visual object (or class stub) development environments. For example, here is a JBuilder's Action designer that maps out page sequences of the Web application.



Click here for a larger image.

WebLogic Workshop introduced Java Page Flows, which extend the Struts framework to provide a simplified development model with numerous additional features. Workshop uses Page Flows that make it easy to separate the user interface from the navigation and business logic. A page flow consists of JSP pages that contain the user interface elements and a controller (JPF) file that contains instructions on how data provided by a user is processed and what page will be returned to the user next. A page flow provides a visual overview of the Web application that enables developers to see how the various JSP pages relate to each other and allows quick building of the overall architecture of the Web application.

MyEclipse provides similar features with a much more attractive price tag.



Click here for a larger image.

Apache Struts Framework

The Struts framework is an open-source product for building Web applications based on the model-view-controller (MVC) design paradigm. It uses and extends the Java Servlet API and was originally created by Craig McClanahan. In May 2000, it was donated to the Apache Foundation. It features a powerful custom tag library, tiled displays, form validation, and I18N (internationalization). Also, Struts supports a variety of presentation layers, including JSP, XML/XSLT, JavaServer Faces (JSF), and Velocity, as well as a variety of model layers, including JavaBeans and EJB.

Spring Framework

The Spring Framework is a layered Java/J2EE application framework based on code published in Expert One-on-One J2EE Design and Development. The Spring Framework provides a simple approach to development that does away with numerous properties files and helper classes that litter projects.

Key features of the Spring Framework include:

  • Powerful JavaBeans-based configuration management, applying Inversion-of-Control (IoC) principles.
  • A core bean factory, usable in any environment, from applets to J2EE containers.
  • Generic abstraction layer for database transaction management, allowing for pluggable transaction managers, and making it easy to demarcate transactions without dealing with low-level issues.
  • JDBC abstraction layer with a meaningful exception hierarchy.
  • Integration with Hibernate, DAO implementation support, and transaction strategies.

Hibernate Framework

Hibernate is an object-relational mapping (ORM) solution for the Java language. It is also open source software, as is Struts, and is distributed under the LGPL. Hibernate was developed by a team of Java software developers around the world. It provides an easy to use framework for mapping an object-oriented domain model to a traditional relational database. It not only takes care of the mapping from Java classes to database tables (and from Java data types to SQL data types), but also provides data query and retrieval facilities and can significantly reduce development time otherwise spent with manual data handling in SQL and JDBC.

Hibernate's goal is to relieve the developer from a significant amount of common data persistence-related programming tasks. Hibernate adapts to the development process, whether it is started with a design from scratch or from a legacy database. Hibernate generates the SQL, and relieves the developer from manual result set handling and object conversion, and keeps the application portable to all SQL databases. It provides transparent persistence, the only requirement for a persistent class is a no-argument constructor.

This framework is typically used in Java Swing applications, Java Servlet-based applications, or J2EE applications using EJB session beans.

Conclusion

This article is a general overview of modern or most popular frameworks. There are more frameworks than I have described here, of course, both open-source and commercial, such as WebWork http://www.opensymphony.com/webwork/ or Tapestry http://jakarta.apache.org/tapestry/, and many frameworks were in-house developed by extending some other MVC frameworks. Currently, the most popular framework is Apache Struts. As the Web development arena continues to evolve its tools and programming methodologies, so will the Java application frameworks continue to grow. The future looks bright for the Java Web-development frameworks.

References

Online:

WebWork Framework

Tapestry Framework

Wikipedia online: http://en.wikipedia.org/wiki/

BEA Workshop

Spring Framework

Hibernate Framework

Spring by Example: http://www.jroller.com/page/kdonald

Books:

Will Iverson: Hibernate: A J2EETM Developer's Guide, Addison-Wesley Professional, ISBN 0-321-26819-9

Christian Bauer, Gavin King: Hibernate in Action, Manning Publications Company, ISBN 1932394-15-X

About the Author

Vlad Kofman is a Senior System Architect. He has been involved with enterprise-level projects for major Wall Street firms and the U.S. government. His main interests are object-oriented programming methodologies and design patterns.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date