Chapter 9: Using JDO in a Swing Application


The Maine Lighthouse Rental Company is a fictitious business that rents light-houses in Maine to vacationers. In fact, the lighthouses used by the JDO Learning Tools are working lighthouses that are not available for rent, but the concept provides an excellent excuse to brighten up the example programs with scenes of the Maine coast. Any resemblance to a real rental business is both unexpected and coincidental.

The management of the Maine Lighthouse Rental Company wants a prototype of a reservation system. The requirements are expressed in 11 use cases. This chapter examines the rental Swing application, an implementation that satisfies these requirements. This implementation is a client/server application that uses Swing and JDO. The next chapter examines an implementation that uses servlets and JDO. In the last chapter of this book, the example makes use of JDO and Enterprise JavaBeans.

Building the Rental Swing Application

The rental Swing application is part of the JDO Learning Tools. Its build target is rental-gui. Chapter 8 discusses the mechanics of setting up the build environment and executing builds. If you have followed the instructions presented there successfully, you are ready to proceed in this chapter. If you have not, it is necessary to follow the directions in the "Getting Started" section in Chapter 8. After the build environment is set up, go to the bookants subdirectory under your bookcode-home directory. To build the rental Swing application, type the command

 ant rental-gui 

Listing 9-1 shows some of the expected output from building this target.

Listing 9-1: Selected Output from Running ant rental-gui

start example
 Buildfile: build.xml      ... rental-gui:      ...      [echo] creating runRentalConsole.bat      [echo] creating runRentalGui.bat BUILD SUCCESSFUL 
end example

The target rental-gui produces two executable classes, both called ReservationClient. One is in the com.ysoft.jdo.book.rental.client.console package and the other is in the com.ysoft.jdo.book.rental.client.gui package. The first has the console user interface discussed in Chapter 8. The second has a Swing user interface. The batch files runRentalConsole.bat and runRentalGui.bat start up the appropriate client class. The batch files work on Microsoft Windows. For other operating systems, you need to edit the batch files. 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. To bring up the rental Swing application, which is the focus of this chapter, go to the bookcode-home directory and execute the batch file runRentalGui.bat.




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