GAE: Introducción al App Engine Java

Con App Engine , podemos construir aplicaciones web utilizando tecnologia Java estandar y ejecutarlas en las infraestructuras escalables de Google. El entorno Java proporciona una máquina virtual Java 6 , un interfaz de Servlets de Java y soporte para interfaces estandares para acceder a los datastores y servicios escalables de Google, tales como JDO, JPA, JavaMail y JCache. Al seguir estandares hace fácil el desarrollo de las aplicaciones y mantienes la posibilidad de que en el futuro puedes instalartelo en tu propio entorno de ejecución de aplicaciones web.

El Google Plugin for Eclipse nos ofrece la posibilidad de crear proyectos en formato wizard y varias opciones de configuración de depuración de tus proyectos en GAE. Con el App Engine de Java se hace especialmente fácil programar y desplegar aplicaciones web utilizando el Google Web Toolkit (GWT). El plugin de eclipse viene con los SDKs de App Engine y de GWT.

Hay plugins de terceros también disponibles para otros IDEs de Java.For NetBeans, see NetBeans support for Google App Engine. For IntelliJ, see Google App Engine Integration for IntelliJ. (These links take you to third-party websites.)

Si no lo has hecho aún , échale un vistazo a la the Java Getting Started Guide para tener una introducción interactiva de lo que es programar aplicaciones web con tecnologías Java y GAE

The Java Runtime Environment

App Engine runs Java applications using the Java 6 virtual machine (JVM). The App Engine SDK supports Java 5 and later, and the Java 6 JVM can use classes compiled with any version of the Java compiler up to Java 6.

App Engine uses the Java Servlet standard for web applications. You provide your app’s servlet classes, JavaServer Pages (JSPs), static files and data files, along with the deployment descriptor (the web.xml file) and other configuration files, in a standard WAR directory structure. App Engine serves requests by invoking servlets according to the deployment descriptor.

The JVM runs in a secured “sandbox” environment to isolate your application for service and security. The sandbox ensures that apps can only perform actions that do not interfere with the performance and scalability of other apps. For instance, an app cannot spawn threads in some ways, write data to the local file system or make arbitrary network connections. An app also cannot use JNI or other native code. The JVM can execute any Java bytecode that operates within the sandbox restrictions.

See Servlet Environment for more information.

The Datastore, the Services and the Standard Interfaces

App Engine provides scalable services that apps can use to store persistent data, access resources over the network, and perform other tasks like manipulating image data. You have the choice between two different data storage options differentiated by their availability and consistency guarantees. Where possible, the Java interfaces to these services conform to established standard APIs to allow for porting apps to and from App Engine. Each service also provides a complete low-level interface for implementing new interface adapters, or for direct access.

Apps can use the App Engine datastore for reliable, scalable persistent storage of data. The datastore supports two standard Java interfaces: Java Data Objects (JDO) 2.3 and Java Persistence API (JPA) 1.0. These interfaces are implemented using DataNucleus Access Platform, the open source implementation of these standards.

The App Engine Memcache provides fast, transient distributed storage for caching the results of datastore queries and calculations. The Java interface implements JCache (JSR 107).

Apps use the URL Fetch service to access resources over the web, and to communicate with other hosts using the HTTP and HTTPS protocols. Java apps can simply use and related classes from the Java standard library to access this service.

An app can use the Mail service to send email messages on behalf of the application’s administrators, or on behalf of the currently signed-in user. Java apps use the JavaMailinterface for sending email messages.

The Images service lets applications transform and manipulate image data in several formats, including cropping, rotating, resizing, and photo color enhancement. The service can handle CPU-intensive image processing tasks, leaving more resources available for the application server to handle web requests. (You can also use any JVM-based image processing software on the application server, provided it operates within the sandbox restrictions.)

An application can use Google Accounts for user authentication. Google Accounts handles user account creation and sign-in, and a user that already has a Google account (such as a GMail account) can use that account with your app. An app can detect when the current user is signed in, and can access the user’s email address. Java applications can use security constraints in the deployment descriptor to control access via Google Accounts, and can detect whether the user is signed in and get the email address using the getUserPrincipal() method on the servlet request object. An app can use the low-level Google Accounts API to generate sign-in and sign-out URLs, and to get a user data object suitable for storage in the datastore.

Scheduled Tasks

An application can configure scheduled tasks that will call URLs of the application at specified intervals. For more on this, see Cron Jobs.

Java Tools

The App Engine Java SDK includes tools for testing your application, uploading your application files, and downloading log data. The SDK also includes a component for Apache Ant to simplify tasks common to App Engine projects. The Google Plugin for Eclipse adds features to the Eclipse IDE for App Engine development, testing and deployment, and includes the complete App Engine SDK. The Eclipse plugin also makes it easy to develop Google Web Toolkit applications and run them on App Engine.

The development server runs your application on your local computer for development and testing. The server simulates the App Engine datastore, services and sandbox restrictions. The development server can also generate configuration for datastore indexes based on the queries the app performs during testing.

A multipurpose tool called AppCfg handles all command-line interaction with your application running on App Engine. AppCfg can upload your application to App Engine, or just update the datastore index configuration so you can build new indexes before updating the code. It can also download the app’s log data, so you can analyze your app’s performance using your own tools.