You are on page 1of 61

A division of

Introducing Spring Roo

Extreme Productivity in 10 Minutes

Eberhard Wolff
Principal Technologist
SpringSource – A division of VMware

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
About me
A division of

•  Eberhard Wolff
•  Principal Technologist
•  i.e. I work on the Service Delivery product
roadmap
•  …and do consulting / training engagements
•  Author of many articles and the first German
Spring book

•  ewolff@vmware.com
•  Blog: http://jandiandme.blogspot.com
•  Twitter: @ewolff

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 2
About SpringSource
A division of

Unifying the Application Lifecycle:


from Developer to Datacenter

Spring Enterprise SpringSource tc Server


Groovy and Grails SpringSource dm Server
SpringSource Tool Suite SpringSource ERS

SpringSource Hyperic HQ
SpringSource Hyperic IQ
SpringSource Hyperic CloudStatus
Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 3
SpringSource – A division of VMware
A division of

"   Efficiency

"   Control Modern


Application
Virtualized
Infrastructure
Platform Platform

"   Flexibility

Developer to
Datacenter to Cloud

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

•  Introducing Roo
•  Capability Areas
•  Using Roo
•  Roadmap and Resources
•  A Closer Look: Spring Insight
•  Let's Get Cloudy: Cloud Foundry

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

•  Introducing Roo
•  Capability Areas
•  Using Roo
•  Roadmap and Resources
•  A Closer Look: Spring Insight
•  Let's Get Cloudy: Cloud Foundry

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 6
Mission Statement
A division of

“Roo's mission is to
fundamentally and sustainably
improve Java developer
productivity without
compromising engineering
integrity or flexibility”

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 7
End User's Description
A division of

•  “Roo is a little genie who sits


in the background and
handles the things I don't
want to worry about”

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 8
What Is Roo?
A division of

•  Roo is an extensible, text-based RAD tool for Java

•  Roo is development-time only (no Roo runtime)

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 9
Implementation Overview
A division of

Roo Infrastructure

Roo STS
Roo
provide Roo
Add-Ons
@Roo Roo
Add-Ons
Add-Ons
Annotations Add-Ons
Shell

source only monitor and


retention change

User's Project

.aj .java .xml .jsp .properties

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 10
Familiar Libraries
A division of

•  Roo builds on what you already know


–  Popular, proven, and mature APIs at your full disposal

•  Java
•  Spring Framework
•  Java Persistence API (Hibernate)
•  Java Server Pages
•  Spring Security
•  Spring Web Flow
•  Log4J, Maven, AspectJ, Eclipse/STS...

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 11
Uses Java's Strengths
A division of

•  The world's most popular language (Tiobe)


–  Skills availability, vendor choice, low risks, open source

•  APIs are popular, standardised, safe, proven

•  Quality, mature and deep tooling integration


–  IDE code assist, debuggers, refactoring, profilers etc

•  Static typing
–  Fewer errors, robust refactoring, code assist, JVM design

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 12
Cloud-Class Scalability
A division of

•  Zero performance overhead


–  Efficient, reflection-free code
–  No dynamic proxies, deferred compiling, LTW or similar
–  No Roo runtime means no runtime performance cost

•  Zero memory overhead


–  No class creation means no Perm Gen memory issues
–  No Roo runtime means no runtime memory cost

•  Zero deployment footprint


–  Roo apps leverage OSGi bundles out-of-the-box
–  No Roo runtime means no WAR footprint size

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
More Great Stuff
A division of

•  No lock-in
–  Get rid of Roo from your project in under 10 minutes!

•  Easy to write and deploy your own Roo add-ons


–  Roo can even write them for you (seriously!)

•  Open source and SpringSource maintained


–  SpringSource-endorsed application architecture

•  Consistent apps across your team and enterprise

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 14
Code Generation Approach
A division of

•  Roo is a hybrid code generator


–  The best of the passive and active generation models
–  Achieved by use case-specific design decisions

•  Passive generation
–  Use Roo shell to make Roo generate something
–  It's done and it's finished (usually .xml and .java files)

•  Active generation (automatic round-tripping)


–  Builds detailed metadata model with help of @Roo*
–  Incrementally updates .aj, .jsp files - never .java files

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15
Active Generation
A division of

AspectJ ITDs

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

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

Person.class

write
Compilation unit separation name:String
toString():String
with automated round-trips getName():String
setName(String):void

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 16
Demo
A division of

The Roo Tour:

A Web App Without Reading The Manual

(or blogs, web sites, samples, pre-written code or similar)

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

•  Introducing Roo
•  Capability Areas
•  Using Roo
•  Roadmap and Resources
•  A Closer Look: Spring Insight
•  Let's Get Cloudy: Cloud Foundry

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 18
Out Of The Box
A division of

•  Project management
•  General object services
•  Entity support
•  Field management
•  Persistence
•  JUnit testing
•  Dynamic finders
•  Spring MVC, Spring Web Flow and Selenium
•  JMS, SMTP and build system integration
•  Spring Security, Logging Setup.....

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19
Project Management
A division of

•  Commands
–  “project” → creates new project in current dir
–  “dependency add” → adds dependency to POM
–  “dependency remove” → opposite of add
–  “backup” → creates ZIP of project

•  All dependencies use Enterprise Bundle Repo


–  Versioned, quality-checked, OSGi-compatible JARs

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 20
General Objects
A division of

•  Roo annotations suitable for any class


–  @RooJavaBean – getters and setters for free
–  @RooConfigurable – adds Spring @Configurable
–  @RooToString – you guessed it

•  Roo will automatically maintain the code for you

•  Roo won't get in your way


–  It just sits in the background and writes code you don't
–  You don't have to “tell” it to stop doing something
–  You don't have to use the Roo shell (any editor will do)

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 21
Entity Support
A division of

•  “entity” → creates an @RooEntity


–  Delivers a flexible, feature-rich JPA entity
–  Declares a JPA @Entity with id, version, EntityManager
and a no-arg constructor
–  Automatically adds count, findAll, findById, findEntries,
persist, remove, merge and flush methods to an entity

•  Command accepts many optional directives


–  Whether to build an automatic integration test
–  Table name, identifier column name etc

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 22
Field Management
A division of

•  “field” commands for most major field types

•  Field commands have options for


–  JPA-specific annotations (--fetch, --column etc)
–  JavaBean valiation-specific annotations (--max etc)
–  Java modifiers (--primitive, --transient etc)

•  Shell remembers last entity you worked with


–  Fields are automatically added to that entity
–  Override using --class

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 23
Persistence
A division of

•  “persistence setup”
–  Use --provider for Hibernate, OpenJPA and EclipseLink
–  Use --database for most common databases
•  Related commands
–  “persistence exception translation” → via AspectJ
–  “database properties list” → lists JDBC props
–  “database properties set” → changes JDBC prop
–  “database properties remove” → deletes JDBC prop
•  You can re-run “persistence setup” at any time
–  Switch from Hibernate to OpenJPA in one line!

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 24
JUnit Testing
A division of

•  “test integration” → JUnit integration test


–  Automatic “data on demand” feature for seed data
–  This is implied with “entity --testAutomatically”

•  “test mock” → JUnit mock test


–  Allows test mocking of static methods in your entities

•  “dod” → creates a data on demand class


–  Rarely used directly
–  Automatically created if tests require it

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 25
Dynamic Finders
A division of

•  Saves you having to write JPA QL finders


–  Roo will write them for you, complete with type safety!

•  Finders are added as static methods to entities


–  They're even compatible with abstract entities
–  “finder list” → shows all available finders
–  “finder add” → enable a specific finder

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 26
Easy Spring Web MVC
A division of

•  “controller scaffold” → an automatic controller


–  Automatic REST controller for a given entity
–  Automatic JSP creation and maintenance
–  Can fine-tune allowed methods (CRUD subset)
–  Permits date format to be specified

•  “controller all” → automatically scaffold all


entities

•  “controller class” → stub a manual controller


–  Just the controller – you write the rest

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 27
Web Stack
A division of

•  Automatic Spring JS, Tiles and URL Rewrite

•  “selenium test” → Test a scaffolded controller


–  Start Tomcat with “mvn tomcat:run”
–  Then run the test with “mvn selenium:selenese”

•  “webflow” → Create a flow with Spring Web Flow

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 28
Messaging: SMTP and JMS
A division of

•  “email sender setup” → setup SMTP sender

•  “field email” → adds an email sender field

•  “jms setup” → sets up JMS support


–  Optionally embeds a TCP-accessible ActiveMQ instance

•  “field jms template” → adds a JMS sender field

•  “jms listener class” → makes a JMS receiver

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 29
Build System Integration
A division of

•  Assorted build options


–  “perform clean” → runs “mvn clean eclipse:clean”
–  “perform eclipse” → runs “mvn eclipse:eclipse” (no m2eclipse)
–  “perform tests” → runs “mvn test”
–  “perform package” → runs “mvn package”
–  “perform command” → custom mvn command
•  You must have Maven setup and in path to use
•  Often used at end of “script” files
–  Verifies success
–  Brings project into Eclipse for further work

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 30
Miscellaneous
A division of

•  “security setup” → sets up Spring Security

•  “logging setup” → sets up Log4J configuration

•  “script” → executes a script


–  Specify clinic.roo, wedding.roo, vote.roo and
bundlor.roo for inbuilt sample applications
–  Specify a fully-qualified file system path for your files

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

•  Introducing Roo
•  Capability Areas
•  Using Roo
•  Roadmap and Resources
•  A Closer Look: Spring Insight
•  Let's Get Cloudy: Cloud Foundry

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 32
Requirements
A division of

•  Java 5
–  Same as Spring 3

•  Maven 2.0.9 or above


–  Roo itself doesn't need Maven installed to work
–  Maven is only needed for Roo-generated projects
–  ROO-91 requests Ant/Ivy → vote if you'd like it!

•  Tested with Linux, Windows and Apple


–  All platforms support tab completion and a colour shell

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 33
Download and Easy Install
A division of

•  Download Roo from www.springsource.org/roo


–  Simply unzip and add to your path

•  Linux/Apple users would use something like:


–  sudo ln -s $HOME/spring-roo-1.0.1.RELEASE/bin/
roo.sh /usr/bin/roo
•  Windows
–  Add %HOME%/spring-roo-1.0.1.RELEASE/bin to PATH

•  A public Subversion repository is also available


–  See readme.txt in root of checkout for dev installation

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 34
IDE Interoperability
A division of

•  We highly recommend SpringSource Tool Suite


–  Download it from www.springsource.com
–  Totally free to use
–  Includes Roo integration (eg CTRL+R commands)
–  Also pre-bundles AJDT, m2eclipse and other plugins
•  Eclipse also works, but use the latest AJDT
–  Eclipse does not provide STS' Roo integration
–  Roo can still be used concurrently via the shell

•  Roo also happily lives alongside emacs, vim,


notepad, and no IDE at all

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 35
Lifecycle Notes
A division of

•  SpringSource Tool Suite


–  Use the embedded Roo option

•  Any other case


–  Load Roo at the same time as your IDE or text editor
–  Roo automatically detects changes made outside Roo

•  No need to add Roo to your build system


–  Although “roo quit” will run Roo, update files and exit

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 36
Upgrade Actions
A division of

•  When you upgrade Roo, .aj files may change


–  This is a feature of active code generation
–  We make optimizations and enhancements in .aj files

•  Please refrain from editing Roo's .aj files


–  Roo “owns” the *_Roo_*.aj files
–  You can freely edit any file in your project except these

•  Just “push-in refactor” any .aj files you wish to edit

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 37
Removing Roo in Three Steps
A division of

1. Use AJDT's “push-in refactoring” feature


–  This moves the Roo .aj content into normal .java files
2. Remove Roo's annotation JAR from your POM
–  You can use Roo's “dependency remove” command
3. Remove @Roo* annotations from .java files
–  Use a regular exp find/replace in Eclipse for speed

•  You can still use Roo on the project again


–  Its “hands off by default” will ensure it's problem-free

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 38
Add-On Services
A division of

•  Third parties can easily publish new add-ons


–  See the addon.roo script

•  “addon list” → lists add-ons presently installed


•  “addon install” → downloads and installs add-on
•  “addon uninstall” → removes an add-on
•  “addon cleanup” → refreshes the environment

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 39
Recommendations
A division of

•  Use SpringSource Tool Suite


•  Don't remove Roo from your projects
–  You'll have much code to now manage by hand again
–  You'll miss out on automatic upgrade improvements
–  Consider removal as your insurance against lock-in
•  Record your jump-start applications as scripts
–  It's now so quick to change your design, so enjoy it!
–  Defer custom coding until your model seems correct
•  Ask questions on the forum for fast support

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

•  Introducing Roo
•  Capability Areas
•  Using Roo
•  Roadmap and Resources
•  A Closer Look: Spring Insight
•  Let's Get Cloudy: Cloud Foundry

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 41
Present Release
A division of

•  Spring Roo 1.0.2.RELEASE

•  Released 21 February 2010

•  11 releases in 11 months = extensive feedback

•  Plenty of documentation and tutorials included

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 42
Project Resources
A division of

•  Home → http://www.springsource.org/roo
–  Contains links to all other resources

•  Forum → http://forum.springsource.org
–  Roo team actively monitor forum and answer queries

•  Issues → http://jira.springframework.org/browse/ROO

•  Twitter → #roo hash key

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

•  Introducing Roo
•  Capability Areas
•  Using Roo
•  Roadmap and Resources
•  A Closer Look: Spring Insight
•  Let's Get Cloudy: Cloud Foundry

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 44
Spring Insight
A division of

•  Complete visibility in the performance for each


request

•  All layers:
Spring Beans (Services, Repositories)
Transactions
JDBC / SQL statements

•  Just deploy the application


•  and go to http://localhost:8080/insight

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 45
Spring Insight
A division of

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 46
A division of

Let's try it on our project!

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

•  Introducing Roo
•  Capability Areas
•  Using Roo
•  Roadmap and Resources
•  A Closer Look: Spring Insight
•  Let's Get Cloudy: Cloud Foundry

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 48
Cloud Foundry
A division of

•  Deploy Spring, Grails and Java applications to a


scalable, managed cloud environment in
minutes
•  No platform or technology lock-in
•  Rapidly deliver business applications without
operations bottlenecks
Productive and familiar development experience
Integrated monitoring and management for applications
and web infrastructure
•  Automatic scaling and infrastructure repair
•  Pay-as-you-go pricing; consumption-based
metering
Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 49
Cloud Foundry䈊
Spring & Grails Applications in the
Cloud A division of

STS

AWS
Spring
tc Server
API Apache
Developers Hyperic
MySQL

Request

QA

User
IT

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 50
Enterprise Java Cloud
Requirements A division of

•  Self-Service
Easy access to Java platform/infrastructure services
Automation of common deployment blueprints
Integrated development & app management experience

•  On-Demand Capacity
Rapid setup, configuration, and tear down of complex
systems on demand
Intelligent provisioning of Java stack

•  SLA-Driven Resource Allocation


Inherently manageable applications & infrastructure
Ex. Elastic middleware driven by application SLAs

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 51
Cloud Foundry Developer
Preview A division of

•  Cloud infrastructure on Amazon Web Services


Will support VMware virtualization/cloud platforms in
future

•  Engage Spring and Grails community in


feedback loop as we build out cloud capabilities

•  Platform includes Apache, tc Server (Tomcat),


MySQL, Hyperic, and Cloud Tools technologies

•  Free to use; no uplift on standard Amazon


charges
Pricing to follow standard cloud service pricing models

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 52
Conclusion
A division of

•  Roo delivers serious productivity gains for Java


–  Popular, proven technologies you already know
–  Easy to learn and easy to use
–  Builds on Java's strengths
–  Extreme performance
–  No runtime, no lock-in, no risk
–  An active, supported, open source project
•  Spring Insight gives you performance
information
•  Cloud Foundry allows you to use the Cloud now!

•  Questions?
Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 53
Learn more at the S2G Forum!
A division of
•  S2G Forum München 18.3. •  1st class speaker:
Jürgen Höller
•  3 Tracks:
Spring
(Spring Lead)
Groovy/Grails Graeme Rocher
Enterprise Production Systems (Grails Lead)
•  95! incl. food Guillaume LaForge
(Groovy Lead)
•  http://
www.springsource.com/ Christian Dupuis
events/s2gforum-3-18-2010 (SpringSource Tool
Suite Lead)

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 54
A division of

•  S2G Forum March 18th:


http://www.springsource.com/events/
s2gforum-3-18-2010

•  Blog: http://JandIandMe.blogspot.com
•  Twitter: @ewolff
•  ewolff@vmware.com

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

Cloud Foundry Screenshot Demo

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 57
Home Screen
A division of

Start
If issues are here
present

General AWS News


User’s events
health feed

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 58
Upload Application
A division of

Static content
deployed on
Apache
WAR file
(multiple
WARs and
contexts
supported)

Database
configuration
and DDL scripts

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 59
Applications Screen
A division of

•  List of previously uploaded applications


•  Actions: Upload, View/Edit, Launch, and Delete

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 60
Launch Application
A division of

Selected topology is
graphically illustrated

Select
topology

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 61
Deployments Screen
A division of

•  List of current and previous deployments


•  Actions: Launch New Deployment, View, Show Log

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