KEMBAR78
GWT Jug Stuttgart | PDF
Best practices for structuring
  large GWT applications
     Heiko Braun <hbraun@redhat.com>
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
Topics


•   GWT in 5 minutes
•   Decomposing a large GWT application
•   Introducing Project Errai
What is GWT?
Write AJAX in the Java language
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
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
Decomposing large
GWT applications
Example: BPM console
Challenge #1:Feature Set

       •   Different features per:
           •   Target runtime
           •   Development stage
           •   Project lifecycle
           •   Target audience
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
Solution #1:
                                 Workspace plugins
(1) ‘mvn -Dconsole.profile=drools install’


                                                 (2) Properties file or annotations




                                            (3) Deferred Binding Generator
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
Challenge #2:
      Interplay w/o dependencies
       •     Model-View-Controller ?

            •       Less coupled, but still dependency

            •       Compile-time


(1) Model changed
                                        (2) Update View
Solution #2: Pub/Sub
       •      Messaging through publish / subscribe

       •      Messaging API only shared dependency

       •      Notion of “presence”



(1) Publish messages




                                                 (2) Subscribe Listener
Limitation #2: Pub/Sub

•   Decoupling through de-typed nature
    •   No compile-time checking
•   Exchange protocol (contract) not “visible”
    •   Choreography validation?
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
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)
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
Introducing Project Errai
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
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)
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)
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)
Workspaces API
        •     Evolution of the property based config

        •     Uses Deferred Binding as well


(1) Annotation driven                                 (2) Automatic workspace assembly
Errai Widgets
• Complements OSS offering (i.e. Mosaic)
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
Demo Applications
Q&A

GWT Jug Stuttgart

  • 1.
    Best practices forstructuring large GWT applications Heiko Braun <hbraun@redhat.com>
  • 2.
    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
  • 3.
    Topics • GWT in 5 minutes • Decomposing a large GWT application • Introducing Project Errai
  • 4.
  • 5.
    Write AJAX inthe Java language
  • 6.
    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
  • 7.
    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
  • 8.
  • 9.
  • 10.
    Challenge #1:Feature Set • Different features per: • Target runtime • Development stage • Project lifecycle • Target audience
  • 11.
    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
  • 12.
    Solution #1: Workspace plugins (1) ‘mvn -Dconsole.profile=drools install’ (2) Properties file or annotations (3) Deferred Binding Generator
  • 13.
    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
  • 14.
    Challenge #2: Interplay w/o dependencies • Model-View-Controller ? • Less coupled, but still dependency • Compile-time (1) Model changed (2) Update View
  • 15.
    Solution #2: Pub/Sub • Messaging through publish / subscribe • Messaging API only shared dependency • Notion of “presence” (1) Publish messages (2) Subscribe Listener
  • 16.
    Limitation #2: Pub/Sub • Decoupling through de-typed nature • No compile-time checking • Exchange protocol (contract) not “visible” • Choreography validation?
  • 17.
    Challenge #3: Server sidecapabilities • 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
  • 18.
    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)
  • 19.
    Solution #3: Messagingw. 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
  • 20.
  • 21.
    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
  • 22.
    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)
  • 23.
    Errai-Bus API: Commonto 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)
  • 24.
    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)
  • 25.
    Workspaces API • Evolution of the property based config • Uses Deferred Binding as well (1) Annotation driven (2) Automatic workspace assembly
  • 26.
    Errai Widgets • ComplementsOSS offering (i.e. Mosaic)
  • 27.
    Putting it alltogether • Baseline and best practices • Free composition of console components • Different projects provide management tools • Mix and match with 3rd party elements
  • 28.
  • 29.