Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Aphorismen
Applications
Business Economics & Admin.
My Computers
Cooking
Devices
Folders
Food
Hardware
Infos
Software Development
Sports
Operation Instructions
Todos
Test
Help
Glossary
Community portal
adaptions
Sidebar anpassen
Wiki RB4
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
GAE
Page
Discussion
English
Read
Edit
View history
Toolbox
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
MOVED TO http://sites.google.com/site/uweheuerwiki/software-development/frameworks/google-app-engine =Introduction= Applications can be developed in Python and Java. =Java Development= You develop and upload Java applications for Google App Engine using the App Engine Java software development kit (SDK). The SDK includes software for a web server that you can run on your own computer to test your Java applications (see [[#Development_Environment|Development Environment]]). Google App Engine provides several useful services based on Google infrastructure, accessible by applications using libraries included with the SDK. 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. GAE uses Java 6. ==Development Environment== ===Installation=== * PlugIn * Path extended to %JAVA_HOME%, to enable call to javac.exe * port change from 8080 to 8090 in C:\Uwes\eclipse\v351\eclipse\plugins\com.google.appengine.eclipse.sdkbundle.1.3.0_1.3.0.v200912141120\appengine-java-sdk-1.3.0\config\user\ant-macros.xml * in eclipse Run -> Run Configuration -> Web Application -> <Project> -> Port from 8888 to 8090 ===Eclipse Plugin=== see plugins/com.google.appengine.eclipse.sdkbundle_VERSION/ ===Java Development Server=== The App Engine Java SDK includes a development web server for testing your application on your computer. The server simulates all of the App Engine services, including a local version of the datastore, Google Accounts, and the ability to fetch URLs and send email from your computer using the App Engine APIs. The Google Plugin for Eclipse can run the server in the Eclipse debugger or you can run it from the command line. ===Libraries=== * datanucleus-*.jar: For accessing the App Engine for Java datastore using standard JDO or the low-level BigTable API * appengine-api-sdk.1.2.0.jar: For using nonstandard App Engine for Java application services like App Engine for Java Security * geronimo-*.jar: For using standard Java APIs like Java Transaction Management API (JTA) and JPA * jdo2-api-2.3-SNAPSHOT.jar: For using the JDO API ===Test=== ====Demos==== C:\Uwes\eclipse\v351\eclipse\plugins\com.google.appengine.eclipse.sdkbundle.1.3.0_1.3.0.v200912141120>appengine-java-sdk-1.3.0\bin\dev_appserver.cmd --port=8090 appengine-java-sdk-1.3.0\demos\guestbook\war ==Development Process== ===New Project=== The wizard creates a directory structure for the project, including a src/ directory for Java source files, and a war/ directory for compiled classes and other files for the application, libraries, configuration files, static files such as images and CSS, and other data files. The wizard also creates a servlet source file and two configuration files. The complete directory structure looks like this: <Project>/ src/ <Project>/ server/ <Project>Servlet.java META-INF/ jdoconfig.xml log4j.properties logging.properties war/ WEB-INF/ lib/ ...App Engine JARs... [[#appengine-web.xml|appengine-web.xml]] [[JEE#Deployment_Descriptor|web.xml]] index.html ====Specific Configuration Files==== =====appengine-web.xml===== appengine-web.xml is specific to App Engine, and is not part of the servlet standard. <?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> =====persistence.xml===== * JPA configuration * general description in [[JavaJEEJPA#persistence.xml|persistence.xml]] =====jdoconfig.xml===== It resides in the directory <code>war/WEB-INF/classes/META-INF/</code>. ===Implementation=== ====New Servlet==== * New Java Class Wizzard with base javax.servlet.http.HttpServlet * add Servlet in \war\WEB-INF\web.xml ====JPA==== * create src\META-INF\[[#persistence.xml|persistence.xml]] =====save an entity===== X x = new X(); x.setA(a); javax.persistence.EntityManager em = EMFactory.get().createEntityManager(); em.persist(x); =====retrieving entities===== javax.persistence.EntityManager em = EMFactory.get().createEntityManager(); javax.persistence.Query q = em.qreateQuery("SELECT v From <CLASSNAME> v"); List<CLASSNAME> results = q.getResultList(); Iterator<CLASSNAME> iter = results.iterator(); while (iter.hasNext()) { <CLASSNAME> v = iter.next(); } ===Run/Debug Project=== With Eclipse, you can leave the server running in the debugger while you make changes to source code, JSPs, static files and appengine-web.xml. When you save changes to source code, Eclipse compiles the class automatically, then attempts to insert it into the running web server dynamically. In most cases, you can simply reload the page in your browser to test the new version of the code. Changes to JSPs, static files and appengine-web.xml are recognized by the development server automatically, and also take effect without restarting the server. If you change web.xml or other configuration files, you must stop and start the server for the changes to take effect. ====Run==== *''Project Context Menu -> Run As -> Web Application'' or *''Project Context Menu -> Run As -> Run Configuration -> Web Application -> <Projectname>'' *Browser http://localhost:<port>/<Appname> ====Debug==== *''Project Context Menu -> Debug As -> Web Application'' or *''Project Context Menu -> Debug As -> Debug Configuration -> Web Application -> <Projectname>'' *Browser http://localhost:<port>/<Appname> ====Deploy changes==== * according documentation local engine should be updated after save but doesn't work, so go to Debug Perspective, select engine context menu and use 'terminate and relaunch' ===Stop Server=== * switch to Debug perspective * select application in the debug panel * press terminate button in button bar ==Application Engine Services== ===Datastore=== App Engine includes support for two different API standards for the datastore: Java Data Objects (JDO) and [[JavaJEEJPA|Java Persistence API]] (JPA). These interfaces are provided by DataNucleus Access Platform, an open source implementation of several Java persistence standards, with an adapter for the App Engine datastore. The [[#JDO|JDO]] and [[#JPA|JPA]] interfaces present some leaky abstractions due to the fact that BigTable is not a relational database. For example, in App Engine for Java, you can't do queries that do joins. You can set up relationships in JPA and JDO, but they can only be used for persisting relationships. Working with App Engine's scalable datastore requires you to rethink your indoctrination to the benefits of normalized data. De-normalization is no longer a dirty word; instead, it is a design tool that you will apply in many aspects of your App Engine for Java applications. ====Entities==== Every entity belongs to an entity group, a set of one or more entities that can be manipulated in a single transaction. Entity group relationships tell App Engine to store several entities in the same part of the distributed network. =====Keys===== Every entity has a key (s. [http://code.google.com/intl/de-DE/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Keys documentation]) that is unique over all entities in App Engine. A complete key includes several pieces of information, including the application ID, the kind, and an entity ID. The following types can be used as keys, but some can not be used for objects which have parents: *java.lang.Long (not for childs) *java.lang.String (not for childs) *com.google.appengine.api.datastore.Key ====Transactions==== All datastore operations in a transaction must operate on entities in the same entity group. ====JDO==== Access Platform needs a configuration file that tells it to use the App Engine datastore as the backend for the JDO implementation. In the final WAR, this file is named [[#jdoconfig.xml|jdoconfig.xml]]. When you create your JDO classes, you use Java annotations to describe how instances should be stored in the datastore, and how they should be recreated when retrieved from the datastore. Access Platform connects your data classes to the implementation using a post-compilation processing step, which DataNucleus calls "enhancing" the classes. An app interacts with JDO using an instance of the PersistenceManager class. You get this instance by instantiating and calling a method on an instance of the PersistenceManagerFactory class. The factory uses the JDO configuration to create PersistenceManager instances. Because a PersistenceManagerFactory instance takes time to initialize, an app should reuse a single instance. To enforce this, an exception is thrown if the app instantiates more than one PersistenceManagerFactory (with the same configuration name). ====JPA==== The DataNucleus implementation of JPA uses a post-compilation "enhancement" step in the build process to associate data classes with the JPA implementation. ===User Service=== UserService userService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser();
Summary:
Please note that all contributions to Wiki RB4 may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Uwe Heuer Wiki New:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width