(ARCHITECTING WEB APPLICATIONS WITHOUT
GWT-USER)
Beyond GWT 3.0 Panic
Cristiano Costantini
@cristcost
+CristianoCostantini
http://lnkdin.me/p/cristianocostantini
GWT and ServiceMix project: 

270K LoC, 5500 classes, more than 200 Maven modules
GWT MEET-UP 2015
“GWT 2.8 and Beyond”, by Ray Cromwell, Goktug Gokdogan
OK… WHAT DO WE
DO NOW?
STOP USING GWT?
No, I want to reuse Java in Web
Applications, mobile platforms and off-
course in the Java Backend
STOP USING GWT?
1st. remove GWT-User from dependencies
2nd. don’t use JSNI, use JsInterop
3rd. don’t use Widgets, use Polymer
4th. don’t use IDE plugins*
5th. don’t use GWT RPC
Experiments Checklist:
1st. remove GWT-User from dependencies
2nd. don’t use JSNI, use JsInterop
3rd. don’t use Widgets, use Polymer
4th. don’t use IDE plugins*
5th. don’t use GWT RPC
LET’S PUT IT INTO PRACTICE
Experiments Checklist:
INTRODUCING WUnit
an example application to test our
survival strategy
INTRODUCING WUNIT
WUNIT IS A UNIT TEST FRAMEWORK FOR…
INTRODUCING WUNIT
WUNIT IS A UNIT TEST FRAMEWORK FOR…
INTRODUCING WUNIT
…WARHAMMER, THE GAME
Testing which “Unit” is the best is really slow
Testing needs throwing a lot of dice
Using the “Assault
Dice” app…
…solves only 

part of the problem
SO IT
CAME
WUnit
DEMO
MANUAL
DICE APP
WUNIT
0 12,5 25 37,5 50
BENCHMARK
(Minutes to test two units)
AT FIRST WUNIT IS BORN WITH THIS ARCHITECTURE
CONSOLE ENGINE MODEL
POJOJavaSystem.out
THE VALUE OF USING JAVA TO IMPLEMENT THE GAME LOGIC
ENGINE
Java
This code is so much complex
(Warhammer rules are so) that I wouldn’t
attempt to write it without a full OOP
language with solid development tools
THE VALUE OF USING JAVA TO IMPLEMENT THE GAME LOGIC
ENGINE
Java
This code is so much complex
(Warhammer rules are so) that I wouldn’t
attempt to write it without a full OOP
language with solid development tools
THE VALUE OF USING JAVA TO IMPLEMENT THE GAME LOGIC
ENGINE
Java
This code is so much complex
(Warhammer rules are so) that I wouldn’t
attempt to write it without a full OOP
language with solid development tools
THE VALUE OF USING JAVA TO IMPLEMENT THE GAME LOGIC
ENGINE
Java
This code is so much complex
(Warhammer rules are so) that I wouldn’t
attempt to write it without a full OOP
language with solid development tools
WUnit’s Engine is implemented in Java
Developed with strong TDD
(coverage is about 93.6%)
REUSE - REUSE - REUSE
AIM CROSS-PLATFORM
CONSOLE
ENGINE MODEL
POJOJava
System.out
WEB
ANDROID
GWT/j2cl
Android
iOS
j2objc
…AND THEN I WANTED TO TO BUILD
AN USER INTERFACE FOR WUNIT:
HOW DID I DID IT?
(Singular not available)
HOW TO USE GWT
AND NOT GWT-USER
(Experiments made with WUnit prototype)
ARCHITECTING WEB APPLICATIONS FOR REUSE
VIEW
INPUT
PRESENTER ENGINE MODEL
VIEW
OUTPUT
written with
POJO
written in (pure)

Java
written in
GWT/JS
written in
Polymer
Note: Engine and Model are compiled
to Javascript and run on the browser
thanks to javaemul !
REMOVE GWT-USER FROM DEPENDENCIES
1st
…but it comes the first failure!
JsInterop annotations and EntryPoint interface are inside GWT-user.
REMOVE GWT-USER FROM DEPENDENCIES
1st
…but it comes the first failure!
JsInterop annotations and EntryPoint interface are inside GWT-user.
Then, just avoid using anything else from GWT-user…
REMOVE GWT-USER FROM DEPENDENCIES
1st
…and avoid inheriting “User” module in your .gwt.xml
-- TO GWT STEERING COMMITTEE --
please create an independent library 

with EntryPoint and JsInterop interfaces
so we can remove GWT-User from dependencies
Polymer is cool!
Write the widgets in javascript
DON'T USE WIDGETS, USE POLYMER
2nd
…displays as a table’s row on the browser
The custom HTML element…
<wunit-dice>element
<wunit-dice>element
Aspect
<wunit-game>element
<wunit-game>element
Aspect
@JsType
USE JsInterop
3rd
@JsType
USE JsInterop
3rd
* Note: this WUnit prototype has used the OLD JsInterop annotations
HTMLHOSTPAGE
LINK FROM GWT TO HOST PAGE
LINK FROM GWT TO HOST PAGE
Fail! I had to use JSNI (but it is limited to invoking query selector from Java,
and it can be rewritten with the new JsInterop)
OUTPUT
FROM JAVA TO POLYMER
ELEMENTS
VIEW
OUTPUT
Polymer
OUTPUT
FROM JAVA TO POLYMER
ELEMENTS
VIEW
OUTPUT
Polymer
INPUT
FROM POLYMER
ELEMENTS TO JAVA
Polymer
VIEW
INPUT
INPUT
FROM POLYMER
ELEMENTS TO JAVA
Polymer
VIEW
INPUT
DON'T USE IDE PLUGINS 4th
Unfortunately this solution does not works standalone…
I've hacked extensively the CodeServer
*
Unfortunately this solution does not works standalone…
I've hacked extensively the CodeServer
HACKS-HACKS-HACKS
*
<add-linker name="sso" />
FOCUS: SSO LINKER
<add-linker name="sso" />
FOCUS: SSO LINKER
-- TO GWT STEERING COMMITTEE --
please make Code Server more modular and reusable so we
can use it this approach without hacks
This problem is not solved yet
(WUnit don't uses client-server communication)
Work in progress
It would be possible to implement a clean approach if GWT was supporting GSON or
if the javaemul was supporting (a more rich subset of) Java Reflection
DON'T USE GWT RPC
5th
-- TO GWT STEERING COMMITTEE --
please create an independent and modular library 

with the javaemul, so it can be extended in a clean way
CONCLUSIONS:
How much GWT-User have we used in WUnit?
How much GWT-User have we used in WUnit?
Instrument
for
coverage
How much GWT-User have we used in WUnit?
Compile,
including
gwt:compile
How much GWT-User have we used in WUnit?
Execute
JettyEmbeddedServer
(including Code Server)
How much GWT-User have we used in WUnit?
* Open and run the app 

(to trigger Code Server compilation)
How much GWT-User have we used in WUnit?
Generate
coverage
report
COVERAGE REPORT WUNIT
(GWT Compilation and Code Server execution)
+ SUPER SOURCES
+ SUPER SOURCES
J2CL ?
FUTURE:
Maven archetype or Template for this approach
https://github.com/codejuicer/gwt-slimmize
(release after some clean up and official gwt 2.8.0)
Career Website:
https://www.thalesgroup.com/en/homepage/careers
Jobs info:
cv.risorseumane@thalesgroup.com
INTERESTED WORKING IN MY TEAM?
THANKS

GWTcon 2015 - Beyond GWT 3.0 Panic