Programming Google App Engine with Java

Book description

This practical guide shows intermediate and advanced web and mobile app developers how to build highly scalable Java applications in the cloud with Google App Engine. The flagship of Google's Cloud Platform, App Engine hosts your app on infrastructure that grows automatically with your traffic, minimizing up-front costs and accommodating unexpected visitors. You’ll learn hands-on how to perform common development tasks with App Engine services and development tools, including deployment and maintenance.

For Java applications, App Engine provides a J2EE standard servlet container with a complete Java 7 JVM and standard library. Because App Engine supports common Java API standards, your code stays clean and portable.

  • Get a hands-on introduction to App Engine's tools and features, using an example application
  • Simulate App Engine on your development machine directly from Eclipse
  • Structure your app into individually addressable modules, each with its own scaling configuration
  • Exploit the power of the scalable Cloud Datastore, using queries, transactions, and data modeling with JPA
  • Use Cloud SQL for standard relational databases with App Engine applications
  • Learn how to deploy, manage, and inspect your application on Google infrastructure

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. A Brief History of App Engine
    2. Using This Book
    3. Conventions Used in This Book
    4. Safari® Books Online
    5. How to Contact Us
    6. Acknowledgments
  2. 1. Introducing Google App Engine
    1. The Runtime Environment
    2. The Static File Servers
    3. Frontend Caches
    4. Cloud Datastore
      1. Entities and Properties
      2. Queries and Indexes
      3. Transactions
    5. The Services
    6. Google Accounts, OpenID, and OAuth
    7. Google Cloud Endpoints
    8. Task Queues and Cron Jobs
    9. Namespaces
    10. Developer Tools
    11. The Cloud Console
    12. Getting Started
  3. 2. Creating an Application
    1. Setting Up the Cloud SDK
      1. Installing Java
      2. Installing Python
      3. Installing the Cloud SDK
      4. Authenticating with the Cloud SDK
      5. Installing the App Engine SDK
      6. Installing the Java SDK with the Google Plugin for Eclipse
    2. Developing the Application
      1. The User Preferences Pattern
      2. A Simple App
      3. Introducing JSPs, JSTL, and EL
      4. Users and Google Accounts
      5. Web Forms and the Datastore
      6. Caching with Memcache
      7. The Development Console
    3. Registering the Application
    4. Uploading the Application
    5. Testing the App
    6. Enabling Billing
  4. 3. Configuring an Application
    1. The App Engine Architecture
    2. Configuring a Java App
    3. App IDs and Versions
    4. Multithreading
    5. Request Handlers
    6. Static Files and Resource Files
    7. Domain Names
    8. Google Apps
    9. Configuring Secure Connections
    10. Secure Connections with Custom Domains
    11. Authorization with Google Accounts
    12. Environment Variables
    13. Inbound Services
    14. Custom Error Responses
    15. Java Servlet Sessions
  5. 4. Request Handlers and Instances
    1. The Runtime Environment
      1. The Sandbox
      2. Quotas and Limits
      3. The Java Runtime Environment
    2. The Request Handler Abstraction
    3. Introducing Instances
    4. Request Scheduling and Pending Latency
    5. Warmup Requests
    6. Resident Instances
    7. Instance Classes and Utilization
    8. Instance Hours and Billing
    9. The Instances Console Panel
    10. Traffic Splitting
  6. 5. Using Modules
    1. An Example Layout
    2. Configuring Modules
      1. The Enterprise Archive Layout
      2. Making Modules with Eclipse
    3. Manual and Basic Scaling
      1. Manual Scaling and Versions
    4. Startup Requests
    5. Shutdown Hooks
    6. Background Threads
    7. Modules and the Development Server
    8. Deploying Modules
    9. Addressing Modules with URLs
      1. Calling Modules from Other Modules
      2. Module URLs and Secure Connections
      3. Module URLs and Custom Domains
    10. Dispatching Requests to Modules
    11. Starting and Stopping Modules
    12. Managing and Deleting Modules and Versions
    13. The Modules API
    14. An Always-On Example
  7. 6. Datastore Entities
    1. Entities, Keys, and Properties
    2. Introducing the Java Datastore API
    3. Property Values
      1. Strings, Text, and Bytes
      2. Unset Versus the Null Value
      3. Multivalued Properties
    4. Keys and Key Objects
    5. Using Entities
      1. Getting Entities Using Keys
      2. Saving Entities
      3. Deleting Entities
    6. Allocating System IDs
    7. The Development Server and the Datastore
  8. 7. Datastore Queries
    1. Queries and Kinds
    2. Query Results and Keys
    3. The Query API
      1. Building the Query
      2. Fetching Results with PreparedQuery
      3. Keys-Only Queries
    4. Introducing Indexes
    5. Automatic Indexes and Simple Queries
      1. All Entities of a Kind
      2. One Equality Filter
      3. Greater-Than and Less-Than Filters
      4. One Sort Order
      5. Queries on Keys
      6. Kindless Queries
    6. Custom Indexes and Complex Queries
      1. Multiple Sort Orders
      2. Filters on Multiple Properties
      3. Multiple Equality Filters
    7. Not-Equal and IN Filters
    8. Unset and Nonindexed Properties
    9. Sort Orders and Value Types
    10. Queries and Multivalued Properties
      1. MVPs in Code
      2. MVPs and Equality Filters
      3. MVPs and Inequality Filters
      4. MVPs and Sort Orders
      5. Exploding Indexes
    11. Query Cursors
    12. Projection Queries
    13. Configuring Indexes
  9. 8. Datastore Transactions
    1. Entities and Entity Groups
      1. Keys, Paths, and Ancestors
      2. Ancestor Queries
    2. What Can Happen in a Transaction
      1. Transactional Reads
      2. Eventually Consistent Reads
    3. Transactions in Java
    4. How Entities Are Updated
    5. How Entities Are Read
    6. Batch Updates
    7. How Indexes Are Updated
    8. Cross-Group Transactions
  10. 9. Datastore Administration
    1. Inspecting the Datastore
    2. Managing Indexes
    3. Accessing Metadata from the App
      1. Querying Statistics
      2. Querying Metadata
      3. Index Status and Queries
      4. Entity Group Versions
    4. Remote Controls
      1. Setting Up the Remote API
      2. Using the Remote API with the Java Client Library
  11. 10. The Java Persistence API
    1. Setting Up JPA
    2. Entities and Keys
    3. Entity Properties
    4. Embedded Objects
    5. Saving, Fetching, and Deleting Objects
    6. Transactions in JPA
    7. Queries and JPQL
    8. Relationships
    9. For More Information
  12. 11. Using Google Cloud SQL with App Engine
    1. Choosing a Cloud SQL Instance
    2. Installing MySQL Locally
    3. Creating a Cloud SQL Instance
    4. Connecting to an Instance from Your Computer
    5. Setting Up a Database
    6. Setting Up JDBC
    7. Connecting to the Database from App Engine
    8. Backup and Restore
    9. Exporting and Importing Data
    10. The gcloud sql Commands
  13. 12. The Memory Cache
    1. Calling Memcache from Java
    2. Keys and Values
    3. Setting Values
      1. Setting Values That Expire
      2. Adding and Replacing Values
    4. Getting Values
    5. Deleting Values
      1. Locking a Deleted Key
    6. Atomic Increment and Decrement
    7. Compare and Set
    8. Batching Calls to Memcache
    9. Memcache and the Datastore
    10. Handling Memcache Errors
    11. Memcache Administration
      1. Cache Statistics
      2. Flushing the Memcache
  14. 13. Fetching URLs and Web Resources
    1. Fetching URLs
    2. Outgoing HTTP Requests
      1. The URL
      2. The HTTP Method and Payload
      3. Request Headers
    3. HTTP over SSL (HTTPS)
    4. Request and Response Sizes
    5. Request Deadlines
    6. Handling Redirects
    7. Response Objects
  15. 14. Sending and Receiving Email Messages
    1. Sending Email Messages
      1. Logging Sent Mail in the Development Server
      2. Sender Addresses
      3. Recipients
      4. Attachments
      5. Sending Email
    2. Receiving Email Messages
  16. 15. Sending and Receiving Instant Messages with XMPP
    1. Inviting a User to Chat
    2. Sending Chat Messages
    3. Receiving Chat Messages
      1. Receiving Chat Messages in Java
    4. Handling Error Messages
    5. Managing Presence
      1. Managing Subscriptions
      2. Managing Presence Updates
      3. Probing for Presence
  17. 16. Task Queues and Scheduled Tasks
    1. Configuring Task Queues
    2. Enqueuing a Task
    3. Task Parameters
      1. Payloads
      2. Task Names
      3. Countdowns and ETAs
    4. Push Queues
      1. Task Requests
      2. Processing Rates and Token Buckets
      3. Retrying Push Tasks
    5. Pull Queues
      1. Enqueuing Tasks to Pull Queues
      2. Leasing and Deleting Tasks
      3. Retrying Pull Queue Tasks
    6. Transactional Task Enqueueing
    7. Task Chaining
    8. Task Queue Administration
    9. Deferring Work
    10. Scheduled Tasks
      1. Configuring Scheduled Tasks
      2. Specifying Schedules
  18. 17. Optimizing Service Calls
    1. Calling Services Asynchronously
      1. The Asynchronous Call API
    2. Visualizing Calls with AppStats
      1. Installing AppStats
      2. Using the AppStats Console
  19. 18. Managing Request Logs
    1. Writing to the Log
    2. Viewing Recent Logs
    3. Downloading Logs
    4. Logs Retention
    5. Querying Logs from the App
  20. 19. Deploying and Managing Applications
    1. Uploading an Application
    2. Using Versions
    3. Managing Service Configuration
    4. App Engine Settings
    5. Managing Developers
    6. Quotas and Billing
    7. Getting Help
  21. Index

Product information

  • Title: Programming Google App Engine with Java
  • Author(s): Dan Sanderson
  • Release date: June 2015
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491903452