GWT – The Java Advantage
Yoav Aharoni
Consultant, AlphaCSP
2
Oracle
Week
10/11/10
» Introduction
» GWT in Action
» How does it work?
» Key Features
» Best Practices
» Recap
» Discussion
» 3rd Parties
» Reference
Agenda
3
Oracle
Week
10/11/10
Introduction
GWT What?
4
Oracle
Week
10/11/10
 A Web Framework.
 A SOUI / SOFEA Framework.
 A Sort of JavaScript Framework.
 One of Google’s gifts to Java developers.
 All of the Above.
Google Web Toolkit Is:
Introduction
Service-Oriented Front-End
Architecture or Service-
Oriented User Interface
5
Oracle
Week
10/11/10
» A web framework for rapid developing and debugging
of JavaScript front-end applications in Java.
1. Develop in Java.
2. Compile into JavaScript.
3. Run on a Browser.
GWT in a Nutshell...
Introduction
BrowserJavaScriptJava
6
Oracle
Week
10/11/10
“GWT's mission is to radically improve the web
experience for users by enabling developers to use
existing Java tools to build no-compromise AJAX for
any modern browser.”
Mission Statement
Introduction
7
Oracle
Week
10/11/10
» It’s built for speed and it’s fast as it gets.
» Runs natively on the browser, no plugins needed.
» Cross browser compatible.
» Has everything a framework needs.
 Dynamic, rich, reusable widgets. Lots of them.
 Utilities and more.
» Big active community.
» Many 3rd party libraries already out there.
» Simple built-in Ajax/RPC mechanism.
What’s so good about it?
Introduction
8
Oracle
Week
10/11/10
» Develop using Java.
 Using YOUR IDE.
 Detect error in compile-time rather than runtime.
 Java tools: refactoring, debugging, profiling, etc…
 JUnit integration.
» Good development environment.
» It’s Open source: Apache v2.0 license.
» It’s Google’s – will be around for a long time.
What’s so good about it?
Introduction
9
Oracle
Week
10/11/10
» Announced at JavaOne, 2006.
» Formerly known as “Project Red Pill”.
» Current release: 2.1.
History
Introduction
05/
2006
10/
2010
06/
2009
GWT 1.0 RC 1
08/
2006
11/
2006
02/
2007
08/
2007
08/
2008
04/
2009
12/
2009
V 2.0V 1.7 V 2.1V 1.5
10
Oracle
Week
10/11/10
» Announced at JavaOne, 2006.
» Formerly known as “Project Red Pill”.
» Current release: 2.1.
History
Introduction
05/
2006
10/
2010
06/
2009
GWT 1.0 RC 1
V 2.0V 1.7
08/
2006
11/
2006
02/
2007
08/
2007
08/
2008
04/
2009
12/
2009
V 2.1
• Support for Java 5 features.
• Even more compiler optimizations.
• UI library additions (animations, themes).
• I18N (Bi-di, pluralizations), accessibility.
• Better DOM API.
V 1.5
11
Oracle
Week
10/11/10
» Announced at JavaOne, 2006.
» Formerly known as “Project Red Pill”.
» Current release: 2.1.
History
Introduction
05/
2006
10/
2010
06/
2009
GWT 1.0 RC 1
V 2.0V 1.7
08/
2006
11/
2006
02/
2007
08/
2007
08/
2008
04/
2009
12/
2009
V 2.1
• Development Mode
• Speed Tracer
• Code Splitting
• Compiler Optimizations
• Draft Compile
• Declarative UI
• ClientBundle
• HtmlUnit
V 1.5
12
Oracle
Week
10/11/10
» Announced at JavaOne, 2006.
» Formerly known as “Project Red Pill”.
» Current release: 2.1.
History
Introduction
05/
2006
10/
2010
06/
2009
GWT 1.0 RC 1
V 2.0V 1.7
08/
2006
11/
2006
02/
2007
08/
2007
08/
2008
04/
2009
12/
2009
V 2.1
• Cell Widgets
• MVP Framework
• Request Factory
• Editor framework
• Logging
• SafeHtml
• Spring Integration
V 1.5
13
Oracle
Week
10/11/10
GWT in Action
Seeing is believing
14
Oracle
Week
10/11/10
How does it work?
... and why is it so damn fast...
15
Oracle
Week
10/11/10
Architecture
JRE Emulation
GWT Compiler
Dev.
Mode
Class Library
Development
Servlet Container
GWT RPC
Remote Service Servlet
Web
Services
Server-Side
Ajax
GWT Runtime
Compiled
JavaScript
Client-Side
Compile
16
Oracle
Week
10/11/10
Development Lifecycle
Download SDK
+ Browser Plugin
Create Project
with IDE/Maven
Develop & Code
View & Debug
using Dev. Mode
Compile to
JavaScript
Deploy to Prod
Server
Profile with
Speed Tracer
Unit Test with
Java Tools
Debug using
Dev. Mode
Fix Bugs
17
Oracle
Week
10/11/10
» Definition: a technique used by the GWT compiler to
create and select a specific implementation of a class
based on a set of parameters.
» GWT produces a different application permutations for
each browser environment.
 Only one of these permutations is downloaded and executed
by the browser.
 Permutations can be created for each Locale.
 Additional custom parameters can be configured.
Deferred Binding
DOMImpl impl = GWT.create(DOMImpl.class);
18
Oracle
Week
10/11/10
» Branching is done in compile time rather than runtime.
 No runtime penalty for lookup.
» Download and evaluate only the minimum needed
code.
 Reduce download size.
 Reduce execution time.
» Saves development time by automatically generating
code to implement an interface or create a proxy class.
Deferred Binding - Benefits
More Info
20
Oracle
Week
10/11/10
» Only “used” code is compiled.
» Highly optimized JavaScript and CSS code.
» Images can be combined into one file to minimize
server requests (aka Image Sprites).
Compilation
21
Oracle
Week
10/11/10
» JavaScript implementations of the most commonly
used classes in JRE
 most of the java.lang package
 a subset of the java.util package
» Several classes are missing
 java.util.Calendar
 date-formatting classes
JRE emulation library
More Info
23
Oracle
Week
10/11/10
Developing with GWT
Lets get to work!
More Info
24
Oracle
Week
10/11/10
» Google SDK
» Eclipse
 Google Plugin for Eclipse
 Google GWT Designer (previously Instantiations)
 Cypal Studio for GWT
» IntelliJ IDEA - GWT Support Plugin.
» Netbeans - GWT4NB Plugin
» Maven - gwt-maven-plugin
» Speed Tracer
» GWT Theme Generator
Available Tools
More Info
34
Oracle
Week
10/11/10
Key Features
Tools of the Toolkit
35
Oracle
Week
10/11/10
» Widgets, Panels and Layout
» Ajax
» Internationalization
» ClientBundle
» UiBinder
» JavaScript Native Interface
» Bookmarks & Browser History Management
» Logging
» Safe HTML
» Validations
Key Features
50
Oracle
Week
10/11/10
Best Practices
Learn from experience
51
Oracle
Week
10/11/10
» All around the world developer have embraced:
Google Web Toolkit Best Practice.
» Highlights:
 Embrace Asynchrony.
 Command (dispatcher) pattern.
 Decoupling, decoupling, decoupling.
 MVP (Model/View/Presenter) pattern.
 Dependency Injection.
 Event Bus.
 Support history from the start (using PlaceManager).
GWT Best Practices
52
Oracle
Week
10/11/10
» Many 3rd party libraries implementing these concepts
has spawned.
» In GWT 2.1 built-in support for MVP, activities and
places was added.
 Joining the existing event bus support.
GWT Best Practices
53
Oracle
Week
10/11/10
HTML5 Show Case
54
Oracle
Week
10/11/10
Recap
Let’s wrap it up
55
Oracle
Week
10/11/10
» Driven by a big corporation - Google.
» Lighting fast.
 UI code runs at the client.
 Deferred binding.
 Code optimizations and magnification.
 Code splitting.
 Image Sprites.
 Asynchronous DNA.
 No state needs to be saved on the server.
Pros
Recap
Scalable
Responsive
Application
=
56
Oracle
Week
10/11/10
» Big, active community.
» Mature project (Version 2.1), ever improving.
» Has all you’re ever need + many 3rd party libs.
» Open Source (Apache v2.0) License.
» No Plugins needed.
» HTML 5 support.
» Can work with any back-end technology (like .NET) or
even without any back-end application.
Pros
Recap
57
Oracle
Week
10/11/10
» Satisfying development cycles using development
mode.
» Java development, with all benefits included.
 Java tools, refactoring, debugging.
 Strictly typed.
 Detect errors in compile time.
 Java unit testing.
» Toolkit tools: IDE plugins, Designer.
Pros
Recap
58
Oracle
Week
10/11/10
» Relies entirely on JavaScript.
 Cannot work if JavaScript is disabled.
 Accessibility issues (especially with older readers etc).
 Limited reflection.
 Limited SEO (search engine optimization).
» HTML Markup is harder to tweak.
» Longer design-refresh development cycles compared to
pure HMTL/CSS/JavaScript development.
» Almost impossible to debug production client-side code.
Cons
Recap
59
Oracle
Week
10/11/10
» When using RPC, model passed to the client must be
“hand-picked”.
 i.e when working with JPA/Hibernate.
 Might need to create TOs.
» Relatively slow bootstrap on page load compared to
plain HTML/CSS pages.
 Which is eventually faster, if application only loads once.
 But might be annoying if application is reloaded on every page
change.
Cons
Recap
60
Oracle
Week
10/11/10
» Best for:
 Building RIA.
 Desktop like applications.
 HTML5 Games.
 Gadgets.
» Not to be used for:
 Building simple/content websites.
 Applications which relies heavily on form submit.
Conclusion
Recap
61
Oracle
Week
10/11/10
Discussion
...This is the part where you ask questions...
62
Oracle
Week
10/11/10
3rd Parties
Community Contributions
63
Oracle
Week
10/11/10
» Google Web Toolkit Incubator
» Ajax/REST:
 GWT-REST
 RestyGWT
 Restlet
 Gwittir (+ other utilities)
» Widgets and more:
 Ext GWT (aka GXT), based on Ext-JS
 SmartGWT, based on Smart-Client
 Tatami, based on Dojo
 GWT Mosaic
3rd Party Libraries & Frameworks
64
Oracle
Week
10/11/10
» Patterns (MVP, MVC,...):
 GWT-Presenter
 GWT-Dispatch
 GWT-MVP
 GWTP
 GWT-Pectin
 MVP4G
» Charts:
 Gchart – HTML5/Canvas Charts (no Plugins).
 OFCGWT – Open Flash Chart integration.
 Charts4j-GWT – Google API Charts.
3rd Party Libraries & Frameworks
65
Oracle
Week
10/11/10
» Dependency Injection:
 GIN – Guice-like DI
 GWToolbox – Spring-like DI + utilities + widgets.
 Rocket-GWT – DI + utilities.
» Utilities:
 GWT-Log – Logging.
 GWT-Validation – Validation.
 GWT-DND – Drag n’ drop.
 GWT-FX – Animations.
 Goda-Time – Joda Time for GWT.
 GWT-Mobile-Webkit – HTML 5 support.
3rd Party Libraries & Frameworks
66
Oracle
Week
10/11/10
» Canvas:
 GWT-Canvas
 GWT-G2D
 GWTCanvas – inside Google Incubator.
» Misc:
 Emite – XMPP (Jabber) Chat Client.
 GWT-Cal – Calendar widget (like Google Calendar, Outlook, iCal).
 Vaadin – Framework based on GWT.
 GWT-Client-Storage – HTML5 local storage.
3rd Party Libraries & Frameworks
67
Oracle
Week
10/11/10
» Spring Integration
 Spring MVC
 Spring Roo (since GWT 2.1)
 Spring Insight profiler.
» Vaadin – Framework based on GWT.
Integration
68
Oracle
Week
10/11/10
» GWT Reference
» Javadoc
» Forum
» onGWT.com
» Blog
» Books
Documentation
Reference
68
69
Oracle
Week
10/11/10
Thank You!


GWT – The Java Advantage

  • 1.
    GWT – TheJava Advantage Yoav Aharoni Consultant, AlphaCSP
  • 2.
    2 Oracle Week 10/11/10 » Introduction » GWTin Action » How does it work? » Key Features » Best Practices » Recap » Discussion » 3rd Parties » Reference Agenda
  • 3.
  • 4.
    4 Oracle Week 10/11/10  A WebFramework.  A SOUI / SOFEA Framework.  A Sort of JavaScript Framework.  One of Google’s gifts to Java developers.  All of the Above. Google Web Toolkit Is: Introduction Service-Oriented Front-End Architecture or Service- Oriented User Interface
  • 5.
    5 Oracle Week 10/11/10 » A webframework for rapid developing and debugging of JavaScript front-end applications in Java. 1. Develop in Java. 2. Compile into JavaScript. 3. Run on a Browser. GWT in a Nutshell... Introduction BrowserJavaScriptJava
  • 6.
    6 Oracle Week 10/11/10 “GWT's mission isto radically improve the web experience for users by enabling developers to use existing Java tools to build no-compromise AJAX for any modern browser.” Mission Statement Introduction
  • 7.
    7 Oracle Week 10/11/10 » It’s builtfor speed and it’s fast as it gets. » Runs natively on the browser, no plugins needed. » Cross browser compatible. » Has everything a framework needs.  Dynamic, rich, reusable widgets. Lots of them.  Utilities and more. » Big active community. » Many 3rd party libraries already out there. » Simple built-in Ajax/RPC mechanism. What’s so good about it? Introduction
  • 8.
    8 Oracle Week 10/11/10 » Develop usingJava.  Using YOUR IDE.  Detect error in compile-time rather than runtime.  Java tools: refactoring, debugging, profiling, etc…  JUnit integration. » Good development environment. » It’s Open source: Apache v2.0 license. » It’s Google’s – will be around for a long time. What’s so good about it? Introduction
  • 9.
    9 Oracle Week 10/11/10 » Announced atJavaOne, 2006. » Formerly known as “Project Red Pill”. » Current release: 2.1. History Introduction 05/ 2006 10/ 2010 06/ 2009 GWT 1.0 RC 1 08/ 2006 11/ 2006 02/ 2007 08/ 2007 08/ 2008 04/ 2009 12/ 2009 V 2.0V 1.7 V 2.1V 1.5
  • 10.
    10 Oracle Week 10/11/10 » Announced atJavaOne, 2006. » Formerly known as “Project Red Pill”. » Current release: 2.1. History Introduction 05/ 2006 10/ 2010 06/ 2009 GWT 1.0 RC 1 V 2.0V 1.7 08/ 2006 11/ 2006 02/ 2007 08/ 2007 08/ 2008 04/ 2009 12/ 2009 V 2.1 • Support for Java 5 features. • Even more compiler optimizations. • UI library additions (animations, themes). • I18N (Bi-di, pluralizations), accessibility. • Better DOM API. V 1.5
  • 11.
    11 Oracle Week 10/11/10 » Announced atJavaOne, 2006. » Formerly known as “Project Red Pill”. » Current release: 2.1. History Introduction 05/ 2006 10/ 2010 06/ 2009 GWT 1.0 RC 1 V 2.0V 1.7 08/ 2006 11/ 2006 02/ 2007 08/ 2007 08/ 2008 04/ 2009 12/ 2009 V 2.1 • Development Mode • Speed Tracer • Code Splitting • Compiler Optimizations • Draft Compile • Declarative UI • ClientBundle • HtmlUnit V 1.5
  • 12.
    12 Oracle Week 10/11/10 » Announced atJavaOne, 2006. » Formerly known as “Project Red Pill”. » Current release: 2.1. History Introduction 05/ 2006 10/ 2010 06/ 2009 GWT 1.0 RC 1 V 2.0V 1.7 08/ 2006 11/ 2006 02/ 2007 08/ 2007 08/ 2008 04/ 2009 12/ 2009 V 2.1 • Cell Widgets • MVP Framework • Request Factory • Editor framework • Logging • SafeHtml • Spring Integration V 1.5
  • 13.
  • 14.
    14 Oracle Week 10/11/10 How does itwork? ... and why is it so damn fast...
  • 15.
    15 Oracle Week 10/11/10 Architecture JRE Emulation GWT Compiler Dev. Mode ClassLibrary Development Servlet Container GWT RPC Remote Service Servlet Web Services Server-Side Ajax GWT Runtime Compiled JavaScript Client-Side Compile
  • 16.
    16 Oracle Week 10/11/10 Development Lifecycle Download SDK +Browser Plugin Create Project with IDE/Maven Develop & Code View & Debug using Dev. Mode Compile to JavaScript Deploy to Prod Server Profile with Speed Tracer Unit Test with Java Tools Debug using Dev. Mode Fix Bugs
  • 17.
    17 Oracle Week 10/11/10 » Definition: atechnique used by the GWT compiler to create and select a specific implementation of a class based on a set of parameters. » GWT produces a different application permutations for each browser environment.  Only one of these permutations is downloaded and executed by the browser.  Permutations can be created for each Locale.  Additional custom parameters can be configured. Deferred Binding DOMImpl impl = GWT.create(DOMImpl.class);
  • 18.
    18 Oracle Week 10/11/10 » Branching isdone in compile time rather than runtime.  No runtime penalty for lookup. » Download and evaluate only the minimum needed code.  Reduce download size.  Reduce execution time. » Saves development time by automatically generating code to implement an interface or create a proxy class. Deferred Binding - Benefits More Info
  • 19.
    20 Oracle Week 10/11/10 » Only “used”code is compiled. » Highly optimized JavaScript and CSS code. » Images can be combined into one file to minimize server requests (aka Image Sprites). Compilation
  • 20.
    21 Oracle Week 10/11/10 » JavaScript implementationsof the most commonly used classes in JRE  most of the java.lang package  a subset of the java.util package » Several classes are missing  java.util.Calendar  date-formatting classes JRE emulation library More Info
  • 21.
  • 22.
    24 Oracle Week 10/11/10 » Google SDK »Eclipse  Google Plugin for Eclipse  Google GWT Designer (previously Instantiations)  Cypal Studio for GWT » IntelliJ IDEA - GWT Support Plugin. » Netbeans - GWT4NB Plugin » Maven - gwt-maven-plugin » Speed Tracer » GWT Theme Generator Available Tools More Info
  • 23.
  • 24.
    35 Oracle Week 10/11/10 » Widgets, Panelsand Layout » Ajax » Internationalization » ClientBundle » UiBinder » JavaScript Native Interface » Bookmarks & Browser History Management » Logging » Safe HTML » Validations Key Features
  • 25.
  • 26.
    51 Oracle Week 10/11/10 » All aroundthe world developer have embraced: Google Web Toolkit Best Practice. » Highlights:  Embrace Asynchrony.  Command (dispatcher) pattern.  Decoupling, decoupling, decoupling.  MVP (Model/View/Presenter) pattern.  Dependency Injection.  Event Bus.  Support history from the start (using PlaceManager). GWT Best Practices
  • 27.
    52 Oracle Week 10/11/10 » Many 3rdparty libraries implementing these concepts has spawned. » In GWT 2.1 built-in support for MVP, activities and places was added.  Joining the existing event bus support. GWT Best Practices
  • 28.
  • 29.
  • 30.
    55 Oracle Week 10/11/10 » Driven bya big corporation - Google. » Lighting fast.  UI code runs at the client.  Deferred binding.  Code optimizations and magnification.  Code splitting.  Image Sprites.  Asynchronous DNA.  No state needs to be saved on the server. Pros Recap Scalable Responsive Application =
  • 31.
    56 Oracle Week 10/11/10 » Big, activecommunity. » Mature project (Version 2.1), ever improving. » Has all you’re ever need + many 3rd party libs. » Open Source (Apache v2.0) License. » No Plugins needed. » HTML 5 support. » Can work with any back-end technology (like .NET) or even without any back-end application. Pros Recap
  • 32.
    57 Oracle Week 10/11/10 » Satisfying developmentcycles using development mode. » Java development, with all benefits included.  Java tools, refactoring, debugging.  Strictly typed.  Detect errors in compile time.  Java unit testing. » Toolkit tools: IDE plugins, Designer. Pros Recap
  • 33.
    58 Oracle Week 10/11/10 » Relies entirelyon JavaScript.  Cannot work if JavaScript is disabled.  Accessibility issues (especially with older readers etc).  Limited reflection.  Limited SEO (search engine optimization). » HTML Markup is harder to tweak. » Longer design-refresh development cycles compared to pure HMTL/CSS/JavaScript development. » Almost impossible to debug production client-side code. Cons Recap
  • 34.
    59 Oracle Week 10/11/10 » When usingRPC, model passed to the client must be “hand-picked”.  i.e when working with JPA/Hibernate.  Might need to create TOs. » Relatively slow bootstrap on page load compared to plain HTML/CSS pages.  Which is eventually faster, if application only loads once.  But might be annoying if application is reloaded on every page change. Cons Recap
  • 35.
    60 Oracle Week 10/11/10 » Best for: Building RIA.  Desktop like applications.  HTML5 Games.  Gadgets. » Not to be used for:  Building simple/content websites.  Applications which relies heavily on form submit. Conclusion Recap
  • 36.
  • 37.
  • 38.
    63 Oracle Week 10/11/10 » Google WebToolkit Incubator » Ajax/REST:  GWT-REST  RestyGWT  Restlet  Gwittir (+ other utilities) » Widgets and more:  Ext GWT (aka GXT), based on Ext-JS  SmartGWT, based on Smart-Client  Tatami, based on Dojo  GWT Mosaic 3rd Party Libraries & Frameworks
  • 39.
    64 Oracle Week 10/11/10 » Patterns (MVP,MVC,...):  GWT-Presenter  GWT-Dispatch  GWT-MVP  GWTP  GWT-Pectin  MVP4G » Charts:  Gchart – HTML5/Canvas Charts (no Plugins).  OFCGWT – Open Flash Chart integration.  Charts4j-GWT – Google API Charts. 3rd Party Libraries & Frameworks
  • 40.
    65 Oracle Week 10/11/10 » Dependency Injection: GIN – Guice-like DI  GWToolbox – Spring-like DI + utilities + widgets.  Rocket-GWT – DI + utilities. » Utilities:  GWT-Log – Logging.  GWT-Validation – Validation.  GWT-DND – Drag n’ drop.  GWT-FX – Animations.  Goda-Time – Joda Time for GWT.  GWT-Mobile-Webkit – HTML 5 support. 3rd Party Libraries & Frameworks
  • 41.
    66 Oracle Week 10/11/10 » Canvas:  GWT-Canvas GWT-G2D  GWTCanvas – inside Google Incubator. » Misc:  Emite – XMPP (Jabber) Chat Client.  GWT-Cal – Calendar widget (like Google Calendar, Outlook, iCal).  Vaadin – Framework based on GWT.  GWT-Client-Storage – HTML5 local storage. 3rd Party Libraries & Frameworks
  • 42.
    67 Oracle Week 10/11/10 » Spring Integration Spring MVC  Spring Roo (since GWT 2.1)  Spring Insight profiler. » Vaadin – Framework based on GWT. Integration
  • 43.
    68 Oracle Week 10/11/10 » GWT Reference »Javadoc » Forum » onGWT.com » Blog » Books Documentation Reference 68
  • 44.