gwt jug stuttgart

29
Best practices for structuring large GWT applications Heiko Braun <[email protected] >

Upload: hbraun

Post on 19-May-2015

4.926 views

Category:

Technology


1 download

DESCRIPTION

Structuring large GWT applications

TRANSCRIPT

Page 1: GWT Jug Stuttgart

Best practices for structuring large GWT applications

Heiko Braun <[email protected]>

Page 2: GWT Jug Stuttgart

About me

• Heiko Braun

• Senior Software Engineer JBoss / Red Hat

• 4 years JBoss, 12 years industry

• Focus on SOA, BPM, GWT

• Contributor: JBossWS, jBPM, Riftsaw, Errai, SAM, Savarra

Page 3: GWT Jug Stuttgart

Topics

• GWT in 5 minutes

• Decomposing a large GWT application

• Introducing Project Errai

Page 4: GWT Jug Stuttgart

What is GWT?

Page 5: GWT Jug Stuttgart

Write AJAX in the Java language

Page 6: GWT Jug Stuttgart

Google Web Toolkit

• SDK: API, Compiler, Hosted Mode Browser

• Write AJAX apps in the Java language, then compile to optimized JavaScript

• Edit Java code, then view changes immediately without re-compiling

• Step through live AJAX code with your Java debugger

• Compile and deploy optimized, cross-browser JavaScript

Page 7: GWT Jug Stuttgart

GWT Features

• Communicate with your server through really simple RPC

• Reuse UI components across projects

• Use other JavaScript libraries and native JavaScript code

• Localize applications

• Choice of development tools

• Test your code with JUnit

• Open Source

Page 8: GWT Jug Stuttgart

Decomposing large GWT applications

Page 9: GWT Jug Stuttgart

Example: BPM console

Page 10: GWT Jug Stuttgart

Challenge #1:Feature Set

• Different features per:

• Target runtime

• Development stage

• Project lifecycle

• Target audience

Page 11: GWT Jug Stuttgart

Solution #1:Workspace plugins

• Determined at compile time

• Based on Maven dependency sets

• Using Deferred Binding

• Create and select a specific implementation of a class

• Either using Replacement or Generators

Page 12: GWT Jug Stuttgart

Solution #1:Workspace plugins

(1) ‘mvn -Dconsole.profile=drools install’

(2) Properties file or annotations

(3) Deferred Binding Generator

Page 13: GWT Jug Stuttgart

Limitation #1:Component interplay

• Each plugin component isolated

• No interplay possible

• It would introduce dependencies

• Grouping by functionality vs. usability

• Conceptual split not necessarily technical split

Page 14: GWT Jug Stuttgart

Challenge #2: Interplay w/o dependencies• Model-View-Controller ?

• Less coupled, but still dependency

• Compile-time

(1) Model changed(2) Update View

Page 15: GWT Jug Stuttgart

Solution #2: Pub/Sub• Messaging through publish / subscribe

• Messaging API only shared dependency

• Notion of “presence”

(1) Publish messages

(2) Subscribe Listener

Page 16: GWT Jug Stuttgart

Limitation #2: Pub/Sub

• Decoupling through de-typed nature

• No compile-time checking

• Exchange protocol (contract) not “visible”

• Choreography validation?

Page 17: GWT Jug Stuttgart

Challenge #3: Server side capabilities• Backend capabilities may change as well

• Staging vs. production

• Different product versions

• Target runtime derivations

• Remember: Compile-time linking AJAX is pure client side technology

Page 18: GWT Jug Stuttgart

Solution #3: Bootstrap

• Bootstrap: “Give me a list of capabilities”

• Usually RPC call when app starts

• Problem: Fixed initialization point

• Lazy Components?

(1) Client UI starts, request server status(2) PluginInfo (type, available)

Page 19: GWT Jug Stuttgart

Solution #3: Messaging w. Presence

• Presence: “Need a plumber. Please call XYZ”

• Relies on messaging bus behind the scenes

• Async, independent, durable

(1) Client: Seek capability

(2) Provider: Offer capability

Page 20: GWT Jug Stuttgart

Introducing Project Errai

Page 21: GWT Jug Stuttgart

Project Errai

• Consolidates JBoss GWT efforts

• Both R&D and actual product development

• Work in progress

• Best of breed spin-off as OSS

• Errai-Bus, Errai-Workspace, Errai,Widgets

• http://jboss.org/errai

Page 22: GWT Jug Stuttgart

Errai-Bus• Backbone to application

design

• Common architecture across client&server

• Enables federated architecture

• Asynchronous messaging(pub/sub)

• Conversational

• Both GWT and Javascript API (OpenHub Spec)

Page 23: GWT Jug Stuttgart

Errai-Bus API: Common to client & server

(1) Client: Publish (2) Server: Subscribe

• NOTE: Don’t confuse pub/sub roles with tiers

• Scenarios:

• client-client across server (chat server)

• client-client w/o server (inter component)

• client-server (client send)

• server-client (server push)

Page 24: GWT Jug Stuttgart

Errai-Workspaces

• UI environment for which to deploy your console

• Develop against a common workspace API

• Provides generic services

• Authentication & Authorization

• Logging & Exception handling

• Presence (aka Shoutbox)

• [...] (add your implementation here)

Page 25: GWT Jug Stuttgart

Workspaces API

(1) Annotation driven

• Evolution of the property based config

• Uses Deferred Binding as well

(2) Automatic workspace assembly

Page 26: GWT Jug Stuttgart

Errai Widgets

• Complements OSS offering (i.e. Mosaic)

Page 27: GWT Jug Stuttgart

Putting it all together• Baseline and best

practices

• Free composition of console components

• Different projects provide management tools

• Mix and match with 3rd party elements

Page 28: GWT Jug Stuttgart

Demo Applications

Page 29: GWT Jug Stuttgart

Q&A