Datasheet

Try It Out Creating a Modularized Application
You can obtain the source code for this example from the Wrox download website (wrox.com). You can
find the directory under
src/chapter1/monolithic.
The following steps enable you to compile and run first the monolithic version of the Calculate applica-
tion, and then a version that is fully modularized.
1. You can compile the all-in-one Calculate class by going into the src/chapter1/monolithic
directory:
cd src/chapter1/monolithic
mvn compile
2. To run the all-in-one application, use the following command:
mvn exec:java -Dexec.mainClass=com.wrox.begspring.Calculate –Dexec.args=”3000 3”
This runs the com.wrox.beginspring.Calculate class and supplies the two numeric argu-
ments as
3000 and 3. Among the logging output from Maven, you should find the output from
the application:
The result of 3000 plus 3 is 3003!
3. The modularized version of the application is located in the src/chapter1/modularized
directory of the source code distribution. Compile the source using the following commands:
cd src/chapter1/modularized
mvn compile
4. Then run the modularized version of Calculate with the CalculateScreen command:
mvn exec:java -Dexec.mainClass=com.wrox.begspring.CalculateScreen –Dexec.args=”3000 3”
You should observe the same output from this modularized application as from the all-in-one application.
Note that you should be connected to the Internet when working with Maven 2. This is because Maven 2
automatically downloads dependencies from global repositories of open-source libraries over the Internet.
This can, for example, eliminate the need for you to download the Spring framework binaries yourself.
How It Works
The mvn command runs Maven 2. Maven 2 is a project management tool that you will use throughout
this book and it is great for handling overall project management. (Appendix A provides more informa-
tion about Maven 2 and can help you to become familiar with it.)
The refactored version of the Calculate application (
CalculateScreen) is fully modularized and is
easier to maintain and modify than the all-in-one version. Figure 1-1 contrasts the monolithic version
of
Calculate with the modularized version, called CalculateScreen.
7
Chapter 1: Jump Start Spring 2
01612c01.qxd:WroxPro 10/31/07 10:42 AM Page 7