Introduction
Google App Engine lets we run web applications on Google's infrastructure. App Engine applications are easy to build, easy to maintain, and easy to scale as our traffic and data storage needs grow. With App Engine, there are no servers to maintain. Just upload application, and it's ready to serve users.
We can serve our app from our own domain name (such as http://www.example.com/) using Google Apps. Or, we can serve our app using a free name on the appspot.com domain. We can share our application with the world, or limit access to members of our organization.
App Engine costs nothing to get started. All applications can use up to 1 GB of storage and enough CPU and bandwidth to support an efficient app serving around 5 million page views a month, absolutely free. When enable billing for application, free limits are raised, and only pay for resources used above the free levels. We can register up to 10 applications per developer account.
The Application Environment
The Sandbox
Applications run in a secure environment that provides limited access to the underlying operating system. The sandbox isolates your application in its own secure, reliable environment that is independent of the hardware, operating system and physical location of the web server.
Example of the limitations of the secure sandbox environment is an application can only access other computers on the Internet through the provided URL fetch and email services. Other computers can only connect to the application by making HTTP (or HTTPS) requests on the standard ports.
Runtime environments
Our application can run in one of three runtime environments:
- Java : With App Engine's Java runtime environment, we can build our app using standard Java technologies, including the JVM, Java servlets, and the Java programming language—or any other language using a JVM-based interpreter or compiler, such as JavaScript or Ruby.
- Python: App Engine features two dedicated Python runtime environments, each of which includes a fast Python interpreter and the Python standard library.
- Go: App Engine provides a Go runtime environment that runs natively compiled Go code.
The Datastore
App Engine provides a distributed data storage service that features a query engine and transactions. Just as the distributed web server grows with traffic, the distributed datastore grows with your data.
The App Engine datastore is not like a traditional relational database. Data objects, or "entities," have a kind and a set of properties. Datastore entities are "schemaless." The structure of data entities is provided by and enforced by your application code. The Java JDO/JPA interfaces and the Python datastore interface include features for applying and enforcing structure within your app. Our app can also access the datastore directly to apply as much or as little structure as it needs.
The datastore is strongly consistent and uses optimistic concurrency control. An update of a entity occurs in a transaction that is retried a fixed number of times if other processes are trying to update the same entity simultaneously.
App Engine Services
App Engine provides a variety of services that enable to perform common operations when managing your application. The following APIs are provided to access these services:
URL Fetch
Applications can access resources on the Internet, such as web services or other data, using App Engine's URL fetch service. The URL fetch service retrieves web resources using the same high-speed Google infrastructure that retrieves web pages for many other Google products.
Applications can send email messages using App Engine's mail service. The mail service uses Google infrastructure to send email messages.
Memcache
The Memcache service provides your application with a high performance in-memory key-value cache that is accessible by multiple instances of your application. Memcache is useful for data that does not need the persistence and transactional features of the datastore, such as temporary data or data copied from the datastore to the cache for high speed access.
Image Manipulation
The Image service lets your application manipulate images. With this API, you can resize, crop, rotate and flip images in JPEG and PNG formats.
FEATURES
- Google App Engine makes it easy to build an application that runs reliably, even under heavy load and with large amounts of data. App Engine includes the following features:
- dynamic web serving, with full support for common web technologies
- persistent storage with queries, sorting and transactions
- automatic scaling and load balancing
- APIs for authenticating users and sending email using Google Accounts
- a fully featured local development environment that simulates Google App Engine on your computer
- task queues for performing work outside of the scope of a web request
- scheduled tasks for triggering events at specified times and regular intervals
Creating Application using Java
For developing application we require the App Engine software development kits (SDKs) for Java. It includes a web server application that emulates all of the App Engine services on your local computer. Each SDK includes all of the APIs and libraries available on App Engine. The web server also simulates the secure sandbox environment, including checks for attempts to access system resources disallowed in the App Engine runtime environment.
Following are the steps to create a java Application
- build an App Engine application using standard Java web technologies, such as servlets and JSPs
- create an App Engine Java project with Eclipse, and without
- use the Google Plugin for Eclipse for App Engine development
- use the App Engine datastore with the Java Data Objects (JDO) standard interface
- integrate an App Engine application with Google Accounts for user authentication
- upload your app to App Engine
Using Eclipse and the Google Plugin for Eclipse
If we are using the Eclipse development environment, the easiest way to develop, test and upload App Engine apps is to use the Google Plugin for Eclipse. The plugin includes everything need to build, test and deploy your app, entirely within Eclipse.
The plugin is available for Eclipse versions 3.3, 3.4, 3.5, and 3.6. We can install the plugin using the Software Update feature of Eclipse. The installation locations are as follows:
The Google Plugin for Eclipse, for Eclipse 3.3 (Europa):
http://dl.google.com/eclipse/plugin/3.3
The Google Plugin for Eclipse, for Eclipse 3.4 (Ganymede):
http://dl.google.com/eclipse/plugin/3.4
The Google Plugin for Eclipse, for Eclipse 3.5 (Galileo):
http://dl.google.com/eclipse/plugin/3.5
The Google Plugin for Eclipse, for Eclipse 3.6 (Helios):
http://dl.google.com/eclipse/plugin/3.6
Creating a Project
App Engine Java applications use the Java Servlet standard for interacting with the web server environment. An application's files, including compiled classes, JARs, static files and configuration files, are arranged in a directory structure using the WAR standard layout for Java web applications.
If we are using Eclipse, create a new project by clicking the New Web Application Project button in the toolbar: Give the project a "Project name" of Guestbook and a "Package" of guestbook. Uncheck "Use Google Web Toolkit," and ensure "Use Google App Engine" is checked. The wizard creates the directory structure, and the files described below.
If we are not using Eclipse, create the directory structure described above. As we read each of the files described in this section, create the files using the given locations and names.
Now write the Servelet class and web.xml.
App Engine needs one additional configuration file to figure out how to deploy and run the application. This file is named appengine-web.xml, and resides in WEB-INF/ alongside web.xml. It includes the registered ID of application (Eclipse creates this with an empty ID to fill in later), the version number of your application, and lists of files that ought to be treated as static files (such as images and CSS) and resource files (such as JSPs and other application data).
In the directory war/WEB-INF/, a file named appengine-web.xml has the following contents:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application></application>
<version>1</version>
</appengine-web-app>
appengine-web.xml is specific to App Engine, and is not part of the servlet standard.
Running the Project
The App Engine SDK includes a web server application we can use to test our application. The server simulates the App Engine environment and services, including sandbox restrictions, the datastore, and the services.
If we are using Eclipse, we can start the development server within the Eclipse debugger. Make sure the project ("Guestbook") is selected, then in the Run menu, select Debug As > Web Application. See Using the Google Plugin for Eclipse for details on creating the debug configuration.
If we are not using Eclipse, see Using Apache Ant for a build script that can build the project and start the development server. To start the server with this build script, enter the following command: ant runserver To stop the server, hit Control-C.
Testing the Application
Start the server, then visit the server's URL in browser. If we're using Eclipse and the Google Eclipse plugin, the server runs using port 8888 by default: http://localhost:8888/guestbook
If you're using the dev_appserver command to start the server, the default port is 8080: http://localhost:8080/guestbook
The server calls the servlet, and displays the message in the browser.
We now have a complete App Engine application! You could deploy this simple greeting right now and share it with users worldwide.
Using the Users Service
Google App Engine provides several useful services based on Google infrastructure, accessible by applications using libraries included with the SDK. One such service is the Users service, which lets our application integrate with Google user accounts. With the Users service, our users can use the Google accounts they already have to sign in to our application.
0 comments:
Post a Comment