+ All Categories
Home > Technology > Alphageeks IL #2 Google App Engine

Alphageeks IL #2 Google App Engine

Date post: 29-Dec-2014
Category:
Upload: alphageeks
View: 1,061 times
Download: 1 times
Share this document with a friend
Description:
Second Alphageeks IL meetup:Liran Zelka talks on Google App-Engine and cloud computing in general.Check us out for more events:http://alphageeks.blogli.co.il/
14
Google App Engine הההה ההההה ההה"ה ההההה[email protected]
Transcript
Page 1: Alphageeks IL #2 Google App Engine

Google App Engine

לירן זילכהמנכ"ל משותף

[email protected]

Page 2: Alphageeks IL #2 Google App Engine

AlunaIsrael’s leading Java/JavaEE and SOA

consulting companyCustomers:

Page 3: Alphageeks IL #2 Google App Engine

Installing The SDKJava 5 & 6 are supportedDownload google eclipse plugin from

Or just download and install the SDKhttp://dl.google.com/eclipse/plugin/3.4

http://code.google.com/appengine/downloads.html

Page 4: Alphageeks IL #2 Google App Engine

App Engine ProjectA standard JavaEE WAR file

Page 5: Alphageeks IL #2 Google App Engine

The Servletpackage guestbook;

import java.io.IOException;import javax.servlet.http.*;

public class GuestbookServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); resp.getWriter().println("Hello, world"); }}

Page 6: Alphageeks IL #2 Google App Engine

Web.xml<?xml version="1.0" encoding="utf-8"?><!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> <servlet> <servlet-name>guestbook</servlet-name> <servlet-class>guestbook.GuestbookServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>guestbook</servlet-name> <url-pattern>/guestbook</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/index.html</welcome-file> </welcome-file-list></web-app>

Page 7: Alphageeks IL #2 Google App Engine

Appengine-web.xml<?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>

Page 8: Alphageeks IL #2 Google App Engine

Run/DebugWeb server runtime comes with the

plugins

Page 9: Alphageeks IL #2 Google App Engine

Users servicepackage guestbook;

public class GuestbookServlet extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { UserService userService = 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())); } }}

Page 10: Alphageeks IL #2 Google App Engine

Other ServicesDatastore

◦Database with JDO and JPA accessMemcache

◦Implements JcacheURL Fetch

◦Or just use java.net.URLConnectionImages

◦Image editing capabilitiesJobsGoogle Accounts

Page 11: Alphageeks IL #2 Google App Engine

Using JPA<?xml version="1.0" encoding="UTF-8" ?><persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">

<persistence-unit name="transactions-optional"> <provider>org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider</provider> <properties> <property name="datanucleus.NontransactionalRead" value="true"/> <property name="datanucleus.NontransactionalWrite" value="true"/> <property name="datanucleus.ConnectionURL" value="appengine"/> </properties> </persistence-unit>

</persistence>

Page 12: Alphageeks IL #2 Google App Engine

Getting EntityManagerimport javax.persistence.EntityManagerFactory;import javax.persistence.Persistence;

public final class EMF { private static final EntityManagerFactory emfInstance = Persistence.createEntityManagerFactory("transactions-optional");

private EMF() {}

public static EntityManagerFactory get() { return emfInstance; }}

Page 13: Alphageeks IL #2 Google App Engine

UploadingRegister at https://appengine.google.com/ Deploy from your eclipse environmentAccess at http://application-id

.appspot.com/

Page 14: Alphageeks IL #2 Google App Engine

App Engine SandboxAn 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.


Recommended