Expert Spring MVC and Web Flow

(Dana P.) #1

Summary


Before any work was done on the web layer, we first analyzed the use cases to develop both a
domain object model and a service layer. Focusing first on these layers forces us to design the
core of the system without dependencies on the web layer. We also are forced into keeping all
of the core business logic in the object model.
The two use cases influenced the FlightServiceinterface, supporting both a read-only
method (getSpecialDeals()) and a query-and-response method (findFlights()).
As the last step, the FlightServiceimplementation is defined as a Spring bean inside the
applicationContext.xmlso that it may be easily injected into our web components.

Web Components


With the service layer built, it is now time to expose the use cases to the web. In this section we
will both create the classes and configure the web application to initialize and host the code.

JAR Dependencies


The Spring Framework ships with a main spring.jarcontaining everything you will need.
This book and all of its examples will work with version 1.2 or later. You may obtain this JAR,
along with the source code, from http://www.springframework.org.
If for some reason disk space is a real issue, you may prefer to use the smaller JAR files
also packaged with the distribution. These JAR files package each section of the framework
individually, offering you the ability to pick and choose which features of the Spring Frame-
work you wish to bundle with the application. If you choose to use the smaller individual JARs,
refer to Table 4-1 for the minimum required.

Table 4-1.Minimum Module-Specific Required Spring JARs
JAR Contents Dependencies
spring-core Core utilities commons-logging
spring-beans JavaBeans support, bean container spring-core
spring-context ApplicationContext, validation, spring-beans
JNDI, UI context support
spring-web WebApplicationContext, MultipartResolver, spring-context, servlet
web utilities, third-party framework support
spring-webmvc Framework servlets, Web mvc framework, web spring-web
controllers, web views

■CautionThe upcoming release of Spring 2.0 will have a different JAR packaging strategy. To be safe,
continue to use the full spring.jar,and monitor the release notes, which is the safest option for future
upgrades.

50 CHAPTER 4 ■JUMP INTO SPRING MVC

Free download pdf