Alphageeks IL #2 Google App Engine - Presentation Transcript
Google App Engine לירן זילכה מנכ"ל משותף Liran.zelkha@alunasoft.com
Aluna Israel’s leading Java/JavaEE and SOA consulting company Customers:
Installing The SDK Java 5 & 6 are supported Download google eclipse plugin from Or just download and install the SDK http://dl.google.com/eclipse/plugin/3.4 http://code.google.com/appengine/downloads.html
App Engine Project A standard JavaEE WAR file
The Servlet package guestbook; import java.io.IOException; import javax.servlet.http.*; public class GuestbookServlet extends HttpServlet { public void doGet(HttpServletRequestreq, HttpServletResponseresp) throws IOException { resp.setContentType("text/plain"); resp.getWriter().println("Hello, world"); } }
Run/Debug Web server runtime comes with the plugins
Users service package guestbook; public class GuestbookServlet extends HttpServlet { public void doGet(HttpServletRequestreq, HttpServletResponseresp) throws IOException { UserServiceuserService = UserServiceFactory.getUserService(); User user = userService.getCurrentUser(); if (user != null) { resp.setContentType("text/plain"); resp.getWriter().println("Hello, " + user.getNickname()); } else { resp.sendRedirect(userService.createLoginURL(req.getRequestURI())); } } }
Other Services Datastore Database with JDO and JPA access Memcache Implements Jcache URL Fetch Or just use java.net.URLConnection Images Image editing capabilities Jobs Google Accounts
Getting EntityManager import javax.persistence.EntityManagerFactory; import javax.persistence.Persistence; public final class EMF { private static final EntityManagerFactoryemfInstance = Persistence.createEntityManagerFactory("transactions-optional"); private EMF() {} public static EntityManagerFactory get() { return emfInstance; } }
Uploading Register at https://appengine.google.com/ Deploy from your eclipse environment Access at http://application-id.appspot.com/
App Engine Sandbox An App Engine application cannot: write to the filesystem. Applications must use the App Engine datastore for storing persistent data. Reading from the filesystem is allowed, and all application files uploaded with the application are available. open a socket or access another host directly. An application can use the App Engine URL fetch service to make HTTP and HTTPS requests to other hosts on ports 80 and 443, respectively. spawn a sub-process or thread. A web request to an application must be handled in a single process within a few seconds. Processes that take a very long time to respond are terminated to avoid overloading the web server. make other kinds of system calls.
0 comments
Post a comment