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

Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun About me ... ‘mvn -Dconsole.profile=drools

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Best practices for structuring large GWT applications

Heiko Braun <[email protected]>

Page 2: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Topics

• GWT in 5 minutes

• Decomposing a large GWT application

• Introducing Project Errai

Page 4: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

What is GWT?

Page 5: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Write AJAX in the Java language

Page 6: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Decomposing large GWT applications

Page 9: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Example: BPM console

Page 10: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Challenge #1:Feature Set

• Different features per:

• Target runtime

• Development stage

• Project lifecycle

• Target audience

Page 11: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Solution #1:Workspace plugins

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

(2) Properties file or annotations

(3) Deferred Binding Generator

Page 13: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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

• Less coupled, but still dependency

• Compile-time

(1) Model changed(2) Update View

Page 15: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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

• Messaging API only shared dependency

• Notion of “presence”

(1) Publish messages

(2) Subscribe Listener

Page 16: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Limitation #2: Pub/Sub

• Decoupling through de-typed nature

• No compile-time checking

• Exchange protocol (contract) not “visible”

• Choreography validation?

Page 17: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Introducing Project Errai

Page 21: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Workspaces API

(1) Annotation driven

• Evolution of the property based config

• Uses Deferred Binding as well

(2) Automatic workspace assembly

Page 26: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Errai Widgets

• Complements OSS offering (i.e. Mosaic)

Page 27: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

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: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Demo Applications

Page 29: Best practices for structuring large GWT applications · Best practices for structuring large GWT applications Heiko Braun  About me ... ‘mvn -Dconsole.profile=drools

Q&A