SlideShare une entreprise Scribd logo
1  sur  46
Télécharger pour lire hors ligne
Chicago, October 19 - 22,
2010
Hello, RooBot: Writing and Distributing
Your Own Spring Roo Add-Ons
Stefan Schmidt
Agenda
•  Architectural Journey
•  Getting Started with a new Add-on
•  Implementation
•  Roo Shell & OSGi
•  Pointers for Starters
Architectural Journey
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
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
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
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
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
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
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
That Leaves One Key Question…
Control Information
Getting Started with a new
Add-on
Add-on Creator
•  ‘Add-on Creator’ itself is a Roo add-on
•  Quick start for Roo add-on development
•  Currently supports three types of add-ons:
–  Simple Add-on
•  ideal for small additions to project dependencies and/or
configuration
–  Advanced Add-on
•  ideal for starting fully-fledged Spring Roo add-ons
–  Internationalization Extension for MVC scaffolding
•  ideal for offering new language translations for Roo’s
scaffolded Spring MVC admin UI
Add-on Creator
•  Project Maven pom.xml is configured for
–  hosting in SVN repository
–  easy creation of Maven repository
–  automatic generation of PgP signed artifacts
•  Optimized for hosting as Google Code projects
•  Add-ons are compliant with RooBot
–  PgP signed artifacts with public keys
–  Generation of OSGi compliant bundles
–  use of httppgp protocol
New Add-on command (Simple)
•  Three new commands in version 1.1.x of Roo
–  ‘addon create simple’
•  What: Command & Operations support
•  When: Simple add-ons which want to add dependencies and/
or configuration artifacts to project
•  Example:
–  addon create simple --topLevelPackage com.foo.batch
–  optional attributes
»  projectName (can use this to map to Google code project names)
»  description (Meaningful description of add-on)
New Add-on Commands (Advanced)
–  ‘addon create advanced’
•  What: Command, Operations & ITD support
•  When: Full-fledged add-ons which offer new functionality to
project
–  enhancements to existing Java types in project
–  introduction of new Java types (+ ITDs)
•  Example:
–  addon create advanced --topLevelPackage com.foo.batch
–  optional attributes
»  projectName (can use this to map to Google code project names)
»  description (Meaningful description of add-on)
New Add-on command (i18n)
–  ‘addon create i18n’
•  What: extension to the existing ‘web mvc install language’
command
•  Example:
–  addon create i18n --topLevelPackage com.foo.ru --locale
ru --messageBundle <path-to>/messages_ru.properties
–  optional attributes
»  projectName (can use this to map to Google code project names)
»  description (Meaningful description of add-on)
»  flagGraphic* (provide a custom flag icon for UI use)
»  language** (provide a meaningful language name)
* based on the ISO 3166 country code Roo will attempt to download the graphic automatically
** based on the ISO 3166 country code Roo will attempt to determine the language name
automatically
DEMO
i18n add-on
RooBot
•  RooBot is a Vmware hosted service for Roo add-on
registration
•  Register new add-on repository by Email
–  send email to s2-roobot@vmware.com
–  subject line: MUST be URL to OSGi repository definition
•  ie: http://spring-roo-simple-addon.googlecode.com/svn/repo/repository.xml
–  body: currently not used (but you can send greetings to the
Roo team ;-)
–  other interaction forms planned
•  Web front-end,
•  Roo shell command
RooBot requirements
RooBot verifies:
–  the provided repository.xml is a OSGi Repository
–  the resource URI must use the httppgp prefix
•  ie: <resource uri="httppgp://fr-test.googlecode.com/svn/…/>
–  the referenced bundle in the repository has a
corresponding .asc file containing the PgP public key
–  RooBot will retrieve publicly accessible key information (key
owner name, email) from public key server
–  the referenced bundle contains a OSGi compliant
manifest.mf file
RooBot
•  RooBot compliant add-on bundles
–  are registered in a publicly accessible roobot.xml file
•  http://spring-roo-repository.springsource.org/roobot.xml
–  popularity of bundles registered (soon)
•  RooBot Roo Shell client
–  addon list (lists all known add-ons)
•  optional ’--refresh’ attribute
–  addon info --bundleSymbolicName <TAB>
–  addon install --bundleSymbolicName <TAB>
–  PgP trust model integrated
–  addon suggestions for unknown commands
Implementation
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
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
Conventions we follow
•  Ensure usability is first-class
•  Minimize the JAR footprint that Roo requires
•  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
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
Core Components
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)
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
Common Services
•  Services
–  o.s.roo.process.manager.FileManager
•  use file manager for all file system operations in project (offers
automatic undo on exception)
–  o.s.roo.project.PathResolver
•  offers abstraction over common project paths
–  o.s.roo.metadata.MetadataService
•  offers access to Roo metadata
–  bean info metadata for mutators/accessors of target type
–  o.s.roo.project.ProjectMetadata
•  project name, top level package
•  read access to project dependencies, repositories, etc
Common Utils
•  o.s.roo.support.util.Assert
–  similar to Spring’s Assert
•  o.s.roo.support.util.FileCopyUtils
–  useful for copying resources from add-on into project
•  o.s.roo.support.util.TemplateUtils
–  useful for obtaining InputStream of resources in bundle
•  o.s.roo.support.util.XmlUtils
–  hides XML ugliness
•  writeXml methods
•  Xpath abstraction
Source Code Metadata Abstraction
•  o.s.roo.classpath.details.*MetadataBuilder types
–  FieldMetadataBuilder
–  MethodMetadataBuilder
•  most commonly used builder during add-on development
–  ConstructorMedataBuilder
–  AnnotationMetadataBuilder
Roo Shell & OSGi
Roo 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
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
OSGi
•  Roo runs in an OSGi container since version 1.1
–  ideal for Roo’s add-on model
–  developers can install, uninstall, start, and stop different
add-ons dynamically without restarting the Roo shell
–  automatic provisioning of external add-on repositories
–  OSGi provides very good infrastructure for developing
modular, as well as embedded, and service-oriented
applications
–  Roo uses Apache Felix OSGi implementation
OSGi Container & Roo Shell
•  ‘osgi’ commands
–  osgi ps  displays OSGi bundle information & status
–  osgi log  access OSGi container logs
–  osgi scr info  info about a specific component
–  help osgi  help to ~20 osgi commands
•  ‘addon install’ command
–  addon install  high level abstraction for
‘felix shell start httppgp://…’
Development with OSGi
•  Technical implications minimal:
–  use Apache Felix Annotations
•  @Service  offer functionality to other add-ons; must use
interfaces
•  @Component  (required) for OSGi container
•  @Reference  allows injection of services by other bundles
–  Manifests are (auto-)generated by Maven bundle plugin 
•  Reference other Roo bundles or OSGi compliant
dependencies in the add-on pom.xml
Development with OSGi
•  Use activate method for
–  inititalization tasks performed at bundle startup
–  metadata dependency registration
•  Don’t forget deactivate method
// example from JsonMetadataProviderImpl"
protected void activate(ComponentContext context) {"
metadataDependencyRegistry.registerDependency (…);"
addMetadataTrigger(new JavaType(RooJson.class.getName()));"
addMetadataTrigger(new JavaType(”org.springf.roo.addon.entity.RooIdentifier"));"
}"
protected void deactivate(ComponentContext context) {"
metadataDependencyRegistry.deregisterDependency(..);"
removeMetadataTrigger(new JavaType(RooJson.class.getName()));"
}"
DEMO
advanced add-on
Pointers for Starters
Add-on Development Examples
•  Roo 30+ core add-ons provide plenty of examples
addon-create a typical simple add-on with
commands and operations
addon-toString a simple ITD-providing add-on with
trigger annotation
addon-json a ‘classic’ add-on with commands,
operations, ITD & trigger annotation
Spring Roo Sources
•  We develop against a public Git repository
–  You can anonymously checkout the code
–  git clone git://git.springsource.org/roo/roo.git spring-roo
•  Review source code without Git
–  http://git.springsource.org/roo/roo/trees/master
–  https://fisheye.springsource.org/changelog/spring-roo
•  Roo itself uses Maven, so it's very easy to build
–  Standard package, install, assembly and site goal
–  PgP should be installed
–  see readme.txt in Roo master root for details
Other Project Resources
•  Project Bug Tracker (Jira)
–  Contains lots of tips and tricks
–  https://jira.springframework.org/browse/ROO
•  Project Forums
–  http://forum.springsource.org/forumdisplay.php?f=67
•  Roo Documentation
–  http://static.springsource.org/spring-roo/reference/html-
single/index.html
–  Architecture details
–  Usage & conventions
Q&A

Contenu connexe

Tendances

Postgresql 9.0 HA at LOADAYS 2012
Postgresql 9.0 HA at LOADAYS 2012Postgresql 9.0 HA at LOADAYS 2012
Postgresql 9.0 HA at LOADAYS 2012
Julien Pivotto
 

Tendances (20)

Modulesync- How vox pupuli manages 133 modules, Tim Meusel
Modulesync- How vox pupuli manages 133 modules, Tim MeuselModulesync- How vox pupuli manages 133 modules, Tim Meusel
Modulesync- How vox pupuli manages 133 modules, Tim Meusel
 
Git and github fundamental
Git and github fundamentalGit and github fundamental
Git and github fundamental
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
 
Postgresql 9.0 HA at LOADAYS 2012
Postgresql 9.0 HA at LOADAYS 2012Postgresql 9.0 HA at LOADAYS 2012
Postgresql 9.0 HA at LOADAYS 2012
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Git training
Git trainingGit training
Git training
 
The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
 The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
The Latest Status of CE Workgroup Shared Embedded Linux Distribution Project
 
Hacking on WildFly 9
Hacking on WildFly 9Hacking on WildFly 9
Hacking on WildFly 9
 
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
Gianluca Varisco - DevOoops (Increase awareness around DevOps infra security)
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
PASS 24HOP Linux Scripting Tips and Tricks
PASS 24HOP Linux Scripting Tips and TricksPASS 24HOP Linux Scripting Tips and Tricks
PASS 24HOP Linux Scripting Tips and Tricks
 
GIT presentation
GIT presentationGIT presentation
GIT presentation
 
Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2
 
Gabriele Columbro - Maurizio Pillitu - Get your Alfresco project from Zero to...
Gabriele Columbro - Maurizio Pillitu - Get your Alfresco project from Zero to...Gabriele Columbro - Maurizio Pillitu - Get your Alfresco project from Zero to...
Gabriele Columbro - Maurizio Pillitu - Get your Alfresco project from Zero to...
 
Git101
Git101Git101
Git101
 
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
JavaOne 2015 : How I Rediscovered My Coding Mojo by Building an IoT/Robotics ...
 
Testing Automaton - CFSummit 2016
Testing Automaton - CFSummit 2016Testing Automaton - CFSummit 2016
Testing Automaton - CFSummit 2016
 
Moving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco RepositoryMoving Gigantic Files Into and Out of the Alfresco Repository
Moving Gigantic Files Into and Out of the Alfresco Repository
 
Introduction to Drupal 7 - Updating core, themes and modules. applying patches
Introduction to Drupal 7 - Updating core, themes and modules. applying patchesIntroduction to Drupal 7 - Updating core, themes and modules. applying patches
Introduction to Drupal 7 - Updating core, themes and modules. applying patches
 

En vedette

Källkritik Kollakällan Anettekristina
Källkritik Kollakällan AnettekristinaKällkritik Kollakällan Anettekristina
Källkritik Kollakällan Anettekristina
Kristina Alexanderson
 
Innovation Center Process
Innovation Center ProcessInnovation Center Process
Innovation Center Process
Caroline Little
 
Olympic Oval
Olympic OvalOlympic Oval
Olympic Oval
boongee
 
A smarter way to give
A smarter way to giveA smarter way to give
A smarter way to give
MDailey
 

En vedette (20)

Mr. Alan Cowen
Mr. Alan CowenMr. Alan Cowen
Mr. Alan Cowen
 
Källkritik Kollakällan Anettekristina
Källkritik Kollakällan AnettekristinaKällkritik Kollakällan Anettekristina
Källkritik Kollakällan Anettekristina
 
Question four
Question fourQuestion four
Question four
 
kreativitetggm12
kreativitetggm12kreativitetggm12
kreativitetggm12
 
Creative commons 10 år
Creative commons 10 årCreative commons 10 år
Creative commons 10 år
 
Measuring Online Video
Measuring Online VideoMeasuring Online Video
Measuring Online Video
 
BlueBridge Overview
BlueBridge OverviewBlueBridge Overview
BlueBridge Overview
 
Escola l'Univers
Escola l'UniversEscola l'Univers
Escola l'Univers
 
Halloween ghosts 2n
Halloween ghosts 2nHalloween ghosts 2n
Halloween ghosts 2n
 
Innovation Center Process
Innovation Center ProcessInnovation Center Process
Innovation Center Process
 
Olympic Oval
Olympic OvalOlympic Oval
Olympic Oval
 
kritiskt granska vanner
kritiskt granska vannerkritiskt granska vanner
kritiskt granska vanner
 
Arima i Hais
Arima i HaisArima i Hais
Arima i Hais
 
Bauhaus exhibition
Bauhaus exhibitionBauhaus exhibition
Bauhaus exhibition
 
digitalaverktyg-skolan
digitalaverktyg-skolandigitalaverktyg-skolan
digitalaverktyg-skolan
 
InternetiskolanSETT2012
InternetiskolanSETT2012InternetiskolanSETT2012
InternetiskolanSETT2012
 
The twelve press book jan to june 2013
The twelve press book jan to june 2013The twelve press book jan to june 2013
The twelve press book jan to june 2013
 
Cckth
CckthCckth
Cckth
 
Question four
Question fourQuestion four
Question four
 
A smarter way to give
A smarter way to giveA smarter way to give
A smarter way to give
 

Similaire à Spring Roo Add-On Development & Distribution

Similaire à Spring Roo Add-On Development & Distribution (20)

Contributing to OpenStack
Contributing to OpenStackContributing to OpenStack
Contributing to OpenStack
 
Fluo CICD OpenStack Summit
Fluo CICD OpenStack SummitFluo CICD OpenStack Summit
Fluo CICD OpenStack Summit
 
OWASP 2013 APPSEC USA ZAP Hackathon
OWASP 2013 APPSEC USA ZAP HackathonOWASP 2013 APPSEC USA ZAP Hackathon
OWASP 2013 APPSEC USA ZAP Hackathon
 
Managing Open Source Software in the GitHub Era
Managing Open Source Software in the GitHub EraManaging Open Source Software in the GitHub Era
Managing Open Source Software in the GitHub Era
 
OpenStack Documentation Projects and Processes
OpenStack Documentation Projects and ProcessesOpenStack Documentation Projects and Processes
OpenStack Documentation Projects and Processes
 
Tuenti Release Workflow
Tuenti Release WorkflowTuenti Release Workflow
Tuenti Release Workflow
 
Contributing to OpenStack
Contributing to OpenStackContributing to OpenStack
Contributing to OpenStack
 
Solum - OpenStack PaaS / ALM
Solum - OpenStack PaaS / ALMSolum - OpenStack PaaS / ALM
Solum - OpenStack PaaS / ALM
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
Tutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer WorkshopTutorial 1: Your First Science App - Araport Developer Workshop
Tutorial 1: Your First Science App - Araport Developer Workshop
 
Tuenti Release Workflow v1.1
Tuenti Release Workflow v1.1Tuenti Release Workflow v1.1
Tuenti Release Workflow v1.1
 
Apereo OAE - Bootcamp
Apereo OAE - BootcampApereo OAE - Bootcamp
Apereo OAE - Bootcamp
 
VA Smalltalk Update
VA Smalltalk UpdateVA Smalltalk Update
VA Smalltalk Update
 
Versioning for Developers
Versioning for DevelopersVersioning for Developers
Versioning for Developers
 
OWASP 2013 APPSEC USA Talk - OWASP ZAP
OWASP 2013 APPSEC USA Talk - OWASP ZAPOWASP 2013 APPSEC USA Talk - OWASP ZAP
OWASP 2013 APPSEC USA Talk - OWASP ZAP
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
 
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
Alfresco DevCon 2018: SDK 3 Multi Module project using Nexus 3 for releases a...
 
Osrs
OsrsOsrs
Osrs
 
Version Control and Continuous Integration
Version Control and Continuous IntegrationVersion Control and Continuous Integration
Version Control and Continuous Integration
 
Developing for the Atlassian Ecosystem
Developing for the Atlassian EcosystemDeveloping for the Atlassian Ecosystem
Developing for the Atlassian Ecosystem
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Spring Roo Add-On Development & Distribution

  • 1. Chicago, October 19 - 22, 2010 Hello, RooBot: Writing and Distributing Your Own Spring Roo Add-Ons Stefan Schmidt
  • 2. Agenda •  Architectural Journey •  Getting Started with a new Add-on •  Implementation •  Roo Shell & OSGi •  Pointers for Starters
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
  • 11. That Leaves One Key Question…
  • 13. Getting Started with a new Add-on
  • 14. Add-on Creator •  ‘Add-on Creator’ itself is a Roo add-on •  Quick start for Roo add-on development •  Currently supports three types of add-ons: –  Simple Add-on •  ideal for small additions to project dependencies and/or configuration –  Advanced Add-on •  ideal for starting fully-fledged Spring Roo add-ons –  Internationalization Extension for MVC scaffolding •  ideal for offering new language translations for Roo’s scaffolded Spring MVC admin UI
  • 15. Add-on Creator •  Project Maven pom.xml is configured for –  hosting in SVN repository –  easy creation of Maven repository –  automatic generation of PgP signed artifacts •  Optimized for hosting as Google Code projects •  Add-ons are compliant with RooBot –  PgP signed artifacts with public keys –  Generation of OSGi compliant bundles –  use of httppgp protocol
  • 16. New Add-on command (Simple) •  Three new commands in version 1.1.x of Roo –  ‘addon create simple’ •  What: Command & Operations support •  When: Simple add-ons which want to add dependencies and/ or configuration artifacts to project •  Example: –  addon create simple --topLevelPackage com.foo.batch –  optional attributes »  projectName (can use this to map to Google code project names) »  description (Meaningful description of add-on)
  • 17. New Add-on Commands (Advanced) –  ‘addon create advanced’ •  What: Command, Operations & ITD support •  When: Full-fledged add-ons which offer new functionality to project –  enhancements to existing Java types in project –  introduction of new Java types (+ ITDs) •  Example: –  addon create advanced --topLevelPackage com.foo.batch –  optional attributes »  projectName (can use this to map to Google code project names) »  description (Meaningful description of add-on)
  • 18. New Add-on command (i18n) –  ‘addon create i18n’ •  What: extension to the existing ‘web mvc install language’ command •  Example: –  addon create i18n --topLevelPackage com.foo.ru --locale ru --messageBundle <path-to>/messages_ru.properties –  optional attributes »  projectName (can use this to map to Google code project names) »  description (Meaningful description of add-on) »  flagGraphic* (provide a custom flag icon for UI use) »  language** (provide a meaningful language name) * based on the ISO 3166 country code Roo will attempt to download the graphic automatically ** based on the ISO 3166 country code Roo will attempt to determine the language name automatically
  • 20. RooBot •  RooBot is a Vmware hosted service for Roo add-on registration •  Register new add-on repository by Email –  send email to s2-roobot@vmware.com –  subject line: MUST be URL to OSGi repository definition •  ie: http://spring-roo-simple-addon.googlecode.com/svn/repo/repository.xml –  body: currently not used (but you can send greetings to the Roo team ;-) –  other interaction forms planned •  Web front-end, •  Roo shell command
  • 21. RooBot requirements RooBot verifies: –  the provided repository.xml is a OSGi Repository –  the resource URI must use the httppgp prefix •  ie: <resource uri="httppgp://fr-test.googlecode.com/svn/…/> –  the referenced bundle in the repository has a corresponding .asc file containing the PgP public key –  RooBot will retrieve publicly accessible key information (key owner name, email) from public key server –  the referenced bundle contains a OSGi compliant manifest.mf file
  • 22. RooBot •  RooBot compliant add-on bundles –  are registered in a publicly accessible roobot.xml file •  http://spring-roo-repository.springsource.org/roobot.xml –  popularity of bundles registered (soon) •  RooBot Roo Shell client –  addon list (lists all known add-ons) •  optional ’--refresh’ attribute –  addon info --bundleSymbolicName <TAB> –  addon install --bundleSymbolicName <TAB> –  PgP trust model integrated –  addon suggestions for unknown commands
  • 24. 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
  • 25. 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
  • 26. Conventions we follow •  Ensure usability is first-class •  Minimize the JAR footprint that Roo requires •  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
  • 27. 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
  • 29. 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)
  • 30. 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
  • 31. Common Services •  Services –  o.s.roo.process.manager.FileManager •  use file manager for all file system operations in project (offers automatic undo on exception) –  o.s.roo.project.PathResolver •  offers abstraction over common project paths –  o.s.roo.metadata.MetadataService •  offers access to Roo metadata –  bean info metadata for mutators/accessors of target type –  o.s.roo.project.ProjectMetadata •  project name, top level package •  read access to project dependencies, repositories, etc
  • 32. Common Utils •  o.s.roo.support.util.Assert –  similar to Spring’s Assert •  o.s.roo.support.util.FileCopyUtils –  useful for copying resources from add-on into project •  o.s.roo.support.util.TemplateUtils –  useful for obtaining InputStream of resources in bundle •  o.s.roo.support.util.XmlUtils –  hides XML ugliness •  writeXml methods •  Xpath abstraction
  • 33. Source Code Metadata Abstraction •  o.s.roo.classpath.details.*MetadataBuilder types –  FieldMetadataBuilder –  MethodMetadataBuilder •  most commonly used builder during add-on development –  ConstructorMedataBuilder –  AnnotationMetadataBuilder
  • 34. Roo Shell & OSGi
  • 35. Roo 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
  • 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
  • 37. OSGi •  Roo runs in an OSGi container since version 1.1 –  ideal for Roo’s add-on model –  developers can install, uninstall, start, and stop different add-ons dynamically without restarting the Roo shell –  automatic provisioning of external add-on repositories –  OSGi provides very good infrastructure for developing modular, as well as embedded, and service-oriented applications –  Roo uses Apache Felix OSGi implementation
  • 38. OSGi Container & Roo Shell •  ‘osgi’ commands –  osgi ps  displays OSGi bundle information & status –  osgi log  access OSGi container logs –  osgi scr info  info about a specific component –  help osgi  help to ~20 osgi commands •  ‘addon install’ command –  addon install  high level abstraction for ‘felix shell start httppgp://…’
  • 39. Development with OSGi •  Technical implications minimal: –  use Apache Felix Annotations •  @Service  offer functionality to other add-ons; must use interfaces •  @Component  (required) for OSGi container •  @Reference  allows injection of services by other bundles –  Manifests are (auto-)generated by Maven bundle plugin  •  Reference other Roo bundles or OSGi compliant dependencies in the add-on pom.xml
  • 40. Development with OSGi •  Use activate method for –  inititalization tasks performed at bundle startup –  metadata dependency registration •  Don’t forget deactivate method // example from JsonMetadataProviderImpl" protected void activate(ComponentContext context) {" metadataDependencyRegistry.registerDependency (…);" addMetadataTrigger(new JavaType(RooJson.class.getName()));" addMetadataTrigger(new JavaType(”org.springf.roo.addon.entity.RooIdentifier"));" }" protected void deactivate(ComponentContext context) {" metadataDependencyRegistry.deregisterDependency(..);" removeMetadataTrigger(new JavaType(RooJson.class.getName()));" }"
  • 43. Add-on Development Examples •  Roo 30+ core add-ons provide plenty of examples addon-create a typical simple add-on with commands and operations addon-toString a simple ITD-providing add-on with trigger annotation addon-json a ‘classic’ add-on with commands, operations, ITD & trigger annotation
  • 44. Spring Roo Sources •  We develop against a public Git repository –  You can anonymously checkout the code –  git clone git://git.springsource.org/roo/roo.git spring-roo •  Review source code without Git –  http://git.springsource.org/roo/roo/trees/master –  https://fisheye.springsource.org/changelog/spring-roo •  Roo itself uses Maven, so it's very easy to build –  Standard package, install, assembly and site goal –  PgP should be installed –  see readme.txt in Roo master root for details
  • 45. Other Project Resources •  Project Bug Tracker (Jira) –  Contains lots of tips and tricks –  https://jira.springframework.org/browse/ROO •  Project Forums –  http://forum.springsource.org/forumdisplay.php?f=67 •  Roo Documentation –  http://static.springsource.org/spring-roo/reference/html- single/index.html –  Architecture details –  Usage & conventions
  • 46. Q&A