this print for content only—size & color not accurate 7.5 x 9.25 spine = x.xxx" xxx page count Roche Douglas eXPeRT’s VOIce ® In clOud cOmPuTIng Beginning Java ™ Google App Engine cYAn mAgenTA YellOW BlAcK PAnTOne 123 c Kyle Roche and Jeff Douglas Companion eBook Available Learn about the core components of the Google App Engine SDK, platform, and services for web developers using Java TM technology BOOKs fOR PROfessIOnAls BY PROfessIOnAls ® Beginning Java ™ Google App Engine Dear Reader, Cloud computing is becoming a model of choice for many developers like yourself. This book gives you the keys to Google App Engine, which is a major Cloud platform for Java TM . We’ll show you all the core components of the SDK, the platform, and the services that Google provides – the essentials for building a web application on App Engine. You'll learn how to put App Engine to work quickly, starting with the Google Plugin for Eclipse and moving on to the development server, the datastore, Java Data Objects (JDO), and Persistence as a Service. Then we'll show you how to use Spring as a Service for transaction, data access, and more. You'll see how you can create Ajax applications with Google Web Toolkit, and how to build Web apps that even integrate with Salesforce.com and Google Wave. And once your app is up and running, you'll learn how to monitor, manage, and maintain it. Beginning Java ™ Google App Engine gives you a complete guided tour of Google App Engine. Once you’ve read this book, you’ll be able to implement your next big project with this exciting new platform, with the knowledge and skills you’ve gained from this book as your foundation. Kyle Roche and Jeff Douglas Kyle Roche US $44.99 Shelve in: Web Development / Programming Languages / Java User level: Beginner to Intermediate FPO THE APRESS ROADMAP Pro Scala Pro Hadoop Beginning Java Google App Engine The Definitive Guide to Lift: A Scala-based Web Framework The Definitive Guide to Grails, Second Edition Beginning Java™ EE 6 Platform with GlassFish™ 3 Beginning Scala Beginning Groovy and Grails TM www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN 978-1-4302-2553-9 9 781430 225539 5 44 9 9 Beginning Jeff Douglas this print for content only—size & color not accurate 7.5 x 9.25 spine = x.xxx" xxx page count eRT’s VOIce ® In clOud cOmPuTI cYAn mAgenTA YellOW BlAcK PAnTOne 123 c OOKs fOR PROfessIOnAls BY PROfessIOnAls ® Beginning Java ™ Google App Engine Dear Reader, Cloud computing is becoming a model of choice for many developers like yourself. This book gives you the keys to Google App Engine, which is a major Cloud platform for Java TM . We’ll show you all the core components of the SDK, the platform, and the services that Google provides – the essentials for building a web application on App Engine. You'll learn how to put App Engine to work quickly, starting with the Google Plugin for Eclipse and moving on to the development server, the datastore, Java Data Objects (JDO), and Persistence as a Service. Then we'll show you how to use Spring as a Service for transaction, data access, and more. You'll see how you can create Ajax applications with Google Web Toolkit, and how to build Web apps that even integrate with Salesforce.com and Google Wave. And once your app is up and running, you'll learn how to monitor, manage, and maintain it. Beginning Java ™ Google App Engine gives you a complete guided tour of Google App Engine. Once you’ve read this book, you’ll be able to implement your next big project with this exciting new platform, with the knowledge and skills you’ve gained from this book as your foundation. Kyle Roche and Jeff Douglas Kyle Roche US $44.99 Shelve in: Web Development / Programming Languages / Java User level: Beginner to Intermediate FPO THE APRESS ROADMAP Pro Scala Pro Hadoop Beginning Java Google App Engine The Definitive Guide to Lift: A Scala-based Web Framework The Definitive Guide to Grails, Second Edition Beginning Java™ EE 6 Platform with GlassFish™ 3 Beginning Scala Beginning Groovy and Grails TM www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version Jeff Douglas Beginning Java ™ Google App Engine ■ ■ ■ Kyle Roche Jeff Douglas Beginning Java ™ Google App Engine Copyright © 2009 by Kyle Roche and Jeff Douglas All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-4302-2553-9 ISBN-13 (electronic): 978-1-4302-2554-6 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. President and Publisher: Paul Manning Lead Editor: Steve Anglin Developmental Editor: Tom Welsh Technical Reviewer: Kunal Mittal Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Kelly Moritz Copy Editor: Jill Steinberg Composition: ContentWorks, Inc. Indexer: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or visit http://www.springeronline.com. For information on translations, please e-mail info@apress.com, or visit http://www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at http://www.apress.com/info/bulksales. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com. You will need to answer questions pertaining to this book in order to successfully download the code. There’s an Irish saying . . . no man can prosper without his woman’s leave. —KR To Cathy, who has touched not only my heart, but the hearts of so many that will never remember her. I love you. —JD v Contents at a Glance Foreword xiii About the Authors xv About the Technical Reviewer xvii Acknowledgments xix Introduction xxi Chapter 1: Beginning Google App Engine for Java 1 Chapter 2: Introduction to App Engine 7 Chapter 3: Getting Started with Google App Engine for Java 25 Chapter 4: Servlet Container and Frameworks 43 Chapter 5: Developing Your Application 89 Chapter 6: Authenticating Users 123 Chapter 7: Using the App Engine Datastore 135 Chapter 8: App Engine Services 169 Chapter 9: Administration and Integration 197 Index 221 vi vii Contents Foreword xiii About the Authors xv About the Technical Reviewer xvii Acknowledgments xix Introduction xxi Chapter 1: Beginning Google App Engine for Java 1 Cloud Computing and App Engine 1 Find More Time to Innovate 4 What You’ll Learn in This Book 5 Summary 6 Chapter 2: Introduction to App Engine 7 App Engine Architecture 7 Being a Good Neighbor With Quotas 9 Billable and Fixed Quotas 10 Detailed Resource Quotas 12 Components of an App Engine Application 22 Summary 23 Chapter 3: Getting Started with Google App Engine for Java 25 Where Do We Start? 25 Create Your First App Engine Project 30 Local Development Server 37 Summary 42 ■ CONTENTS viii Chapter 4: Servlet Container and Frameworks 43 Choosing a Framework 43 Servlets and JavaServer Pages 46 Views 46 Model 59 Controller 64 Deployment Descriptor 69 PersistenceManager 69 Spring MVC 70 Server Configuration 71 Views 72 Adobe Flex 74 Server Configuration 76 Client-Side Code 79 Server-Side Code 83 Summary 88 Chapter 5: Developing Your Application 89 Functional Specifications 89 Timecard UI Mock-up 90 Technical Specifications 91 Authentication 91 Presentation 91 Persistence 92 Using Google Web Toolkit 92 Creating Your Project 93 Running the Initial Starter Application 96 Developing Your Application 97 Required Imports 101 Coding Your UI 102 . York, NY 10 013 . Phone 1- 8 00-SPRINGER, fax 20 1- 3 4 8-4 505, e-mail orders-ny@springer-sbm.com, or visit http://www.springeronline.com. For information on translations, please e-mail info @apress. com,. Introduction xxi Chapter 1: Beginning Google App Engine for Java 1 Chapter 2: Introduction to App Engine 7 Chapter 3: Getting Started with Google App Engine for Java 25 Chapter 4: Servlet Container. Frameworks 43 Chapter 5: Developing Your Application 89 Chapter 6: Authenticating Users 12 3 Chapter 7: Using the App Engine Datastore 13 5 Chapter 8: App Engine Services 16 9 Chapter 9: Administration