Tag Archives: spring book

Spring Book – Part IV – Enterprise Application Development

Enterprise application requires many services to realize various uses cases. These services are mandatory and form the backbone of the application in many ways. Changing business scenarios requires changing and updating these services at various changes according to demand. With Spring’s capability, this can be achieved very easily catering integration with evolving opens-source technologies and solutions.

This part of the book contains Chapters which will help you in developing enterprise application having all the required enterprise services helping you realize business use case with the help of Spring Framework.

Chapter 16, “Web Services – Spring WS”, introduces you to the Spring’s capability of supporting web services in your application. After reading through this Chapter, you will have clear idea of all the terminologies related to web services and will also have a clear idea of the support provided by Spring to create and use web services in your application.

Chapter 17, “Messaging with Spring”, will initially cover messaging concepts in some detail. Later on we will cover JMS and its components in detail. We will then deep-dive into the support provided by Spring in applying messaging to your application. We will then go through the transaction support by JMS and again what Spring has to offer in this space. Last but not the least, the Chapter concluded with introduction and Spring’s support in achieving global transactions in your application.

Chapter 18, “Remoting”, we will first go through the basic concepts in remoting and then go on to the support provided by Spring. We will then go on in detail to cover the various remoting technologies which Spring supports in detail.

Chapter 19, “Tasks and Scheduling”, initially looks into the various concepts dealing with concurrency and then looks into Java support for doing this. Later on it looks into how Spring Framework can support doing this in your application. You should also be able to configure and use Quartz in your Spring application as well have the capability of using JDK’s timer support in your application.

Chapter 20, “Spring Integration”, will help you start with Spring Integration and will aid you in achieving the various integration requirement in your application. I am sure after reading through this Chapter you will have one more weapon up your sleeves which you can use and reap benefits from its high level of integration capabilities.

Chapter 21, “Spring Batch”, similar to other chapters will introduce you to Spring Batch in a comprehensive manner. Batch operation is one among the integral parts of modern day application and Spring’s support comes in the form of Spring Batch and we will deep dive into this in all aspects possible.

Chapter 16: Web Services – Spring WS

Chapter 17: Messaging with Spring

Chapter 18: Remoting

Chapter 19: Tasks and Scheduling

Chapter 20: Spring Integration

Chapter 21: Spring Batch

Page Visitors: 647

Model View Controller 2 architecture

Spring Book – Chapter 12 – Spring and Struts Integration

My humble effort to explain Spring and Struts integration in detail using code samples for easy understanding for my fellow developers and readers.

Apache Struts is more established, more used and well known MVC2 web framework in the Java world. I am sure anyone experienced with web application will surely have had a chance to work with this one of the pioneers in web framework.

Over the past few years there have been so many buzz words in the world of software development like Inversion of Control (IoC), AOP etc. These paradigms has revolutionized the software development and Spring being one of the frameworks adopting these new technologies into it and have become really good at it.

This Chapter makes a big assumption that the reader is conversant with the Struts Framework and that the reader would like to integrate the Spring Framework into the struts application so as to use the capabilities and out-of-box features provided by the Spring Framework.

If you like to take advantage of these features of Spring you do not have to rebuild the application, but you can integrate your existing Struts application with Spring without much hassle. This Chapter will let you do exactly this so that you can take the advantages of both worlds with good level of confidence and comfort. This Chapter is a very simple one and I am sure you will be able to complete it at one go without trouble whatsoever.

Apache Struts

Apache Struts 2 is an elegant, extensible framework for creating enterprise-ready Java web applications. The framework is designed to streamline the full development cycle, from building, to deploying, to maintaining applications over time.

Apache Struts 2 was originally known as WebWork 2. After working independently for several years, the WebWork and Struts communities joined forces to create Struts2. This new version of Struts is simpler to use and closer to how Struts was always meant to be.

Apache Struts in an MVC2 Java web framework. MVC2 is a servlet-centric architecture.  MVC2 incorporates a clear separation of view and controller. A controller receives all the requests, retrieves data from a Model and forwards it to next view for presentation.

In MVC2, there is a central Servlet (Controller) which calls business logic (Model) and the forwards it particular JSP page (View) that is why it is also called servlet-centric architecture. Pictorially MVC2 implementation is as shown in Figure 12-1 below.

 Model View Controller 2 architecture

Figure 12-1. MVC2 (Servlet-centric architecture)

WebWork was a Java-based web application framework developed by OpenSymphony which got merged into the current Struts2 web application framework. WebWork is built on top of XWork, which provides a generic command pattern framework as well as an Inversion of Control container.

Advantages of integrating Struts with Spring

The advantages of integrating a Struts application into the Spring Framework are:

  • Spring framework is based on new design approach and was designed to resolve the existing problems of existing Java applications. To a larger extent Spring has been successful in living to the expectations. Integrating Struts application with Spring buys in all the advantages provided out-of-box by Spring.
  • Spring framework lets you apply AOP (aspect-oriented programming technique) rather than object-oriented code. This is quite useful in addressing some very core concerns in any modern day enterprise application.
  • Spring provides more control on struts actions. That may depend on the method of integration you choose which we will cover in detail in the following sections of this Chapter.

Struts History

Before going through Spring and Struts integration in detail, because of the evolution complexity of Struts, we would have to first go through the Struts history with core focus on the versions. According to the Struts version that you use in your application, the integration methodology changes accordingly.

Struts were originally developed by the programmer and author Craig R. McClanahan and were later taken over by the Apache Software Foundation in 2002. Strut1 with all standard Java technologies and packages of Jakarta assists to create an extensible development environment. However, with the growing demand of web application, Struts 1 does not stand firm and needs to be changed with demand. This leads to the creation of Struts 2, which is more developer friendly with features like Ajax, rapid development and extensibility.

The team of Apache Struts and another J2EE framework, WebWork from OpenSymphony joined hand together to develop an advanced framework with all possible developing features that will make it developer and user friendly.

Even though the new version is Spring 2, we would still cover integration of Spring with Struts 1 as well so that if existing Struts 1 project needs the various capabilities of Spring, they can do so without much hassle.

Page Visitors: 6423