CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

Post on 13-Jan-2015

619 views 0 download

Tags:

description

 

Transcript of CiklumJavaSat15112011:Andrew Mormysh-GWT features overview

GWT Features Overview

Andrey Mormysh

Java Developera.mormysh@gmail.com

October 15, 2011 www.ExigenServices.com

2 www.ExigenServices.com

GWT Google Web Toolkit

3 www.ExigenServices.com

GWT /ˈɡwɪt /Google Web Toolkit

4 www.ExigenServices.com

GWT-based projects

5 www.ExigenServices.com

GWT-based projects

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

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

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

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.

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

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

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…

12 www.ExigenServices.com

Features

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

13 www.ExigenServices.com

Features

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

14 www.ExigenServices.com

Features

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

15 www.ExigenServices.com

Features

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

16 www.ExigenServices.com

Features

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

17 www.ExigenServices.com

Features

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

18 www.ExigenServices.com

Features

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

19 www.ExigenServices.com

Features

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

20 www.ExigenServices.com

Features

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

21 www.ExigenServices.com

Features

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

22 www.ExigenServices.com

Features

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

23 www.ExigenServices.com

Features

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

24 www.ExigenServices.com

?

25 www.ExigenServices.com

26 www.ExigenServices.com

27 www.ExigenServices.com

JSNIJava Script Native Interface

Access JS code from Java code and vice versa

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.

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);}-*/;

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());}-*/;

}

31 www.ExigenServices.com

Deferred binding

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

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);

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.

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.

35 www.ExigenServices.com

Permutations

36 www.ExigenServices.com

Permutations

Example:

Input:

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

37 www.ExigenServices.com

Permutations

Example:

Input:

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

Implementations:DOMImplInternetExplorerDOMImplMozillaDOMImplOpera

  Property:user_agent = “IE”

38 www.ExigenServices.com

Permutations

Example:

Input:

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

Implementations:DOMImplInternetExplorerDOMImplMozillaDOMImplOpera

  Property:user_agent = “IE”

Output:

DOM dom = new DOMImplInternetExplorer();

39 www.ExigenServices.com

Permutations

Example:

40 www.ExigenServices.com

Perfect Caching

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

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>

43 www.ExigenServices.com

Monilithic Compilation

44 www.ExigenServices.com

Monilithic Compilation

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

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();

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);

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;

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;

49 www.ExigenServices.com

Image Bundling

50 www.ExigenServices.com

Image Bundling

Problem:

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

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)

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")

53 www.ExigenServices.com

Image Bundling

Solution:

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

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

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());

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); }}

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); }}

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); }}

58 www.ExigenServices.com

HTML5 Features Support

59 www.ExigenServices.com

HTML5 Features Support

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

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

61 www.ExigenServices.com

HTML5 Features support

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)• …