You are previewing Enterprise J2ME™: Developing Mobile Java™ Applications.
O'Reilly logo
Enterprise J2ME™: Developing Mobile Java™ Applications

Book Description

Industrial-strength J2ME™ for enterprise developers, architects, and decision-makers

J2ME offers an extraordinarily flexible and robust platform for developing mobile applications with enterprise-class performance, reliability, and value. Now, leading mobile developer Michael Yuan covers every aspect of building industrial-strength applications with J2ME: design, architecture, tools, processes, business issues, and more.

Yuan introduces innovations that make the platform even more powerful, ranging from new J2ME profiles and wireless messaging APIs to mobile databases and web services tools. These innovations allow existing Java™ developers (especially J2EE™ developers) to leverage their skills and add mobility to enterprise applications. Yuan also presents more than a dozen complete sample applications—including the application that earned him the grand prize in Nextel, Sun, and Motorola’s nationwide wireless developer contest. Coverage includes:

  • Patterns and best practices for building end-to-end mobile applications

  • Emerging mobile “killer applications”: driving productivity and cost reduction

  • “Smart client” applications: architecture and construction

  • Advanced HTTP techniques for authentication and session tracking

  • Overcoming hardware and network limitations

  • Leading-edge mobile enterprise messaging techniques

  • Mobile databases and synchronization engines

  • XML and mobile web services, including the J2ME Web Services Optional Package

  • New options for mobile security in the enterprise

Table of Contents

  1. Copyright
    1. Dedication
  2. About Prentice Hall Professional Technical Reference
  3. Foreword
  4. About this Book
    1. Target Audience
    2. Prerequisites
    3. Contents
    4. Code Examples
    5. Commercial Products
    6. Related Publications
    7. Production Notes
  5. Acknowledgments
  6. I. Introduction
    1. 1. Mobile Commerce: Visions, Realities, and Opportunities
      1. 1.1. Mobile Commerce Value Propositions
        1. 1.1.1. Business to Consumer (B2C)
        2. 1.1.2. Business to Business (B2B)
        3. 1.1.3. Business to Employee (B2E)
        4. 1.1.4. Public Services and Safety
      2. 1.2. Mobile Technology Adoption
      3. 1.3. The Search for Killer Mobile Applications
        1. 1.3.1. Mobile Entertainment
        2. 1.3.2. From Toys to Tools
        3. 1.3.3. The Enterprise Mobility Eco-system
      4. 1.4. Mobile Commerce Landscape
        1. 1.4.1. Mobile Device Manufacturers
        2. 1.4.2. Mobile Internet Service Providers
        3. 1.4.3. Mobile Software Platform Providers
        4. 1.4.4. Mobile Application Service Providers
      5. 1.5. Summary
      6. Resources
        1. Bibliography
    2. 2. J2ME: Is Mobile Java Ready for Enterprise?
      1. 2.1. Why Java?
      2. 2.2. The Java Community Process
      3. 2.3. Java Everywhere
        1. 2.3.1. The Single Architecture Solution
        2. 2.3.2. Opportunities for J2EE Developers
      4. 2.4. Java 2 Micro Edition Explained
        1. 2.4.1. J2ME Architecture
        2. 2.4.2. J2ME Components
      5. 2.5. Competing Technologies
      6. 2.6. Summary
      7. Resources
        1. Bibliography
  7. II. End-to-End Enterprise Applications
    1. 3. The Smart Client Paradigm: iFeedBack
      1. 3.1. Benefits of Smart Clients
      2. 3.2. Introducing iFeedBack
        1. 3.2.1. The Problems to Solve
        2. 3.2.2. Architecture
        3. 3.2.3. Real-World Deployment
      3. 3.3. iFeedBack Usage Scenarios
        1. 3.3.1. Build and Deploy
        2. 3.3.2. Try It Out!
      4. 3.4. Implementation Walk Through
        1. 3.4.1. The Call Model
        2. 3.4.2. The Threading Model
        3. 3.4.3. Data Exchange
      5. 3.5. Summary
      6. Resources
        1. Bibliography
    2. 4. Managed Smart Clients
      1. 4.1. Container-Managed Applications
        1. 4.1.1. Container Features
        2. 4.1.2. Benefits of Containers
      2. 4.2. OSGi Containers
        1. 4.2.1. Bundles
        2. 4.2.2. Standard Services
        3. 4.2.3. Bundle Interaction and Custom Services
        4. 4.2.4. OSGi Runtime Requirements
      3. 4.3. A Simple Echo Service Example
        1. 4.3.1. The IBM Service Management Framework
        2. 4.3.2. The EchoService Bundle
        3. 4.3.3. The EchoUIConsumer Bundle
      4. 4.4. Smart Client with HTTP Front End
        1. 4.4.1. The Pizza Order Bundle
        2. 4.4.2. The Pizza Order Servlet
        3. 4.4.3. The Logging Service
        4. 4.4.4. Rich UI Clients for the HTTP Service
      5. 4.5. Mobile Gateways
      6. 4.6. Summary
      7. Resources
        1. Bibliography
    3. 5. Mobile Design Patterns: The Smart Ticket Blueprint
      1. 5.1. Getting Started
      2. 5.2. Smart Ticket in Action
        1. 5.2.1. Manage User Preferences
        2. 5.2.2. Search and Purchase Tickets
        3. 5.2.3. Rate Movies
        4. 5.2.4. Cache Theater Schedules
      3. 5.3. Important Architectural Patterns
        1. 5.3.1. The Overall MVC Pattern
        2. 5.3.2. The Clientside Facade
        3. 5.3.3. The Serverside Facade
      4. 5.4. Implementation Techniques
        1. 5.4.1. Chain of Handlers
        2. 5.4.2. Binary RPC over HTTP
        3. 5.4.3. The Clientside Thread Model
      5. 5.5. Summary
      6. Resources
        1. Bibliography
    4. 6. Advanced HTTP Techniques
      1. 6.1. The Decorator Approach
        1. 6.1.1. The CustomConnector Factory Class
        2. 6.1.2. The CustomConnection Class
        3. 6.1.3. Decorator Pros and Cons
      2. 6.2. The Process-Chain Approach
        1. 6.2.1. The HttpClient Source Code
      3. 6.3. Session Tracking via HTTP Cookies
        1. 6.3.1. Handle Cookies via Decorator Classes
        2. 6.3.2. Handle Cookies via HttpClient Handlers
      4. 6.4. HTTP Basic Authentication
        1. 6.4.1. Code Example
      5. 6.5. HTTP Digest Authentication
        1. 6.5.1. Code Example
      6. 6.6. Secure HTTP
        1. 6.6.1. HTTPS Support in the MIDP
      7. 6.7. Summary
      8. Resources
        1. Bibliography
    5. 7. End-to-End Best Practices
      1. 7.1. Limited Device Hardware
        1. 7.1.1. Lightweight Libraries
        2. 7.1.2. Reduce Application Footprint
        3. 7.1.3. Minimize the Garbage Collector
        4. 7.1.4. Use Mobile Portals
        5. 7.1.5. Use Design Patterns Judiciously
      2. 7.2. Slow, Unreliable Networks
        1. 7.2.1. Support the Offline Mode
        2. 7.2.2. Use Remote Facades
        3. 7.2.3. Place Portals Locally
        4. 7.2.4. Buffered I/O
        5. 7.2.5. Encrypt Your Data
        6. 7.2.6. Obtain Server Status Efficiently
      3. 7.3. Pervasive Devices
        1. 7.3.1. Protect On-Device Data
        2. 7.3.2. Synchronize Often
        3. 7.3.3. Optimize for Many Devices
        4. 7.3.4. Centralized Provisioning
      4. 7.4. Ubiquitous Integration
        1. 7.4.1. Proprietary Binary Protocols
        2. 7.4.2. Use Mobile RPC Frameworks
        3. 7.4.3. Messaging Is Our Friend
        4. 7.4.4. XML and Web Services
      5. 7.5. The Impatient User
        1. 7.5.1. Take Advantage of the Rich UI
        2. 7.5.2. Use Threads Judiciously
        3. 7.5.3. One Screen at a Time
        4. 7.5.4. Store User Preferences
        5. 7.5.5. Use Deployment Descriptors
      6. 7.6. Summary
      7. Resources
        1. Bibliography
  8. III. Mobile Messaging Applications
    1. 8. Email and PIM
      1. 8.1. Basics of Email
        1. 8.1.1. The SMTP Server
        2. 8.1.2. The POP3/IMAP Server
      2. 8.2. Introducing Mail4ME
        1. 8.2.1. Send Email
        2. 8.2.2. Receive and Manipulate Messages
        3. 8.2.3. Display Message Parts
      3. 8.3. The JavaPhone API
      4. 8.4. The PDA Optional Package
      5. 8.5. Commercial Email and PIM Suites
        1. 8.5.1. The Espial Suite
        2. 8.5.2. The ReqWireless Suite
      6. 8.6. Corporate Portal Servers
        1. 8.6.1. BlackBerry Email
        2. 8.6.2. BlackBerry PIM
      7. 8.7. Summary
      8. Resources
        1. Bibliography
    2. 9. Converged Mobile P2P Messaging
      1. 9.1. Introducing the Wireless Messaging API
        1. 9.1.1. Top-Level WMA Classes
        2. 9.1.2. URLs and Message Connections
      2. 9.2. WMA in Action
        1. 9.2.1. Send SMS Messages
        2. 9.2.2. Synchronously Receive SMS Messages
        3. 9.2.3. Asynchronously Receive SMS Messages
        4. 9.2.4. Receive SMS Message via MIDP PUSH
      3. 9.3. WMA Reference Implementation
        1. 9.3.1. Runtime Properties
        2. 9.3.2. WMA Console in J2ME WTK v2.0
        3. 9.3.3. Architecture
      4. 9.4. SMS from the Back End
        1. 9.4.1. The jSMS API
        2. 9.4.2. The Simplewire Java SMS SDK
        3. 9.4.3. The Nokia Mobile Server Services SDK
        4. 9.4.4. Standardize the Serverside Messaging API
      5. 9.5. Beyond SMS: The IM Convergence
        1. 9.5.1. Introducing Jabber
        2. 9.5.2. The Jabber Protocol: XMPP
        3. 9.5.3. The KVMJab Jabber Library
        4. 9.5.4. Other Commercial Jabber Clients
      6. 9.6. SIP-Based IM Applications
        1. 9.6.1. The SIP API for J2ME
      7. 9.7. Summary
      8. Resources
        1. Bibliography
    3. 10. Enterprise Messaging
      1. 10.1. Mobile Enterprise Messaging
        1. 10.1.1. Mobile MOM
      2. 10.2. Introducing the JMS
        1. 10.2.1. Top-Level Interfaces
        2. 10.2.2. Publish-and-Subscribe Model
        3. 10.2.3. Point-to-Point Model
        4. 10.2.4. Combine the Two Messaging Models
      3. 10.3. Mobile JMS from iBus//Mobile
        1. 10.3.1. J2ME JMS Clients
        2. 10.3.2. The Lightweight Client for MIDP
        3. 10.3.3. Non-Programmable Clients
      4. 10.4. The IBM WebSphere MQ Everyplace
        1. 10.4.1. A Truly Mobile MOM Solution
        2. 10.4.2. HelloWorld Code Walk Through
        3. 10.4.3. Storage Adapters
        4. 10.4.4. The Administration Queue
        5. 10.4.5. Communications Adapters
      5. 10.5. Summary
      6. Resources
        1. Bibliography
  9. IV. Mobile Databases and Synchronization Engines
    1. 11. Mobile Database for CDC Devices
      1. 11.1. Database on the Go
      2. 11.2. Introducing JDBC
        1. 11.2.1. A JDBC Example
        2. 11.2.2. Obtain a Connection Object
        3. 11.2.3. Execute a SQL Statement
        4. 11.2.4. Extract Search Results
      3. 11.3. Portable and Efficient Code Using PreparedStatement
        1. 11.3.1. Problems with the Statement Interface
        2. 11.3.2. Use of the PreparedStatement Interface
      4. 11.4. Access Stored Procedures Using CallableStatement
        1. 11.4.1. What Is a Stored Procedure?
        2. 11.4.2. Use of the CallableStatement Interface
      5. 11.5. The JDBC Optional Package for the CDC
      6. 11.6. HSQL Database Engine
      7. 11.7. iAnywhere Solutions SQL Anywhere Studio
        1. 11.7.1. Use an UltraLite Custom Database
      8. 11.8. IBM DB2 Everyplace
      9. 11.9. Oracle9i Lite
      10. 11.10. PointBase Micro Edition
      11. 11.11. Example Application: Contact Manager
      12. 11.12. Summary
      13. Resources
        1. Bibliography
    2. 12. Mobile Databases for MIDP Devices
      1. 12.1. PointBase Micro Edition
      2. 12.2. The Oracle J2ME SODA SDK
      3. 12.3. The IBM DB2e FastRecordStore
      4. 12.4. Summary
      5. Resources
        1. Bibliography
    3. 13. Database Synchronization
      1. 13.1. Synchronization and Mobility
        1. 13.1.1. The Disconnected but Synchronized Architecture
        2. 13.1.2. Mobile Database Synchronization
      2. 13.2. PointBase UniSync
        1. 13.2.1. Serverside Code Walk Through
        2. 13.2.2. Clientside Code Walk Through
      3. 13.3. IBM DB2 Everyplace
        1. 13.3.1. Access DB2e Sync Programmatically
        2. 13.3.2. Sync with MIDP FastRecordStore
      4. 13.4. iAnywhere Solutions MobiLink
        1. 13.4.1. MobiLink via Standalone Native Clients
        2. 13.4.2. Access MobiLink Programmatically
      5. 13.5. Oracle9i Mobile Server
      6. 13.6. The Synchronized Contact Manager
      7. 13.7. Summary
      8. Resources
        1. Bibliography
    4. 14. Access Backend Databases
      1. 14.1. Direct Access to Remote Databases
        1. 14.1.1. Application-Specific Middleware
        2. 14.1.2. Using JDBC
        3. 14.1.3. Gateway Servlet
      2. 14.2. The Oracle J2ME SQL SDK
      3. 14.3. Legacy Applications
        1. 14.3.1. Screen Scraping
      4. 14.4. Using Simplicity for Legacy Databases
        1. 14.4.1. Simplicity Mobile
        2. 14.4.2. Simplicity Enterprise Legacy Rejuvenation
      5. 14.5. Summary
      6. Resources
        1. Bibliography
  10. V. XML and Mobile Web Services
    1. 15. XML for Small Devices
      1. 15.1. What Is XML?
      2. 15.2. Challenges for Small Devices
      3. 15.3. XML Parsing Models
        1. 15.3.1. SAX
        2. 15.3.2. XMLPull
        3. 15.3.3. Document Model
      4. 15.4. Introducing Amazon XML Services
      5. 15.5. Amazon Services via XmlPull
      6. 15.6. Amazon Services via kDOM
      7. 15.7. A Mobile RSS Client
        1. 15.7.1. A Simple RSS Example
        2. 15.7.2. PeekAndPick
      8. 15.8. Summary
      9. Resources
        1. Bibliography
    2. 16. SOAP Web Services on Smart Clients
      1. 16.1. What Is SOAP Web Services?
        1. 16.1.1. The SOAP Advantage
        2. 16.1.2. SOAP Hello World
        3. 16.1.3. Architecture of SOAP Web Services
      2. 16.2. Introducing kSOAP
        1. 16.2.1. What Is SOAP Parsing?
        2. 16.2.2. Simple Parsing Example Using kSOAP
        3. 16.2.3. How the call() Method Works
        4. 16.2.4. kSOAP Message Transport
        5. 16.2.5. kSOAP Stub Generators
      3. 16.3. kSOAP Explained
        1. 16.3.1. The Default Mapping
        2. 16.3.2. Object Structure
        3. 16.3.3. Custom Mapping Through Data Marshal
        4. 16.3.4. A More Complex Example
        5. 16.3.5. Recap: The kSOAP API
      4. 16.4. Advanced kSOAP
        1. 16.4.1. Arrays
        2. 16.4.2. Validate Documents Using SoapTemplate
      5. 16.5. More kSOAP Examples
        1. 16.5.1. The Google Web Services API Demo
        2. 16.5.2. SmartPhrases
      6. 16.6. What’s in kSOAP v2.0?
        1. 16.6.1. Programming for kSOAP v2.0
      7. 16.7. Summary
      8. Resources
        1. Bibliography
    3. 17. The J2ME Web Services Optional Package
      1. 17.1. A Little History
      2. 17.2. The XML Processing API
        1. 17.2.1. The API
      3. 17.3. The JAX-RPC API
        1. 17.3.1. Features
        2. 17.3.2. The API
        3. 17.3.3. A User Scenario
      4. 17.4. The SPI for Implementers
        1. 17.4.1. Support for Gateway-Based Clients
      5. 17.5. Compare with kXML and kSOAP
      6. 17.6. Summary
      7. Resources
        1. Bibliography
    4. 18. Case Study: Mobile Clients for Location-Based Services
      1. 18.1. Location-Based Services
      2. 18.2. Microsoft MapPoint Web Services
        1. 18.2.1. The MapPoint v3.0 SOAP API
        2. 18.2.2. The Aggregated API
        3. 18.2.3. The Axis Facade
      3. 18.3. MapPoint J2ME Clients
        1. 18.3.1. CDC/PP and PersonalJava Clients
        2. 18.3.2. MIDP Clients
      4. 18.4. Enhancing the Driving Directions Application
        1. 18.4.1. Location Determination Techniques
        2. 18.4.2. The Location API for J2ME
      5. 18.5. Summary
      6. Resources
        1. Bibliography
  11. VI. Advanced Mobile Security
    1. 19. Mobile Security for Enterprise
      1. 19.1. What Is Advanced Mobile Security?
        1. 19.1.1. Content-Based Security
        2. 19.1.2. Distributed Access Control
        3. 19.1.3. Device Security
      2. 19.2. Lightweight Mobile Cryptography Toolkits
        1. 19.2.1. General Requirements
      3. 19.3. Bouncy Castle Lightweight API
        1. 19.3.1. The Power of Open Source
        2. 19.3.2. Things to Watch Out For
      4. 19.4. The IAIK ME JCE
        1. 19.4.1. Porting Existing JCE Applications
      5. 19.5. Phaos Technology Micro Foundation Toolkit
        1. 19.5.1. The Phaos Micro Foundation
      6. 19.6. NTRU jNeo for Java Toolkit
        1. 19.6.1. The jNeo Package
      7. 19.7. B3 Security
        1. 19.7.1. How Does B3 Work?
        2. 19.7.2. Advantages
      8. 19.8. Device-Specific APIs
      9. 19.9. Standardization of J2ME Security APIs
      10. 19.10. Summary
      11. Resources
        1. Bibliography
    2. 20. The J2ME Crypto Recipes
      1. 20.1. Overview of Recipes
        1. 20.1.1. The Package Structure
        2. 20.1.2. Key Serialization
      2. 20.2. Symmetric Encryption
        1. 20.2.1. Bouncy Castle
        2. 20.2.2. IAIK JCE-ME
        3. 20.2.3. Phaos Micro Foundation
        4. 20.2.4. NTRU jNeo
      3. 20.3. Password-Based Encryption
        1. 20.3.1. Bouncy Castle
        2. 20.3.2. IAIK JCE-ME
        3. 20.3.3. Phaos Micro Foundation
      4. 20.4. Public Key Encryption
        1. 20.4.1. Bouncy Castle
        2. 20.4.2. IAIK JCE-ME
        3. 20.4.3. Phaos Micro Foundation
        4. 20.4.4. NTRU jNeo
      5. 20.5. Digital Signature
        1. 20.5.1. Bouncy Castle
        2. 20.5.2. IAIK JCE-ME
        3. 20.5.3. Phaos Micro Foundation
        4. 20.5.4. NTRU jNeo
      6. 20.6. Summary
      7. Resources
        1. Bibliography
  12. A. Basics of J2ME Application Development
    1. A.1. Life Cycle Methods
    2. A.2. UI Model
    3. A.3. Remote and Local Data
    4. A.4. Code Walk Through
    5. A.5. Packaging and Building
    6. A.6. Deployment
    7. A.7. Summary
  13. B. Tools and J2ME Runtimes for PDAs
    1. B.1. Overview of the WebSphere Studio Device Developer
    2. B.2. Installing MIDP on PocketPC Devices
    3. B.3. Installing Personal Profile on PocketPC Devices
    4. B.4. Run Java Applications on the PocketPC Device
    5. B.5. Summary