CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

62
1 www.ExigenServices.com GWT Features Overview Andrey Mormysh Java Developer [email protected] October 15, 2011 www.ExigenServices.com

description

 

Transcript of CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

Page 1: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

GWT Features Overview

Andrey Mormysh

Java [email protected]

October 15, 2011 www.ExigenServices.com

Page 2: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

2 www.ExigenServices.com

GWT Google Web Toolkit

Page 3: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

3 www.ExigenServices.com

GWT /ˈɡwɪt /Google Web Toolkit

Page 4: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

4 www.ExigenServices.com

GWT-based projects

Page 5: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

5 www.ExigenServices.com

GWT-based projects

Google Wave (http://wave.google.com/) - an online tool for real-time communication and collaboration

Page 6: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

6 www.ExigenServices.com

GWT-based projects

Google Wave (http://wave.google.com/) - an online tool for real-time communication and collaboration

Odnoklassniki (http://www.odnoklassniki.ru) - social network

Page 7: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

7 www.ExigenServices.com

GWT-based projects

Google Wave (http://wave.google.com/) - an online tool for real-time communication and collaboration

Odnoklassniki (http://www.odnoklassniki.ru) - social network Google Moderator (http://www.google.com/moderator) - a tool that allows

distributed communities to submit and vote on questions for talks, presentations and events

Page 8: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

8 www.ExigenServices.com

GWT-based projects

Google Wave (http://wave.google.com/) - an online tool for real-time communication and collaboration

Odnoklassniki (http://www.odnoklassniki.ru) - social network Google Moderator (http://www.google.com/moderator) - a tool that allows

distributed communities to submit and vote on questions for talks, presentations and events

Go Grid (http://www.gogrid.com/) - cloud computing infrastructure service provider which enables you to deploy and scale load-balanced cloud server networks via a unique multi-server control panel.

Page 9: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

9 www.ExigenServices.com

GWT-based projects

Google Wave (http://wave.google.com/) - an online tool for real-time communication and collaboration

Odnoklassniki (http://www.odnoklassniki.ru) - social network Google Moderator (http://www.google.com/moderator) - a tool that allows

distributed communities to submit and vote on questions for talks, presentations and events

Go Grid (http://www.gogrid.com/) - cloud computing infrastructure service provider which enables you to deploy and scale load-balanced cloud server networks via a unique multi-server control panel.

Blueprint (https://blueprint.lombardi.com/index.html) - business process mapping tool

Page 10: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

10 www.ExigenServices.com

GWT-based projects

Google Wave (http://wave.google.com/) - an online tool for real-time communication and collaboration

Odnoklassniki (http://www.odnoklassniki.ru) - social network Google Moderator (http://www.google.com/moderator) - a tool that allows

distributed communities to submit and vote on questions for talks, presentations and events

Go Grid (http://www.gogrid.com/) - cloud computing infrastructure service provider which enables you to deploy and scale load-balanced cloud server networks via a unique multi-server control panel.

Blueprint (https://blueprint.lombardi.com/index.html) - business process mapping tool

Scenechronize (https://www.scenechronize.com/) - a production management web application for film, television and commercials

Page 11: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

11 www.ExigenServices.com

GWT-based projects

Google Wave (http://wave.google.com/) - an online tool for real-time communication and collaboration

Odnoklassniki (http://www.odnoklassniki.ru) - social network Google Moderator (http://www.google.com/moderator) - a tool that allows

distributed communities to submit and vote on questions for talks, presentations and events

Go Grid (http://www.gogrid.com/) - cloud computing infrastructure service provider which enables you to deploy and scale load-balanced cloud server networks via a unique multi-server control panel.

Blueprint (https://blueprint.lombardi.com/index.html) - business process mapping tool

Scenechronize (https://www.scenechronize.com/) - a production management web application for film, television and commercials

Whirled (http://www.whirled.com/) - social virtual world website which includes multi-player games

etc…

Page 12: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

12 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 13: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

13 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 14: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

14 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 15: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

15 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 16: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

16 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 17: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

17 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 18: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

18 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 19: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

19 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 20: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

20 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 21: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

21 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 22: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

22 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 23: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

23 www.ExigenServices.com

Features

Cross-browserObject-oriented programmingDev-modeGUI debuggingWigets and declarative UIClient BundleSimple localizationCode optimizationCode splittingRPC, JSON/XMLUI DesignerHTML5…

Page 24: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

24 www.ExigenServices.com

?

Page 25: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

25 www.ExigenServices.com

Page 26: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

26 www.ExigenServices.com

Page 27: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

27 www.ExigenServices.com

JSNIJava Script Native Interface

Access JS code from Java code and vice versa

Page 28: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

28 www.ExigenServices.com

JSNIJava Script Native Interface

Access JS code from Java code and vice versa

Wrap your own or third-party JS-widgets with JSNI:• Google Maps• Flash objects• etc.

Page 29: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

29 www.ExigenServices.com

JSNIJava Script Native Interface

Access JS code from Java code and vice versa

Wrap your own or third-party JS-widgets with JSNI:• Google Maps• Flash objects• etc.

Example 1:

public static native void alert(String msg) /*-{ $wnd.alert(msg);}-*/;

Page 30: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

30 www.ExigenServices.com

JSNI

Example 2:

package mypackage;public MyClass{

public static int foo(){ ... }    public static native void exportStaticMethod() /*-{

$wnd.foo = $entry(@mypackage.MyClass::foo());}-*/;

}

Page 31: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

31 www.ExigenServices.com

Deferred binding

It is a pluggable compile-time type substitution and code generation mechanism.

Page 32: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

32 www.ExigenServices.com

Deferred binding

It is a pluggable compile-time type substitution and code generation mechanism.

Example:

Static bindingFoo f = new Foo();

 Dynamic Binding

Class c = Class.forName(fooImplName);Foo f = (Foo) c.newInstance();

 Deferred Binding

Foo f = (Foo) GWT.create(Foo.class);

Page 33: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

33 www.ExigenServices.com

Deferred binding

Goal - send exactly the right code to client, depending on

• User’s browser• Locale• Mode (debug / production)• Network characteristics• etc.

Page 34: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

34 www.ExigenServices.com

Deferred binding

Goal - send exactly the right code to client, depending on

• User’s browser• Locale• Mode (debug / production)• Network characteristics• etc.

Facilities

• Make fewer Http Requests• Eliminate dead code• Avoid polymorphic dispatch• Avoid synchronous XHR• Avoid spaghetti code (if-s in JS-code)• Try to use only inline code “elem.innerText = str”• etc.

Page 35: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

35 www.ExigenServices.com

Permutations

Page 36: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

36 www.ExigenServices.com

Permutations

Example:

Input:

DOMImpl dom = GWT.create(DOMImpl.class);

Page 37: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

37 www.ExigenServices.com

Permutations

Example:

Input:

DOMImpl dom = GWT.create(DOMImpl.class);

Implementations:DOMImplInternetExplorerDOMImplMozillaDOMImplOpera

  Property:user_agent = “IE”

Page 38: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

38 www.ExigenServices.com

Permutations

Example:

Input:

DOMImpl dom = GWT.create(DOMImpl.class);

Implementations:DOMImplInternetExplorerDOMImplMozillaDOMImplOpera

  Property:user_agent = “IE”

Output:

DOM dom = new DOMImplInternetExplorer();

Page 39: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

39 www.ExigenServices.com

Permutations

Example:

Page 40: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

40 www.ExigenServices.com

Perfect Caching

Page 41: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

41 www.ExigenServices.com

Perfect Caching

Bootstrap selection script loads Javascript ‘executable’ containing correct set of bindings for given request. 

<module>.nocache.js - small<md5>.cache.js – big

Page 42: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

42 www.ExigenServices.com

Perfect Caching

Bootstrap selection script loads Javascript ‘executable’ containing correct set of bindings for given request. 

<module>.nocache.js - small<md5>.cache.js – big Apache HTTP server .htaccess configuration: <Files *.nocache.*>

ExpiresActive on ExpiresDefault "now" Header merge Cache-Control "public, max-age=0, must-revalidate"

</Files>

<Files *.cache.*> ExpiresActive on ExpiresDefault "now plus 1 year"

</Files>

Page 43: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

43 www.ExigenServices.com

Monilithic Compilation

Page 44: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

44 www.ExigenServices.com

Monilithic Compilation

“The fastest code that which does not run”, --Joel Webber, GWT co-creator

Page 45: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

45 www.ExigenServices.com

Monilithic Compilation

“The fastest code that which does not run”, --Joel Webber, GWT co-creator

Example:

Shape shape = new Square(4);

1) int area = shape.getArea();

Page 46: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

46 www.ExigenServices.com

Monilithic Compilation

“The fastest code that which does not run”, --Joel Webber, GWT co-creator

Example:

Shape shape = new Square(4);

1) int area = shape.getArea();

2) int area = Shape_getArea(shape);

Page 47: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

47 www.ExigenServices.com

Monilithic Compilation

“The fastest code that which does not run”, --Joel Webber, GWT co-creator

Example:

Shape shape = new Square(4);

1) int area = shape.getArea();

2) int area = Shape_getArea(shape);

3) int area = shape.len * shape.len;

Page 48: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

48 www.ExigenServices.com

Monilithic Compilation

“The fastest code that which does not run”, --Joel Webber, GWT co-creator

Example:

Shape shape = new Square(4);

1) int area = shape.getArea();

2) int area = Shape_getArea(shape);

3) int area = shape.len * shape.len;

4) int area = 16;

Page 49: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

49 www.ExigenServices.com

Image Bundling

Page 50: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

50 www.ExigenServices.com

Image Bundling

Problem:

1) HTTP 1.1 limit: 2 outgoing connections per domain/port

Page 51: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

51 www.ExigenServices.com

Image Bundling

Problem:

1) HTTP 1.1 limit: 2 outgoing connections per domain/port

2) HTTP request has to be sent to the server for each resource (e.g. image)

Page 52: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

52 www.ExigenServices.com

Image Bundling

Problem:

1) HTTP 1.1 limit: 2 outgoing connections per domain/port

2) HTTP request has to be sent to the server for each resource (e.g. image)

3) Request for status 304 ("Not Modified")

Page 53: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

53 www.ExigenServices.com

Image Bundling

Solution:

interface Resources extends ClientBundle {@Source("logo.png")ImageResource logo();

 @Source("arrow.png")@ImageOptions(flipRtl = true)ImageResource pointer();

Page 54: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

54 www.ExigenServices.com

Image Bundling

Solution:

interface Resources extends ClientBundle {@Source("logo.png")ImageResource logo();

 @Source("arrow.png")@ImageOptions(flipRtl = true)ImageResource pointer();

} Resources resources = GWT.create(Resources.class);

Image img = new Image(resources.logo());

Page 55: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

55 www.ExigenServices.com

Code Splittingpublic class Hello implements EntryPoint { public void onModuleLoad() { Button b = new Button("Click me", new ClickHandler() { public void onClick(ClickEvent event) { Window.alert("Hello, AJAX"); } });  RootPanel.get().add(b); }}

Page 56: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

56 www.ExigenServices.com

Code Splittingpublic class Hello implements EntryPoint { public void onModuleLoad() { Button b = new Button("Click me", new ClickHandler() { public void onClick(ClickEvent event) { Window.alert("Hello, AJAX"); } });  RootPanel.get().add(b); }}

Page 57: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

57 www.ExigenServices.com

Code Splittingpublic class Hello implements EntryPoint { public void onModuleLoad() { Button b = new Button("Click me", new ClickHandler() { public void onClick(ClickEvent event) { GWT.runAsync(new RunAsyncCallback() {

public void onFailure(Throwable caught) { Window.alert("Code download failed"); } public void onSuccess() { Window.alert("Hello, AJAX"); }

}); } }); RootPanel.get().add(b); }}

Page 58: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

58 www.ExigenServices.com

HTML5 Features Support

Page 59: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

59 www.ExigenServices.com

HTML5 Features Support

• Client-side Storage – Use LocalStorage, SessionStorage, and monitor StorageEvents

Page 60: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

60 www.ExigenServices.com

HTML5 Features Support

• Client-side Storage – Use LocalStorage, SessionStorage, and monitor StorageEvents

• Canvas – Add visualizations using Canvas

• Audio – Use Audio widgets

• Video – Use Video widgets

Page 61: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

61 www.ExigenServices.com

HTML5 Features support

Page 62: CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

62 www.ExigenServices.com

http://www.exigenservices.by/webinars

To be continued…

• Client-server communication (RPC, JSON/XML)• MVP framework (Activities and Places)• DevMode (code-test-debug cycle)• Modules (properties, rules)• Generators (meta-programming)• UiBinder• Cell Widgets (CellTable, CellTree, CellBrowser)• …