SlideShare a Scribd company logo
1 of 57
Download to read offline
Spring Roo 1.0.0:
                                           Technical Deep Dive

                                         Roo Internals and Add-On Development

                                                 Ben Alex, Project Lead, Spring Roo




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Agenda


      •       Architectural Journey
      •       Implementation
      •       Development Mode
      •       Building Add-Ons
      •       Conclusion




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   2
Agenda


      •       Architectural Journey
      •       Implementation
      •       Development Mode
      •       Building Add-Ons
      •       Conclusion




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   3
Design Goals


      • High productivity for Java developers
                – Reuse their existing knowledge, skills and experience


      • Eliminate barriers to adoption
                – Lock-in, runtime, size, development experience


      • Embrace the strengths of Java
                – Dev-time: tooling, popularity, API quality, static typing
                – Deploy-time: performance, memory use, footprint




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   4
High-Impact Decisions


      • Use Java
                – This is a tool for Java developers
                – It defeats the purpose if we insist on a new language


      • Don't create a runtime
                – This avoids bugs, lock-in, adoption barriers, approvals
                – This avoids CPU cost, RAM cost and footprint cost


      • This easily led to some sort of generation model




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   5
Prototyped Approaches


      •       Pluggable Annotation Processing API (JSR 269)
      •       Generate source at build time (XDoclet-style)
      •       Generate bytecode at build time (ASM)
      •       Generate bytecode at runtime (ASM)
      •       Advanced proxy-based approaches (Spring AOP)
      •       IDE plugins

      • None of them satisfied all of the design goals




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   6
Decision 1: Use AspectJ

      • AspectJ ITDs for “active” generation
                – Active generation automatically maintains output


      • Delivers compilation unit separation of concern
                – Easier for users, and easier for us as developers


      • Instant IDE support
                – Reduce time to market and adoption barriers


      • Other good reasons
                – Mature, “push in” refactor, compile-time is welcome

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   7
ITD Model


      • Roo owns *_Roo_*.aj files
                – Will delete them if necessary


      • Every ITD provider registers a “suffix” it uses
                – Eg “Entity” becomes *_Roo_Entity.aj
                – A missing ITD provider causes AJ file removal


      • ITDs have proper import management
                – So they look and feel normal to developers
                – So they “push in refactor” in a natural form



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   8
Decision 2: Create A Shell


      • Need something to host the “active” generation

      • Need something to receive user commands

      • Usability issues were of extremely high priority

      • We chose an interactive shell
                – Highest usability (tab, context awareness, hiding, hints...)
                – Background monitoring of externally-made changes
                – Background monitoring avoided crude “generate” steps


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   9
Shell Model

      • Shell will perform a “startup” scan
                – To handle changes made while it wasn't running


      • Shell will monitor file system once started
                – To handle changes made while it is running


      • Shell will have a set of commands registered
                – To handle explicit directives from the user


      • Roo will never modify a *.java file except at the
        explicit request of a user via a shell command

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   10
That Left One Key Question...




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   11
Control Information

            AspectJ ITDs

              Person_Roo_
                                                             write                            Roo                            read              Person.java
               ToString.aj                                                                   Roo
                                                                                            Add-Ons
                                                                                            Roo
                                                                                           Add-Ons
                                                                                          Roo                                                  name:String
             toString():String                                                           Add-Ons
                                                                                        Add-Ons



              Person_Roo_
              JavaBean.aj
                                                                read                             AspectJ                            read
         getName():String                                                                        Compiler
       setName(String):void

                                                                                                                                              Person.class

                                                                                                                     write
How will add-ons know                                                                                                                           name:String
                                                                                                                                              toString():String
what to generate?                                                                                                                            getName():String
                                                                                                                                           setName(String):void


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                                                12
Metadata

      • Project details
                – Project name, dependencies, build system...


      • Java type details
                – Fields, methods, constructors, inheritance...


      • Higher-level concepts
                – Entity properties, controller paths, validation rules...


      • Must be automatically determined from project
                – With @Roo* (source level retention) where infeasible


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   13
Metadata Model


      • Immutable
      • String-based keys (start with “MID:”)
      • Built on demand only (never persisted)

      • Metadata can depend on other metadata
                – If “upsteam” metadata changes, “downstream” is told
                – Some metadata will want to monitor the file system


      • Central metadata service and cache required



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   14
Demo #1




                                         Shell Operation and ITD Maintenance




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   15
Agenda


      •       Architectural Journey
      •       Implementation
      •       Development Mode
      •       Building Add-Ons
      •       Conclusion




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   16
Conventions We Follow


      •       Ensure usability is first-class
      •       Minimize the JAR footprint that Roo requires
      •       Dependencies only from Enterprise Bundle Repo
      •       Relocate runtime needs to sister Spring projects
      •       Embrace immutability as much as possible
      •       Maximize performance in generated code
      •       Minimize memory consumption in generated code
      •       Use long artifact IDs to facilitate identification
      •       Don't put into @Roo* what you could calculate
      •       Don't violate generator predictability conventions

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   17
The Roo Distribution


      • “Roo” is split into two logical components

      • Base add-ons
                – org.springframework.roo.addon.*
                – Provide major out-of-the-box Roo features
                – Provide metadata for other add-ons


      • Roo Core
                – org.springframework.roo.* (excluding .addon.*)
                – Provide services add-ons will almost always require



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   18
1.0.0 Base Add-Ons

      •       Backup                                                                              •       Logging
      •       Bean Info                                                                           •       Maven
      •       Configurable                                                                        •       Pluralization
      •       Data On Demand                                                                      •       Property Editor
      •       Email                                                                               •       Property File
      •       Entity                                                                              •       Security
      •       Dynamic Finder                                                                      •       Integration Test
      •       Java Bean                                                                           •       ToString
      •       JMS                                                                                 •       Web (various)
      •       JPA

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.           19
Role of Third Party Add-Ons

      • 3rd party add-ons have a long-term role in Roo

      •       Minimize download size of Roo distribution
      •       Avoid licensing issues with Roo distribution
      •       Facilitate features of more niche interest
      •       Separate project management and maintenance
      •       Enable end user customization
      •       Provide a sandbox for easy experimentation




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   20
Core Components


                                                                                      Classpath



                                                     Process Manager



                                     Project                                                                     File Undo    Shell



            Model                                             Metadata                                         File Monitor




                                                                                         Support
                                                                                          (used by all)




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                    21
File Monitor API


      • Mostly used by project and classpath modules
                – Rare for an add-on to directly use file monitor


      • Publishes startup and “on change” events

      • Events
                –      Create
                –      Update
                –      Delete
                –      Rename (if implementation supported)
                –      Monitoring start (for each file when first found)

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   22
File Monitor Implementation


      • Polling-based implementation

      • Auto-scales to reduce CPU overhead

      • Shell commands
                – “poll status” → indicates scan frequency and duration
                – “poll speed” → allows specification of frequency
                – “poll now” → forces an immediate poll




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   23
Metadata Identifiers (MIDs)


       MID:o.s.r.classpath.PhysicalTypeId#SRC_MAIN_JAVA?com.foo.Bar

        Static          MetadataIdentificationUtils.getMdClass(..)                                        MetadataIdentificationUtils.getMdInstance(..)




      • Immutable strings to avoid GC cost

      • Note the “instance” portion denotes a Java type
                – Most MIDs include this physical location and type name
                – Use PhysicalTypeIdentifier.getPath(..) and
                  getJavaType(..) to directly extract typesafe objects


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                                        24
Metadata Facilities

                                                                                                                      Metadata
                               Add-On                                                                                Dependency
                                                                                   registers + notifies               Registry
                                Metadata
                                Provider
                                                                                                 queries
                                                                                                                      Metadata
                                                                                                                      Service

                                Metadata
                                  Item
                                                                                                stores

                                                                                                                      Metadata
                                                                                                                       Cache


        •       MetadataService can provide all metadata in the system
        •       MetadataService auto-evicts all downstream dependencies
        •       Dependency registration can be MID class or MID instance specific


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                25
Project Abstraction


      • Abstracts the user's project build system
                –      Immutable metadata (including dependency details)
                –      Path (eg SRC_MAIN_JAVA) mapping to directories
                –      Operations object to modify project structures
                –      Access to the PathResolver instance


      • Maven implementation via add-on
                – Designed to also support Ivy in due course (ROO-91)


      • Add-ons will regularly use ProjectOperations


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   26
Process Manager


      • Ensures non-overlapping synchronization
                – Background file monitor polling thread
                – Shell command foreground thread


      • Facilitates “atomic” operations with rollback
                – Notifies disk changes until disk is in stable state
                – Rolls back disk changes if from a failed shell command


      • Provides a FileManager abstraction
                – Add-ons must use this abstraction for disk changes
                – Reads via FileManager are optional (but recommended)


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   27
Classpath API

            MID:o.s.r.classpath.PhysicalTypeId#SRC_MAIN_JAVA?com.foo.Bar

                                Physical                                                        Physical
                                  Type                                                            Type
                                Identifier                                                      Category




                                Physical                                                          Physical
                                 Type                                                               Type
                                Metadata                                                           Details




                                                                 ClassOrInterface
                                                                                                                     ItdTypeDetails
                                                                   TypeDetails




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                    28
Classpath Implementation

      • JavaParser
                – Provides a javacc-based AST, but no binding API
                – Used due to licensing considerations of alternatives


      • Roo offers binding, including parameterization

      • JavaParser does require source code
                – Avoids necessity of having a compiler running
                – Abstractions designed to provide ASM-like *.class
                  introspection should it be desired in the future



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   29
Shell


      • Implementations for STS and JLine

      • Add-ons should
                –      Make a “Command” class and implement CommandMaker
                –      Delegate methods through to an “Operations” object
                –      Annotate methods with @CliCommand
                –      Annotate method parameters with @CliOption
                –      Optionally use @CliAvailabilityIndicator if desired
                –      Throw any exceptions to abort and rollback changes
                –      Use JDK logging or return objects for console output



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   30
Building From Source


      • We develop against a public Subversion repo
                – You can anonymously checkout the code


      • There's also a public FishEye instance (plus Jira)

      • Roo itself uses Maven, so it's very easy to build
                – Standard package, install, assembly and site goal




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   31
Mainline Development


      • Checkout Roo anonymously

      svn co https://anonsvn.springframework.org/svn/spring-roo/
      cd spring-roo/trunk
      less readme.txt


      • readme.txt contains latest setup details
                – Add ROO_CLASSPATH_FILE variable
                – Create symbolic link to bootstrap/roo-dev


      • It works under Windows as well, but not as well

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   32
Classpath File Maintenance


      • Classpath file allows rapid execution of the shell
        without loading Maven to build a full classpath

      • Refreshing the ROO_CLASSPATH_FILE is easy

      cd /home/spring-roo/trunk
      mvn clean eclipse:clean eclipse:eclipse compile


      • Use the “props” shell command to verify classpath
                – Use the above command to update the classpath file



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   33
Development Tips


      • Load Roo using “roo-dev” (not “roo”)
                – Uses incremental builds as per ROO_CLASSPATH_FILE


      • Note roo-dev add-ons will be under ~/roo-dev

      • roo-dev always starts up in “development mode”

      • Debugging is supported via Eclipse/STS
                – Refer to readme.txt for details




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   34
Demo #2




                                                      Setting Up A Fresh Checkout




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   35
Agenda


      •       Architectural Journey
      •       Implementation
      •       Development Mode
      •       Building Add-Ons
      •       Conclusion




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   36
Development Mode


      • Enable via
                – Loading Roo via roo-dev shell script
                – JVM property developmentMode = true
                – Typing “development mode” at the roo> shell prompt


      • Outputs full exception traces within Roo
                – Ugly for normal usage (exceptions are the normal way
                  that an add-ons abort from unexpected conditions)


      • First line of troubleshooting add-on bugs is to
        ask for “development mode” exception data


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   37
Metadata For Type




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   38
Metadata For Id




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   39
Metadata Trace


      • Use --level 1 for instance-specific notifications
      • Use --level 2 for absolutely all notifications

      • Consider the number of notifications involved in
        adding a field to an entity that also has a JSP
                – File system change → physical type metadata → entity
                  metadata → finder metadata → bean info metadata →
                  controller metadata → jsp metadata
                – This doesn't even consider parallel and unchanged
                  paths (eg integration test, getter/setters, menus etc)
                – Metadata beyond type introspection is really useful!


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   40
Demo #3




                                             Development Mode Demonstration




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   41
Agenda


      •       Architectural Journey
      •       Implementation
      •       Development Mode
      •       Building Add-Ons
      •       Conclusion




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   42
Roo's Add-On Model


      • Roo 1.0.0 offers third-party add-on support

      • Very simple single classloader model

      • Add-on ZIPs placed in $ROO_HOME/add-ons
      • JARs auto-extracted into $ROO_HOME/work

      • Launch scripts add $ROO_HOME/work to classpath




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   43
User Add-On Installation


      • “addon install --url file:/some.ZIP”
      • “addon install --url http://www.x.com/s.ZIP”
      • “addon uninstall --pattern some*.zip”

      • Install/uninstall always does a “clean” afterwards

      • “addon clean”
                – Manages $ROO_HOME/work as appropriate
                – Will request to restart shell if any changes are made
                – Deletions are deferred until JVM shuts down


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   44
Add-On ZIP Structure


      • ZIP can be created whatever way you like
                – Although Roo offers a Maven assembly.xml


      • Directories required
                –      “dist” contains 1+ JARs produced by an add-on
                –      “lib” contains 0+ JARs required by the add-on
                –      “lib” contains all transitively-necessary dependencies
                –      Roo does not perform transitive dependency resolution


      • By convention there's a readme and “legal” dir


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   45
Add-On Naming Guidelines


      • Artifact IDs must be
                – Fully qualified (eg com.foo.bar)
                – Start with .com or .net or .org (due to class scanning)
                – End with .roo.addon (due to class scanning)


      • Results in useful ZIP and JAR names like
                – com.my.proj.roo.addon-1.0.0.zip
                – com.my.proj.roo.addon-1.0.0.jar


      • Roo add-on commands enforce the above
                – Plus offer suggestions, so don't worry too much

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   46
Add-On Creation


      • It's seriously this easy:                                                                                    or create a project by hand


      roo> project --topLevelPackage com.my.proj.roo.addon
                   --template ROO_ADDON_SIMPLE

      roo> perform eclipse                                                                      optional, or use mvn directly


      roo> perform assembly


                                                                                                            or use Maven directly




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                                 47
ROO_ADDON_SIMPLE


      • Depends on currently-running Roo version
                – Provides access to full Roo core and all base add-ons


      • Creates Java types for you
                – These are usable types that show key Roo APIs


      • Outputs a valid Maven POM and assembly.xml

      • Also gives you shell scripts for classpath control



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   48
Commands and Operations

                                                                                                                     Static Field
                                                                                                           rego       Options

                  Operations                                              Command
                                                                                                           rego
                                                                                                                     Static Field
                                                                                                                      Options

                                                                                                                                    Shell
                            Roo APIs
                                                                                                                                     API




                                                                          Command                                      Shell
                  Operations
                                                                                                                     Converter


                                                                           Add-On



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                          49
Development-Time Notes


      • roo-dev uses ~/roo-dev as $ROO_HOME
      • roo-dev uses $ROO_ADDON_CLASSPATH_FILE

      • This allows you to incrementally develop in
        Eclipse and not have to make a ZIP every time

      • Set $ROO_ADDON_CLASSPATH_FILE via
                – *nix: “source /your/add-on/setup.env”
                – Windows: “youradd-onsetup.bat”
                – Files automatically updated during “mvn compile”



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   50
Add-On Distribution


      • Suggestions
                – Host ZIPs on your own server or Google Code SVN
                – Commiting to SVN simplifies HTTP distribution


      • Announce via
                – A Tweet including #roo
                – A forum post at http://forum.springsource.org/
                – Email balex@vmware.com with details
                   • I'll add it to the official list of public Roo add-ons


      • A future release will revisit distribution facilities

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   51
Suggested Add-On Steps


      • Learn Roo conventions from a user's perspective

      • Use “project --template ROO_ADDON_SIMPLE”
                – Then “addon install” and try the “welcome” commands
                – Import it into Eclipse, study the code and customize


      • Use Roo SVN to study more advanced add-ons

      • Obtain help via the Spring community forums



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   52
Demo #4




                                                                   Building An Add-On




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   53
Agenda


      •       Architectural Journey
      •       Implementation
      •       Development Mode
      •       Building Add-Ons
      •       Conclusion




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   54
Roo's Design


      • Result of considerable R&D

      • Very lightweight and loosely-coupled core

      • Easy to build from SVN and round-trip develop

      • “Development mode” eases troubleshooting




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   55
A Growing Ecosystem

                                                                                                                                     Other
                 Free-Text
                                                               Reporting                                     Scheduling              Spring
                  Search
                                                                                                                                    projects


                   DTOs/                                      Database                                                              Hundreds
                                                                                                                Captcha
                  Mappers                                    Deployment                                                              More...



                                                                             Roo Distribution



                                          Roo Core                                                                   Base Add-Ons




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                             56
Thanks


      • Hope you've enjoyed our “deep dive” into Roo!

      • Roo community resources
                –      Home → http://www.springsource.org/roo
                –      Support → http://forum.springframework.org
                –      Issues → http://jira.springframework.org/browse/ROO
                –      Tweets → #roo hash key


      • Questions?

                                                                                                                     balex@vmware.com

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                 57

More Related Content

Viewers also liked

Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Oliver Gierke
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDBOliver Gierke
 
Mylyn - Increasing developer productivity
Mylyn - Increasing developer productivityMylyn - Increasing developer productivity
Mylyn - Increasing developer productivityOliver Gierke
 
Generic DAOs With Hades
Generic DAOs With HadesGeneric DAOs With Hades
Generic DAOs With HadesOliver Gierke
 
Increasing developer procutivity with Mylyn (Devoxx 2010)
Increasing developer procutivity with Mylyn (Devoxx 2010)Increasing developer procutivity with Mylyn (Devoxx 2010)
Increasing developer procutivity with Mylyn (Devoxx 2010)Oliver Gierke
 
Whoops! where did my architecture go?
Whoops! where did my architecture go?Whoops! where did my architecture go?
Whoops! where did my architecture go?Oliver Gierke
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDBOliver Gierke
 
REST based web applications with Spring 3
REST based web applications with Spring 3REST based web applications with Spring 3
REST based web applications with Spring 3Oliver Gierke
 
Coding & Music Passion And Profession
Coding & Music   Passion And ProfessionCoding & Music   Passion And Profession
Coding & Music Passion And ProfessionOliver Gierke
 
Real world dependency injection - DPC10
Real world dependency injection - DPC10Real world dependency injection - DPC10
Real world dependency injection - DPC10Stephan Hochdörfer
 
Spring in action - Hades & Spring Roo
Spring in action - Hades & Spring RooSpring in action - Hades & Spring Roo
Spring in action - Hades & Spring RooOliver Gierke
 
Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Oliver Gierke
 
An introduction into Spring Data
An introduction into Spring DataAn introduction into Spring Data
An introduction into Spring DataOliver Gierke
 
Spring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightSpring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightOliver Gierke
 
Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Oliver Gierke
 
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Oliver Gierke
 

Viewers also liked (18)

Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDB
 
Mylyn - Increasing developer productivity
Mylyn - Increasing developer productivityMylyn - Increasing developer productivity
Mylyn - Increasing developer productivity
 
Generic DAOs With Hades
Generic DAOs With HadesGeneric DAOs With Hades
Generic DAOs With Hades
 
Increasing developer procutivity with Mylyn (Devoxx 2010)
Increasing developer procutivity with Mylyn (Devoxx 2010)Increasing developer procutivity with Mylyn (Devoxx 2010)
Increasing developer procutivity with Mylyn (Devoxx 2010)
 
Whoops! where did my architecture go?
Whoops! where did my architecture go?Whoops! where did my architecture go?
Whoops! where did my architecture go?
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDB
 
REST based web applications with Spring 3
REST based web applications with Spring 3REST based web applications with Spring 3
REST based web applications with Spring 3
 
Coding & Music Passion And Profession
Coding & Music   Passion And ProfessionCoding & Music   Passion And Profession
Coding & Music Passion And Profession
 
Real world dependency injection - DPC10
Real world dependency injection - DPC10Real world dependency injection - DPC10
Real world dependency injection - DPC10
 
Mylyn
MylynMylyn
Mylyn
 
Spring in action - Hades & Spring Roo
Spring in action - Hades & Spring RooSpring in action - Hades & Spring Roo
Spring in action - Hades & Spring Roo
 
Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!
 
An introduction into Spring Data
An introduction into Spring DataAn introduction into Spring Data
An introduction into Spring Data
 
Spring integration
Spring integrationSpring integration
Spring integration
 
Spring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightSpring Data JPA - Repositories done right
Spring Data JPA - Repositories done right
 
Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!
 
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
 

Similar to Spring Roo 1.0.0 Technical Deep Dive

Groovy overview, DSLs and ecosystem - Mars JUG - 2010
Groovy overview, DSLs and ecosystem - Mars JUG - 2010Groovy overview, DSLs and ecosystem - Mars JUG - 2010
Groovy overview, DSLs and ecosystem - Mars JUG - 2010Guillaume Laforge
 
2017 03 25 Microsoft Hacks, How to code efficiently
2017 03 25 Microsoft Hacks, How to code efficiently2017 03 25 Microsoft Hacks, How to code efficiently
2017 03 25 Microsoft Hacks, How to code efficientlyBruno Capuano
 
Develop Community-based Android Distribution and Upstreaming Experience
Develop Community-based Android Distribution and Upstreaming Experience Develop Community-based Android Distribution and Upstreaming Experience
Develop Community-based Android Distribution and Upstreaming Experience National Cheng Kung University
 
A Java Implementer's Guide to Boosting Apache Spark Performance by Tim Ellison.
A Java Implementer's Guide to Boosting Apache Spark Performance by Tim Ellison.A Java Implementer's Guide to Boosting Apache Spark Performance by Tim Ellison.
A Java Implementer's Guide to Boosting Apache Spark Performance by Tim Ellison.J On The Beach
 
Java, Ruby & Rails
Java, Ruby & RailsJava, Ruby & Rails
Java, Ruby & RailsPeter Lind
 
Philly Spring UG Roo Overview
Philly Spring UG Roo OverviewPhilly Spring UG Roo Overview
Philly Spring UG Roo Overviewkrimple
 
Server Day 2009: Spring dm Server by Alef Arendsen
Server Day 2009: Spring dm Server by Alef ArendsenServer Day 2009: Spring dm Server by Alef Arendsen
Server Day 2009: Spring dm Server by Alef ArendsenJUG Genova
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repositorynobby
 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept Prakash Poudel
 
Flex For Java Architects Ledroff Breizh Jug V Blog Cc
Flex For Java Architects Ledroff Breizh Jug V Blog CcFlex For Java Architects Ledroff Breizh Jug V Blog Cc
Flex For Java Architects Ledroff Breizh Jug V Blog CcFrançois Le Droff
 
Build Community Android Distribution and Ensure the Quality
Build Community Android Distribution and Ensure the QualityBuild Community Android Distribution and Ensure the Quality
Build Community Android Distribution and Ensure the QualityNational Cheng Kung University
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy Systemadrian_nye
 
Five cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark fasterFive cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark fasterTim Ellison
 

Similar to Spring Roo 1.0.0 Technical Deep Dive (20)

Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
 
Intel open mp
Intel open mpIntel open mp
Intel open mp
 
Practical JRuby
Practical JRubyPractical JRuby
Practical JRuby
 
Groovy overview, DSLs and ecosystem - Mars JUG - 2010
Groovy overview, DSLs and ecosystem - Mars JUG - 2010Groovy overview, DSLs and ecosystem - Mars JUG - 2010
Groovy overview, DSLs and ecosystem - Mars JUG - 2010
 
2017 03 25 Microsoft Hacks, How to code efficiently
2017 03 25 Microsoft Hacks, How to code efficiently2017 03 25 Microsoft Hacks, How to code efficiently
2017 03 25 Microsoft Hacks, How to code efficiently
 
Improve Android System Component Performance
Improve Android System Component PerformanceImprove Android System Component Performance
Improve Android System Component Performance
 
Develop Community-based Android Distribution and Upstreaming Experience
Develop Community-based Android Distribution and Upstreaming Experience Develop Community-based Android Distribution and Upstreaming Experience
Develop Community-based Android Distribution and Upstreaming Experience
 
A Java Implementer's Guide to Boosting Apache Spark Performance by Tim Ellison.
A Java Implementer's Guide to Boosting Apache Spark Performance by Tim Ellison.A Java Implementer's Guide to Boosting Apache Spark Performance by Tim Ellison.
A Java Implementer's Guide to Boosting Apache Spark Performance by Tim Ellison.
 
Java, Ruby & Rails
Java, Ruby & RailsJava, Ruby & Rails
Java, Ruby & Rails
 
Philly Spring UG Roo Overview
Philly Spring UG Roo OverviewPhilly Spring UG Roo Overview
Philly Spring UG Roo Overview
 
Server Day 2009: Spring dm Server by Alef Arendsen
Server Day 2009: Spring dm Server by Alef ArendsenServer Day 2009: Spring dm Server by Alef Arendsen
Server Day 2009: Spring dm Server by Alef Arendsen
 
The Java Content Repository
The Java Content RepositoryThe Java Content Repository
The Java Content Repository
 
Java Programming concept
Java Programming concept Java Programming concept
Java Programming concept
 
Letest
LetestLetest
Letest
 
Flex For Java Architects Ledroff Breizh Jug V Blog Cc
Flex For Java Architects Ledroff Breizh Jug V Blog CcFlex For Java Architects Ledroff Breizh Jug V Blog Cc
Flex For Java Architects Ledroff Breizh Jug V Blog Cc
 
Build Community Android Distribution and Ensure the Quality
Build Community Android Distribution and Ensure the QualityBuild Community Android Distribution and Ensure the Quality
Build Community Android Distribution and Ensure the Quality
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
Java introduction
Java introductionJava introduction
Java introduction
 
Five cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark fasterFive cool ways the JVM can run Apache Spark faster
Five cool ways the JVM can run Apache Spark faster
 
Java 8
Java 8Java 8
Java 8
 

Recently uploaded

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Recently uploaded (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

Spring Roo 1.0.0 Technical Deep Dive

  • 1. Spring Roo 1.0.0: Technical Deep Dive Roo Internals and Add-On Development Ben Alex, Project Lead, Spring Roo Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 2. Agenda • Architectural Journey • Implementation • Development Mode • Building Add-Ons • Conclusion Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 2
  • 3. Agenda • Architectural Journey • Implementation • Development Mode • Building Add-Ons • Conclusion Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 3
  • 4. Design Goals • High productivity for Java developers – Reuse their existing knowledge, skills and experience • Eliminate barriers to adoption – Lock-in, runtime, size, development experience • Embrace the strengths of Java – Dev-time: tooling, popularity, API quality, static typing – Deploy-time: performance, memory use, footprint Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 4
  • 5. High-Impact Decisions • Use Java – This is a tool for Java developers – It defeats the purpose if we insist on a new language • Don't create a runtime – This avoids bugs, lock-in, adoption barriers, approvals – This avoids CPU cost, RAM cost and footprint cost • This easily led to some sort of generation model Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 5
  • 6. Prototyped Approaches • Pluggable Annotation Processing API (JSR 269) • Generate source at build time (XDoclet-style) • Generate bytecode at build time (ASM) • Generate bytecode at runtime (ASM) • Advanced proxy-based approaches (Spring AOP) • IDE plugins • None of them satisfied all of the design goals Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 6
  • 7. Decision 1: Use AspectJ • AspectJ ITDs for “active” generation – Active generation automatically maintains output • Delivers compilation unit separation of concern – Easier for users, and easier for us as developers • Instant IDE support – Reduce time to market and adoption barriers • Other good reasons – Mature, “push in” refactor, compile-time is welcome Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 7
  • 8. ITD Model • Roo owns *_Roo_*.aj files – Will delete them if necessary • Every ITD provider registers a “suffix” it uses – Eg “Entity” becomes *_Roo_Entity.aj – A missing ITD provider causes AJ file removal • ITDs have proper import management – So they look and feel normal to developers – So they “push in refactor” in a natural form Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 8
  • 9. Decision 2: Create A Shell • Need something to host the “active” generation • Need something to receive user commands • Usability issues were of extremely high priority • We chose an interactive shell – Highest usability (tab, context awareness, hiding, hints...) – Background monitoring of externally-made changes – Background monitoring avoided crude “generate” steps Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 9
  • 10. Shell Model • Shell will perform a “startup” scan – To handle changes made while it wasn't running • Shell will monitor file system once started – To handle changes made while it is running • Shell will have a set of commands registered – To handle explicit directives from the user • Roo will never modify a *.java file except at the explicit request of a user via a shell command Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 10
  • 11. That Left One Key Question... Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 11
  • 12. Control Information AspectJ ITDs Person_Roo_ write Roo read Person.java ToString.aj Roo Add-Ons Roo Add-Ons Roo name:String toString():String Add-Ons Add-Ons Person_Roo_ JavaBean.aj read AspectJ read getName():String Compiler setName(String):void Person.class write How will add-ons know name:String toString():String what to generate? getName():String setName(String):void Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 12
  • 13. Metadata • Project details – Project name, dependencies, build system... • Java type details – Fields, methods, constructors, inheritance... • Higher-level concepts – Entity properties, controller paths, validation rules... • Must be automatically determined from project – With @Roo* (source level retention) where infeasible Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
  • 14. Metadata Model • Immutable • String-based keys (start with “MID:”) • Built on demand only (never persisted) • Metadata can depend on other metadata – If “upsteam” metadata changes, “downstream” is told – Some metadata will want to monitor the file system • Central metadata service and cache required Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 14
  • 15. Demo #1 Shell Operation and ITD Maintenance Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15
  • 16. Agenda • Architectural Journey • Implementation • Development Mode • Building Add-Ons • Conclusion Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 16
  • 17. Conventions We Follow • Ensure usability is first-class • Minimize the JAR footprint that Roo requires • Dependencies only from Enterprise Bundle Repo • Relocate runtime needs to sister Spring projects • Embrace immutability as much as possible • Maximize performance in generated code • Minimize memory consumption in generated code • Use long artifact IDs to facilitate identification • Don't put into @Roo* what you could calculate • Don't violate generator predictability conventions Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 17
  • 18. The Roo Distribution • “Roo” is split into two logical components • Base add-ons – org.springframework.roo.addon.* – Provide major out-of-the-box Roo features – Provide metadata for other add-ons • Roo Core – org.springframework.roo.* (excluding .addon.*) – Provide services add-ons will almost always require Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 18
  • 19. 1.0.0 Base Add-Ons • Backup • Logging • Bean Info • Maven • Configurable • Pluralization • Data On Demand • Property Editor • Email • Property File • Entity • Security • Dynamic Finder • Integration Test • Java Bean • ToString • JMS • Web (various) • JPA Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19
  • 20. Role of Third Party Add-Ons • 3rd party add-ons have a long-term role in Roo • Minimize download size of Roo distribution • Avoid licensing issues with Roo distribution • Facilitate features of more niche interest • Separate project management and maintenance • Enable end user customization • Provide a sandbox for easy experimentation Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 20
  • 21. Core Components Classpath Process Manager Project File Undo Shell Model Metadata File Monitor Support (used by all) Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 21
  • 22. File Monitor API • Mostly used by project and classpath modules – Rare for an add-on to directly use file monitor • Publishes startup and “on change” events • Events – Create – Update – Delete – Rename (if implementation supported) – Monitoring start (for each file when first found) Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 22
  • 23. File Monitor Implementation • Polling-based implementation • Auto-scales to reduce CPU overhead • Shell commands – “poll status” → indicates scan frequency and duration – “poll speed” → allows specification of frequency – “poll now” → forces an immediate poll Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 23
  • 24. Metadata Identifiers (MIDs) MID:o.s.r.classpath.PhysicalTypeId#SRC_MAIN_JAVA?com.foo.Bar Static MetadataIdentificationUtils.getMdClass(..) MetadataIdentificationUtils.getMdInstance(..) • Immutable strings to avoid GC cost • Note the “instance” portion denotes a Java type – Most MIDs include this physical location and type name – Use PhysicalTypeIdentifier.getPath(..) and getJavaType(..) to directly extract typesafe objects Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 24
  • 25. Metadata Facilities Metadata Add-On Dependency registers + notifies Registry Metadata Provider queries Metadata Service Metadata Item stores Metadata Cache • MetadataService can provide all metadata in the system • MetadataService auto-evicts all downstream dependencies • Dependency registration can be MID class or MID instance specific Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 25
  • 26. Project Abstraction • Abstracts the user's project build system – Immutable metadata (including dependency details) – Path (eg SRC_MAIN_JAVA) mapping to directories – Operations object to modify project structures – Access to the PathResolver instance • Maven implementation via add-on – Designed to also support Ivy in due course (ROO-91) • Add-ons will regularly use ProjectOperations Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 26
  • 27. Process Manager • Ensures non-overlapping synchronization – Background file monitor polling thread – Shell command foreground thread • Facilitates “atomic” operations with rollback – Notifies disk changes until disk is in stable state – Rolls back disk changes if from a failed shell command • Provides a FileManager abstraction – Add-ons must use this abstraction for disk changes – Reads via FileManager are optional (but recommended) Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 27
  • 28. Classpath API MID:o.s.r.classpath.PhysicalTypeId#SRC_MAIN_JAVA?com.foo.Bar Physical Physical Type Type Identifier Category Physical Physical Type Type Metadata Details ClassOrInterface ItdTypeDetails TypeDetails Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 28
  • 29. Classpath Implementation • JavaParser – Provides a javacc-based AST, but no binding API – Used due to licensing considerations of alternatives • Roo offers binding, including parameterization • JavaParser does require source code – Avoids necessity of having a compiler running – Abstractions designed to provide ASM-like *.class introspection should it be desired in the future Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 29
  • 30. Shell • Implementations for STS and JLine • Add-ons should – Make a “Command” class and implement CommandMaker – Delegate methods through to an “Operations” object – Annotate methods with @CliCommand – Annotate method parameters with @CliOption – Optionally use @CliAvailabilityIndicator if desired – Throw any exceptions to abort and rollback changes – Use JDK logging or return objects for console output Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 30
  • 31. Building From Source • We develop against a public Subversion repo – You can anonymously checkout the code • There's also a public FishEye instance (plus Jira) • Roo itself uses Maven, so it's very easy to build – Standard package, install, assembly and site goal Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 31
  • 32. Mainline Development • Checkout Roo anonymously svn co https://anonsvn.springframework.org/svn/spring-roo/ cd spring-roo/trunk less readme.txt • readme.txt contains latest setup details – Add ROO_CLASSPATH_FILE variable – Create symbolic link to bootstrap/roo-dev • It works under Windows as well, but not as well Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 32
  • 33. Classpath File Maintenance • Classpath file allows rapid execution of the shell without loading Maven to build a full classpath • Refreshing the ROO_CLASSPATH_FILE is easy cd /home/spring-roo/trunk mvn clean eclipse:clean eclipse:eclipse compile • Use the “props” shell command to verify classpath – Use the above command to update the classpath file Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 33
  • 34. Development Tips • Load Roo using “roo-dev” (not “roo”) – Uses incremental builds as per ROO_CLASSPATH_FILE • Note roo-dev add-ons will be under ~/roo-dev • roo-dev always starts up in “development mode” • Debugging is supported via Eclipse/STS – Refer to readme.txt for details Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 34
  • 35. Demo #2 Setting Up A Fresh Checkout Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 35
  • 36. Agenda • Architectural Journey • Implementation • Development Mode • Building Add-Ons • Conclusion Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 36
  • 37. Development Mode • Enable via – Loading Roo via roo-dev shell script – JVM property developmentMode = true – Typing “development mode” at the roo> shell prompt • Outputs full exception traces within Roo – Ugly for normal usage (exceptions are the normal way that an add-ons abort from unexpected conditions) • First line of troubleshooting add-on bugs is to ask for “development mode” exception data Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 37
  • 38. Metadata For Type Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 38
  • 39. Metadata For Id Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 39
  • 40. Metadata Trace • Use --level 1 for instance-specific notifications • Use --level 2 for absolutely all notifications • Consider the number of notifications involved in adding a field to an entity that also has a JSP – File system change → physical type metadata → entity metadata → finder metadata → bean info metadata → controller metadata → jsp metadata – This doesn't even consider parallel and unchanged paths (eg integration test, getter/setters, menus etc) – Metadata beyond type introspection is really useful! Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 40
  • 41. Demo #3 Development Mode Demonstration Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 41
  • 42. Agenda • Architectural Journey • Implementation • Development Mode • Building Add-Ons • Conclusion Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 42
  • 43. Roo's Add-On Model • Roo 1.0.0 offers third-party add-on support • Very simple single classloader model • Add-on ZIPs placed in $ROO_HOME/add-ons • JARs auto-extracted into $ROO_HOME/work • Launch scripts add $ROO_HOME/work to classpath Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 43
  • 44. User Add-On Installation • “addon install --url file:/some.ZIP” • “addon install --url http://www.x.com/s.ZIP” • “addon uninstall --pattern some*.zip” • Install/uninstall always does a “clean” afterwards • “addon clean” – Manages $ROO_HOME/work as appropriate – Will request to restart shell if any changes are made – Deletions are deferred until JVM shuts down Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 44
  • 45. Add-On ZIP Structure • ZIP can be created whatever way you like – Although Roo offers a Maven assembly.xml • Directories required – “dist” contains 1+ JARs produced by an add-on – “lib” contains 0+ JARs required by the add-on – “lib” contains all transitively-necessary dependencies – Roo does not perform transitive dependency resolution • By convention there's a readme and “legal” dir Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 45
  • 46. Add-On Naming Guidelines • Artifact IDs must be – Fully qualified (eg com.foo.bar) – Start with .com or .net or .org (due to class scanning) – End with .roo.addon (due to class scanning) • Results in useful ZIP and JAR names like – com.my.proj.roo.addon-1.0.0.zip – com.my.proj.roo.addon-1.0.0.jar • Roo add-on commands enforce the above – Plus offer suggestions, so don't worry too much Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 46
  • 47. Add-On Creation • It's seriously this easy: or create a project by hand roo> project --topLevelPackage com.my.proj.roo.addon --template ROO_ADDON_SIMPLE roo> perform eclipse optional, or use mvn directly roo> perform assembly or use Maven directly Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 47
  • 48. ROO_ADDON_SIMPLE • Depends on currently-running Roo version – Provides access to full Roo core and all base add-ons • Creates Java types for you – These are usable types that show key Roo APIs • Outputs a valid Maven POM and assembly.xml • Also gives you shell scripts for classpath control Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 48
  • 49. Commands and Operations Static Field rego Options Operations Command rego Static Field Options Shell Roo APIs API Command Shell Operations Converter Add-On Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 49
  • 50. Development-Time Notes • roo-dev uses ~/roo-dev as $ROO_HOME • roo-dev uses $ROO_ADDON_CLASSPATH_FILE • This allows you to incrementally develop in Eclipse and not have to make a ZIP every time • Set $ROO_ADDON_CLASSPATH_FILE via – *nix: “source /your/add-on/setup.env” – Windows: “youradd-onsetup.bat” – Files automatically updated during “mvn compile” Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 50
  • 51. Add-On Distribution • Suggestions – Host ZIPs on your own server or Google Code SVN – Commiting to SVN simplifies HTTP distribution • Announce via – A Tweet including #roo – A forum post at http://forum.springsource.org/ – Email balex@vmware.com with details • I'll add it to the official list of public Roo add-ons • A future release will revisit distribution facilities Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 51
  • 52. Suggested Add-On Steps • Learn Roo conventions from a user's perspective • Use “project --template ROO_ADDON_SIMPLE” – Then “addon install” and try the “welcome” commands – Import it into Eclipse, study the code and customize • Use Roo SVN to study more advanced add-ons • Obtain help via the Spring community forums Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 52
  • 53. Demo #4 Building An Add-On Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 53
  • 54. Agenda • Architectural Journey • Implementation • Development Mode • Building Add-Ons • Conclusion Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 54
  • 55. Roo's Design • Result of considerable R&D • Very lightweight and loosely-coupled core • Easy to build from SVN and round-trip develop • “Development mode” eases troubleshooting Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 55
  • 56. A Growing Ecosystem Other Free-Text Reporting Scheduling Spring Search projects DTOs/ Database Hundreds Captcha Mappers Deployment More... Roo Distribution Roo Core Base Add-Ons Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 56
  • 57. Thanks • Hope you've enjoyed our “deep dive” into Roo! • Roo community resources – Home → http://www.springsource.org/roo – Support → http://forum.springframework.org – Issues → http://jira.springframework.org/browse/ROO – Tweets → #roo hash key • Questions? balex@vmware.com Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 57