Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ... ...

106
Monday, June 1, 2009

Transcript of Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ... ...

Page 1: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

Monday, June 1, 2009

Page 2: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

Monday, June 1, 2009

Page 3: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

Google App Engine:

Now Serving JavaDon SchwarzToby Reyelts5/26/09

Monday, June 1, 2009

Page 4: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

3

Overview

• Google App Engine• Java on App Engine• Demo• Questions

Monday, June 1, 2009

Page 5: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

4

What is Google App Engine?

Monday, June 1, 2009

Page 6: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

4

What is Google App Engine?

• A cloud-computing platform

Monday, June 1, 2009

Page 7: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

4

What is Google App Engine?

• A cloud-computing platform• Run your web apps on Google’s infrastructure

Monday, June 1, 2009

Page 8: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

4

What is Google App Engine?

• A cloud-computing platform• Run your web apps on Google’s infrastructure• We provide the container and services (PaaS)

– Hardware, connectivity– Operating system– JVM– Servlet container– Software services

Monday, June 1, 2009

Page 9: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

5

Key Features

Monday, June 1, 2009

Page 10: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

5

Key Features

• No need to install or maintain your own stack

Monday, June 1, 2009

Page 11: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

5

Key Features

• No need to install or maintain your own stack• We do the scaling for you

Monday, June 1, 2009

Page 12: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

5

Key Features

• No need to install or maintain your own stack• We do the scaling for you• Use Google’s scalable services via standard APIs

Monday, June 1, 2009

Page 13: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

5

Key Features

• No need to install or maintain your own stack• We do the scaling for you• Use Google’s scalable services via standard APIs• Charge only for actual usage

– Always free to get started

Monday, June 1, 2009

Page 14: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

5

Key Features

• No need to install or maintain your own stack• We do the scaling for you• Use Google’s scalable services via standard APIs• Charge only for actual usage

– Always free to get started

• Built-in application management console

Monday, June 1, 2009

Page 15: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

6

App Engine Architecture

Incoming Requests

Monday, June 1, 2009

Page 16: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

6

App Engine Architecture

Incoming Requests

App Engine Front End

App Engine Front End

App Engine Front End

Monday, June 1, 2009

Page 17: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

6

App Engine Architecture

Incoming Requests

App Engine Front End

App Engine Front End

App Engine Front End

AppServer AppServer AppServer

Monday, June 1, 2009

Page 18: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

6

App Engine Architecture

Incoming Requests

App Engine Front End

App Engine Front End

App Engine Front End

AppServer AppServer AppServer

Load Balancer

Monday, June 1, 2009

Page 19: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

6

App Engine Architecture

Incoming Requests

App Engine Front End

App Engine Front End

App Engine Front End

AppServer AppServer AppServer

Load Balancer

AppServer

API Layer

Other Google Infrastructure

- Bigtable

- Google Accounts

- Memcache

- Image manipulation

App App App

Monday, June 1, 2009

Page 20: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

7

When To Use Google App Engine

Monday, June 1, 2009

Page 21: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

7

When To Use Google App Engine

• Targeting web applications– Serve HTTP requests, limited to 30 seconds– No long-running background processes– No server push

Monday, June 1, 2009

Page 22: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

7

When To Use Google App Engine

• Targeting web applications– Serve HTTP requests, limited to 30 seconds– No long-running background processes– No server push

• Sandboxed environment– SecurityManager installed– No threads– Read-only file system

Monday, June 1, 2009

Page 23: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

8

Java Support

• Servlets• Software services• Sandboxing• DevAppServer• Deployment• Tooling

Monday, June 1, 2009

Page 24: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

9

Servlet API

Monday, June 1, 2009

Page 25: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

9

Servlet API

• Full Servlet 2.5 Container– HTTP Session support– JSP support

Monday, June 1, 2009

Page 26: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

9

Servlet API

• Full Servlet 2.5 Container– HTTP Session support– JSP support

• Uses Jetty and Jasper– Powered by Google’s HTTP stack– No Jetty-specific features

• jetty-web.xml• continuations

– Subject to change

Monday, June 1, 2009

Page 27: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

10

Servlet API - Application Configuration

<appengine-web-app> <application>application-id</application> <version>1</version> </appengine-web-app>

Monday, June 1, 2009

Page 28: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

11

Servlet API - Application Configuration

<appengine-web-app> <application>application-id</application> <version>1</version> <static-files> <include path="/**.png"/> <exclude path="/data/**.png"/> </static-files> <resource-files> <include path="/**.xml"/> <exclude path="/feeds/**.xml"/> </resource-files></appengine-web-app>

Monday, June 1, 2009

Page 29: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

12

Servlet API - Application Configuration

<appengine-web-app> <application>application-id</application> <version>1</version> <static-files> <include path="/**.png"/> <exclude path="/data/**.png"/> </static-files> <resource-files> <include path="/**.xml"/> <exclude path="/feeds/**.xml"/> </resource-files> <system-properties> <property name="max-length" value="140"/> </system-properties></appengine-web-app>

Monday, June 1, 2009

Page 30: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

13

Servlet API - Application Configuration

<appengine-web-app> <application>application-id</application> <version>1</version> <static-files> <include path="/**.png"/> <exclude path="/data/**.png"/> </static-files> <resource-files> <include path="/**.xml"/> <exclude path="/feeds/**.xml"/> </resource-files> <system-properties> <property name="max-length" value="140"/> </system-properties> <ssl-enabled>true</ssl-enabled> <sessions-enabled>true</sessions-enabled></appengine-web-app>

Monday, June 1, 2009

Page 31: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

14

Software Services

Service Java Standard Google Infrastructure

Authentication Servlet API Google Accounts

Datastore JPA, JDO Bigtable

Caching javax.cache memcacheg

E-mail javax.mail Gmail gateway

URLFetch URLConnection Caching HTTP proxy

Monday, June 1, 2009

Page 32: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

15

Service Infrastructure - Overview

Monday, June 1, 2009

Page 33: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

15

Service Infrastructure - Overview

Standard InterfaceJDO, JPA, JCache, JavaMail, ...

Monday, June 1, 2009

Page 34: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

15

Service Infrastructure - Overview

Proprietary Interfacecom.google.appengine.api.*

Standard InterfaceJDO, JPA, JCache, JavaMail, ...

Monday, June 1, 2009

Page 35: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

15

Service Infrastructure - Overview

Language-Neutral InterfaceProtocol Buffers

Proprietary Interfacecom.google.appengine.api.*

Standard InterfaceJDO, JPA, JCache, JavaMail, ...

Monday, June 1, 2009

Page 36: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

15

Service Infrastructure - Overview

ImplementationGoogle servers, SDK local stubs

Language-Neutral InterfaceProtocol Buffers

Proprietary Interfacecom.google.appengine.api.*

Standard InterfaceJDO, JPA, JCache, JavaMail, ...

Monday, June 1, 2009

Page 37: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

16

Service Infrastructure - Evolution

Monday, June 1, 2009

Page 38: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

16

Service Infrastructure - Evolution

• Several levels of indirection– Facilitates evolution– Provides consistency

Monday, June 1, 2009

Page 39: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

16

Service Infrastructure - Evolution

• Several levels of indirection– Facilitates evolution– Provides consistency

• App Engine API jar (appengine-api.jar)– Contains

• Proprietary API

• Mapping to language-neutral API• JCache, JavaMail adapters (for now)

– Major releases• Breaking API changes

• Need to recompile, redeploy with latest jar

– Patch releases• Bug fixes, new functionality• Upgrades happen automatically

Monday, June 1, 2009

Page 40: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

17

Service Infrastructure - ApiProxy

Monday, June 1, 2009

Page 41: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

17

Service Infrastructure - ApiProxy

• API calls are made via ApiProxy– com.google.apphosting.api.ApiProxy– Invoked by Proprietary API, uses Protocol Buffers– Forwards API calls on to a registered Delegate– Stores per-request information

• ThreadLocal<Environment>

Monday, June 1, 2009

Page 42: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

17

Service Infrastructure - ApiProxy

• API calls are made via ApiProxy– com.google.apphosting.api.ApiProxy– Invoked by Proprietary API, uses Protocol Buffers– Forwards API calls on to a registered Delegate– Stores per-request information

• ThreadLocal<Environment>

• To make API calls outside of App Engine tools– Call ApiProxy.setDelegate(Delegate)

– Call ApiProxy.setEnvironmentForCurrentThread(Environment)

Monday, June 1, 2009

Page 43: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

17

Service Infrastructure - ApiProxy

• API calls are made via ApiProxy– com.google.apphosting.api.ApiProxy– Invoked by Proprietary API, uses Protocol Buffers– Forwards API calls on to a registered Delegate– Stores per-request information

• ThreadLocal<Environment>

• To make API calls outside of App Engine tools– Call ApiProxy.setDelegate(Delegate)

– Call ApiProxy.setEnvironmentForCurrentThread(Environment)

• Can use ApiProxyLocalFactory to simplify unit testing– Uses JAR Service Provider to locate API implementations– Can replace API implementations just by changing classpath

Monday, June 1, 2009

Page 44: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

18

ApiProxy Interception

Monday, June 1, 2009

Page 45: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

18

ApiProxy Interception

• Can intercept any service call

Monday, June 1, 2009

Page 46: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

18

ApiProxy Interception

• Can intercept any service call• Similar to AOP

– Add additional logic before, after, or around service call– Delegate to previous ApiProxy in chain

Monday, June 1, 2009

Page 47: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

18

ApiProxy Interception

• Can intercept any service call• Similar to AOP

– Add additional logic before, after, or around service call– Delegate to previous ApiProxy in chain

• Useful for profiling and debugging– Prod services perform differently than local services

Monday, June 1, 2009

Page 48: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

19

ApiProxy Interception - Profiling

Monday, June 1, 2009

Page 49: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

19

ApiProxy Interception - Profiling

class ProfilingDelegate extends Delegate {

Delegate parent;

public ProfilingDelegate(Delegate parent) {

this.parent = parent;

}

public byte[] makeSyncCall(Environment env, String pkg,

String method, byte[] request) {

long start = System.nanoTime();

byte[] result = parent.makeSyncCall(env, pkg, method, request);

log.log(INFO, pkg + “.” + method + “: “ + System.nanoTime() - start);

return result;

}

}

ApiProxy.setDelegate(new ProfilingDelegate(ApiProxy.getDelegate()));

Monday, June 1, 2009

Page 50: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

20

Sandboxing

Monday, June 1, 2009

Page 51: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

20

• What do we do?– Restrict JVM permissions– WhiteList classes

Sandboxing

Monday, June 1, 2009

Page 52: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

20

• What do we do?– Restrict JVM permissions– WhiteList classes

• Why is it necessary?– Clustering - JVMs come and go– Protect applications from one another– Quality of service

Sandboxing

Monday, June 1, 2009

Page 53: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

21

Sandboxing Restrictions

Restriction Alternative

Threads Async API (coming soon)

Direct network connections

URLConnection

Direct file system writes Memory, memcache, datastore

Java2D Images APISoftware rendering

Native code Pure Java Libraries

Monday, June 1, 2009

Page 54: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

22

Flexible Sandboxing

Monday, June 1, 2009

Page 55: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

22

Flexible Sandboxing

We want to give developers flexibility, but JVM Permissions are often too coarse.

Monday, June 1, 2009

Page 56: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

22

Flexible Sandboxing

We want to give developers flexibility, but JVM Permissions are often too coarse.

They either provide a cramped sandbox.

Monday, June 1, 2009

Page 57: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

22

Flexible Sandboxing

We want to give developers flexibility, but JVM Permissions are often too coarse.

They either provide a cramped sandbox.

Or they hand over the nuclear launch codes.

Monday, June 1, 2009

Page 58: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

22

Flexible Sandboxing

We want to give developers flexibility, but JVM Permissions are often too coarse.

They either provide a cramped sandbox.

Or they hand over the nuclear launch codes.

App Engine delivers a happy medium.

Monday, June 1, 2009

Page 59: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

23

Flexible Sandboxing - Reflection

Monday, June 1, 2009

Page 60: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

23

Flexible Sandboxing - Reflection

• Access private fields, call private methods– suppressAccessChecks– accessDeclaredMembers

Monday, June 1, 2009

Page 61: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

23

Flexible Sandboxing - Reflection

• Access private fields, call private methods– suppressAccessChecks– accessDeclaredMembers

Field f = String.class.getDeclaredField(“count”);

f.setAccessible(true);

f.set(“Hello World”, 2);

Bad!

Monday, June 1, 2009

Page 62: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

23

Flexible Sandboxing - Reflection

• Access private fields, call private methods– suppressAccessChecks– accessDeclaredMembers

Field f = String.class.getDeclaredField(“count”);

f.setAccessible(true);

f.set(“Hello World”, 2);

Field f = MyClass.class.getDeclaredField(“foo”);

f.setAccessible(true);

f.set(myObj, aFoo);

Bad!

Good!

Monday, June 1, 2009

Page 63: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

24

Flexible Sandboxing - Class Loading

Monday, June 1, 2009

Page 64: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

24

Flexible Sandboxing - Class Loading

• Create user-controlled ClassLoaders– createClassLoader

Monday, June 1, 2009

Page 65: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

24

Flexible Sandboxing - Class Loading

• Create user-controlled ClassLoaders– createClassLoader

ClassLoader myClassLoader = new URLClassLoader() {

public PermissionsCollection getPermissions(CodeSource cs) {

// return AllPermission;

}

};

Bad!

Monday, June 1, 2009

Page 66: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

24

Flexible Sandboxing - Class Loading

• Create user-controlled ClassLoaders– createClassLoader

ClassLoader myClassLoader = new URLClassLoader() {

public PermissionsCollection getPermissions(CodeSource cs) {

// return AllPermission;

}

};

ClassLoader myClassLoader = new URLClassLoader() {

public Class findClass(String className) {

// define and load some newly generated bytecode

}

};

Bad!

Good!

Monday, June 1, 2009

Page 67: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

25

Flexible Sandboxing - Compatibility

Flexibility Compatibility

Monday, June 1, 2009

Page 68: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

25

Flexible Sandboxing - Compatibility

• Dependency Injection Frameworks– Guice, Spring, etc.

Flexibility Compatibility

Monday, June 1, 2009

Page 69: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

25

Flexible Sandboxing - Compatibility

• Dependency Injection Frameworks– Guice, Spring, etc.

• Aspect Oriented Programming– AspectJ, Spring AOP, etc.

Flexibility Compatibility

Monday, June 1, 2009

Page 70: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

25

Flexible Sandboxing - Compatibility

• Dependency Injection Frameworks– Guice, Spring, etc.

• Aspect Oriented Programming– AspectJ, Spring AOP, etc.

• Web frameworks– Google Web Toolkit, Tapestry, BlazeDS (Flex), etc.– Grails (Just Announced!)

Flexibility Compatibility

Monday, June 1, 2009

Page 71: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

25

Flexible Sandboxing - Compatibility

• Dependency Injection Frameworks– Guice, Spring, etc.

• Aspect Oriented Programming– AspectJ, Spring AOP, etc.

• Web frameworks– Google Web Toolkit, Tapestry, BlazeDS (Flex), etc.– Grails (Just Announced!)

• Alternate JVM languages– Scala, Rhino, JRuby, Jython, Clojure, Groovy, PHP, etc.

Flexibility Compatibility

Monday, June 1, 2009

Page 72: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

26

DevAppServer

Monday, June 1, 2009

Page 73: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

26

DevAppServer

• Emulates the production environment

Monday, June 1, 2009

Page 74: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

26

DevAppServer

• Emulates the production environment• Customized Jetty server

Monday, June 1, 2009

Page 75: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

26

DevAppServer

• Emulates the production environment• Customized Jetty server• Local implementation of services

– LRU memcache– Disk-backed datastore– HttpClient-backed URLFetch

Monday, June 1, 2009

Page 76: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

26

DevAppServer

• Emulates the production environment• Customized Jetty server• Local implementation of services

– LRU memcache– Disk-backed datastore– HttpClient-backed URLFetch

• Some sandbox restrictions difficult to emulate– WhiteList not enforced

Monday, June 1, 2009

Page 77: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

27

Deployment

Monday, June 1, 2009

Page 78: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

27

Deployment

• Your app lives at– <app_id>.appspot.com, or– Custom domain with Google Apps

Monday, June 1, 2009

Page 79: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

27

Deployment

• Your app lives at– <app_id>.appspot.com, or– Custom domain with Google Apps

• Command line and IDE tools

Monday, June 1, 2009

Page 80: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

27

Deployment

• Your app lives at– <app_id>.appspot.com, or– Custom domain with Google Apps

• Command line and IDE tools• Deploying uploads

– Static files– Resource files– Other metadata (datastore indexes, cron jobs)

Monday, June 1, 2009

Page 81: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

27

Deployment

• Your app lives at– <app_id>.appspot.com, or– Custom domain with Google Apps

• Command line and IDE tools• Deploying uploads

– Static files– Resource files– Other metadata (datastore indexes, cron jobs)

• Admin Console– dashboards– manage multiple versions– view logs

Monday, June 1, 2009

Page 82: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

28

Quotas and Billing

Resource Provided Free Additional Cost

CPU 6.5 hours/day $0.10/hour

Bandwidth In 1GByte/day $0.10/GByte

Bandwidth Out 1GByte/day $0.12/GByte

Stored Data 1 GB $0.005/GB-day

Emails sent 2000/day to users50000/day to admins

$0.0001/email

Monday, June 1, 2009

Page 83: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

29

Tooling

Monday, June 1, 2009

Page 84: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

29

Tooling

• SDK Tools API– Command line tools, Ant, and IDE plugins

Monday, June 1, 2009

Page 85: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

29

Tooling

• SDK Tools API– Command line tools, Ant, and IDE plugins

• Provides– Deployment– DevAppServer– WhiteList for compile-time checks– XML validation

Monday, June 1, 2009

Page 86: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

29

Tooling

• SDK Tools API– Command line tools, Ant, and IDE plugins

• Provides– Deployment– DevAppServer– WhiteList for compile-time checks– XML validation

• Google Eclipse Plugin

Monday, June 1, 2009

Page 87: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

29

Tooling

• SDK Tools API– Command line tools, Ant, and IDE plugins

• Provides– Deployment– DevAppServer– WhiteList for compile-time checks– XML validation

• Google Eclipse Plugin• Intellij Plugin (New!)

Monday, June 1, 2009

Page 88: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

Monday, June 1, 2009

Page 89: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

Demo

Monday, June 1, 2009

Page 90: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

31

Demo - Login

Monday, June 1, 2009

Page 91: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

32

Demo - Question

Monday, June 1, 2009

Page 92: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

33

Demo - Question Result

Monday, June 1, 2009

Page 93: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

34

Demo - Scoreboard

Monday, June 1, 2009

Page 94: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

Monday, June 1, 2009

Page 95: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

Demo - Code

Monday, June 1, 2009

Page 96: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

36

Monday, June 1, 2009

Page 97: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

36

http://java-demo.appspot.com

Monday, June 1, 2009

Page 98: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

37

Coming Soon

Monday, June 1, 2009

Page 99: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

37

Coming Soon

• Task queues

Monday, June 1, 2009

Page 100: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

37

Coming Soon

• Task queues• Full text search

Monday, June 1, 2009

Page 101: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

37

Coming Soon

• Task queues• Full text search• Incoming e-mail

Monday, June 1, 2009

Page 102: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

37

Coming Soon

• Task queues• Full text search• Incoming e-mail• XMPP

Monday, June 1, 2009

Page 103: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

37

Coming Soon

• Task queues• Full text search• Incoming e-mail• XMPP• Large file storage and retrieval

Monday, June 1, 2009

Page 104: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

37

Coming Soon

• Task queues• Full text search• Incoming e-mail• XMPP• Large file storage and retrieval• Datastore export tools

Monday, June 1, 2009

Page 106: Monday, June 1, 2009 - 123seminarsonly.com · 2012-07-07 · –JVM –Servlet container ...  Monday, June 1, 2009. 14 Software Services Service Java Standard

Monday, June 1, 2009