Building the Rental Web Application


To build the rental Web application, go to the bookants directory under your bookcode-home directory. Build the clean-out target first by executing the following command:

 ant clean-out 

Assuming that you have successfully built some of the examples from Chapters 8 and 9, you will see output that looks like the output in Listing 10-1.

Listing 10-1: Expected Output from Building the clean-out Target

start example
 E:\Bookcode\bookants>ant clean-out Buildfile: build.xml are-we-ready: verify: clean-out:      [echo] Deleting files in build, enhanced, and warfiles    [delete] Deleting 66 files from E:\Bookcode\build    [delete] Deleted 13 directories from E:\Bookcode\build    [delete] Deleting 8 files from E:\Bookcode\enhanced    [delete] Deleted 8 directories from E:\Bookcode\enhanced BUILD SUCCESSFUL Total time: 1 second 
end example

By cleaning out the old compiled files, you remove the compiled versions of the Rental, Week, Customer, and Lighthouse classes that were built for the rental Swing application. Although the rental Swing application can use the version of these classes built by the rental Web application, the opposite is not true. Some of the application data classes for the rental Web application support string identities and a versioning scheme, while the versions used by the rental Swing application do not. Both versions have the same persistent fields and therefore the same database schema.

Next, build the rental Web application by running its build target. Execute the following command:

 ant rental-servlet-opr 

You should see output that looks like the output shown in Listing 10-2. Building this target will shut down Tomcat if it is running. You must restart Tomcat to use the rental Web application.

Listing 10-2: Expected Output from Building the rental-servlet-opr Target

start example
 E:\Bookcode\bookants>ant rental-servlet-opr Buildfile: build.xml are-we-ready: ... copy-files:      [copy] Copying 6 files to E:\Bookcode\warfiles\WEB-INF\lib     [mkdir] Created dir: E:\Bookcode\warfiles\images      [copy] Copying 3 files to E:\Bookcode\warfiles\images    [delete] Deleting 53 files from E:\tomcat4.1.12\webapps\rental    [delete] Deleted 18 directories from E:\tomcat4.1.12\webapps\rental      [copy] Copying 53 files to E:\tomcat4.1.12\webapps\rental      [echo] You'll have to restart Tomcat BUILD SUCCESSFUL Total time: 43 seconds 
end example

The rental Web application satisfies all of the use cases described in Chapter 9 that define the rental application's requirements, except that it does not satisfy the first two use cases that describe the initialization and clearing of the datastore. Although a Web application could initialize a database, in practice, this is rarely done. Since the rental Web application uses the same data schema as the rental Swing application, you can use the Swing application to initialize the database.

If the rental data has not been initialized, you will need to build the rental-gui target and use the rental Swing application to initialize the rental data. To do this, execute the following build command:

 ant rental-gui 

Then change to the bookcode-home directory and execute the batch file runRentalGui.bat. If you are not using Microsoft Windows, you will need to alter the batch file for your operating system. The code is open source. If you feel inspired to contribute modified build scripts for other operating systems, they will be most welcomed at http://sourceforge.net/projects/jdo-tools. When the rental Swing application comes up, select the menu item Connect to datastore from the Connect menu. Then select the menu item Populate database from the File menu. Finally, to see the results, select the Available menu item from the View menu. For more details, see Chapter 9.

If you are using the JDO reference implementation, and this is your first time using the JDO Learning Tools, you will have to follow the directions in Chapter 8 to properly initialize the reference implementation's datastore. Also with the reference implementation, after you initialize the datastore and initialize the test data for the rental applications, you need to copy the two FOStoreTestDB files found in the bookcode-home directory to the bin subdirectory under your tomcat-home directory.




Using and Understanding Java Data Objects
Using and Understanding Java Data Objects
ISBN: 1590590430
EAN: 2147483647
Year: 2005
Pages: 156
Authors: David Ezzio

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net