Overview
The first Java technology blueprint, Java Pet Store, was released in 2001 as a showcase for Sun's J2EE technologies. The blueprint not only provides sample code for a multilayered, database-driven e-commerce application, it also furnishes design guidelines and demonstrates commonly used patterns. Since that first release, the Java blueprints have become one of the most important resources for developers wanting to learn the latest J2EE technologies and best practices.
The Smart Ticket blueprint adds a new dimension: mobility. It demonstrates how to build a complete end-to-end mobile commerce system for ordering movie tickets, using J2ME MIDP for a wireless front end and a J2EE application server and a relational database at the back end. Studying how this application is designed and built will greatly enhance your understanding of the problems of mobile entERPrise applications – and their solutions.
This article covers version 2.0 Early Access of the Smart Ticket code, released in April 2003. The screen shots and code samples in the early-access version may change slightly in the final release, but the lessons you learn from the design should still hold. Smart Ticket 1.2 is still available. It has the same model and back-end implementation as the version discussed here, so many of the details are applicable to both past and future releases. Unless otherwise noted, all source code in this article is copyrighted by Sun Microsystems.
Download and Installation
The Smart Ticket application is available from Sun's Blueprints web site. The .zip archive contains source code, Ant build scripts, and pre-built, deployable applications.
Smart Ticket contains a J2ME component and a J2EE component. Running it requires a J2EE application server (such as the Sun J2EE reference implementation, version 1.3 or higher), and either a MIDP 2.0-compatible device with Internet connectivity or a suitable emulator, such as the one in Sun's J2ME Wireless Toolkit 2.0. The Smart Ticket distribution contains specific instructions for building and deploying the application. To get started:
-
Make sure you have these resources installed:
- JDK v1.4.1 or higher
- J2EE v1.3.1 or higher
- J2ME Wireless Toolkit 2.0 or higher
-
Set the following environment variables:
JAVA_HOME: JDK installation directoryJ2EE_HOME: J2EE RI installation directoryJ2MEWTK_HOME: J2ME Wireless Toolkit installation directory
-
Start the J2EE server:
J2EE_HOME/bin/cloudscape -start J2EE_HOME/bin/j2ee -verbose
Deploy the J2EE application. Use the
setupscript as follows to invoke thedeployAnt task insetup.XML:setup deploy
Point your browser to
http://localhost:8000/smartticketand click on the Populate Database link to import mock theater and movie data into the database. This is a very slow process on older computers, so be patient! The mock data includes theaters in two Zip codes: 95054 and 95130.Start J2ME Wireless Toolkit 2.0 and run the MIDlet described in
smart_ticket-client.jad.
Smart Ticket in Action
When you have the MIDlet running, take a brief tour to get the user's perspective. You'll find you can perform four kinds of tasks.
- Manage user preferences: When you start the MIDP client for the first time, you'll be asked to create a profile with a username, password, preferred Zip codes for theater search, preferred day of the week and, optionally, credit-card numbers. Smart Ticket uses the account credentials to create a user account on the server side, and caches the preference data on the device. You could also configure the MIDP client to cache the credentials so that you don't need to sign in manually every time you want to purchase tickets or submit movie ratings. You can modify user preferences at any time.
(Click image to enlarge.) - Search for films and purchase tickets: Once you've logged in, you can search among theaters, movies, and show times that reflect your preference data. Once you select a show, the MIDlet presents a seating map that shows available seats. This process involves a series of real-time queries to the J2EE server. Taking advantage of MIDP's rich UI, you can select a seat and make a reservation. The reservation is written to the server database and will be reflected on the seating map in the next search.
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




