Rapid Development with Spring Roo
Gordon Dickens
April 9, 2010
What is Roo?
Extensible RAD tool for Java
Open Source
Development time only!
No Runtime
Zero memory overhead
Zero deployment footprint
First Roo Hops:
1. Create Project
2. Setup Persistence
3. Set Connection parameters
4. Create Domain
5. Create Controller
6. Scaffold
7. Create Tests
Roo's Mission Statement
"Roo's mission is to:
fundamentally and sustainably
Improve Java Developer Productivity
without compromising
Engineering Integrity and Flexibility"
Roo Uses Best of Breed
Spring 3.x
Spring Security
Spring MVC / Web Flow
JPA/Hibernate
JSP
Log4J
But I don't want to lock in!!!
No Lock-in
Remove Roo in a few minutes
Roo Implementation Overview
Roo Code Generation
Passive generation
Use shell to generate
When its done, its done
Active Generation
Metadata model with @Roo* annotations
Incremental updates to .aj & .jsp files
never java files
Note: "Managed" -vs- "Created"
Project Commands
project
dependency add | remove
backup
Entity
Sets up your domain classes
Config options for class & table:
--abstract
--extends
--table
--identifierField
--identifierType
...
Entity Fields
JPA
--fetch, --column, ...
JSR 303 Validation
--min, --max, ...
Modifiers
--primitive, --transient, ...
Persistence Setup
Provider options:
--provider HIBERNATE | OPENJPA | ECLIPSELINK
--database MYSQL | ORACLE | HYPERSONIC | ...
Configure Database:
database properties list | set | remove
* Switch providers any time with one command!
JUnit Testing
test integration
@RooIntegrationTest
test mock
@MockStaticEntityMethods
Dynamic Finders
Roo writes them for you
Type Safe
Static Methods to Entities
finder list | add
Default:
findMyDomainsByMyField(<datatype> MyField)
findMyDomainsByMyFieldEquals(<datatype> MyField)
findMyDomainsByMyFieldIsNotNull()
findMyDomainsByMyFieldIsNull()
findMyDomainsByMyFieldLike(<datatype> MyField)
findMyDomainsByMyFieldNotEquals(<datatype> MyField)
Adds to Entity:
@RooEntity(finders = { "findStudentsByFirstName" })
Controller
controller scaffold | all | class
- scaffold
* REST controller
* JSP creation and mgmt
- all
* Scaffolds all entities
- class
* stubs an @MVC for manual coding
Recommendations
Don't remove Roo - unless you must
Record application creation as scripts
Defer custom coding until model is correct
Summary
Popular technologies
Easy to learn & use
Builds on Java's strengths
No runtime lockin or deployment footprint
Doesn't get in the way
Actively supported
Open source project
Whats coming in Roo v1.1
Reverse engineering of existing entities
OSGi Compatible infrastructure for Roo & Addons
Custom templates for scaffolding
Custom tags for form elements
- <field: select | input | datetime
GAE & GWT support
roo> project --topLevelPackage com.chariot.roster
~.domain.Student roo> field string --fieldName firstName
Using the Shell
Start typing - press TAB
Stuck?
At any time type: "hint" or "help"
com.chariot.roster roo> persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY
com.chariot.roster roo> database properties set --key database.url --value jdbc:mysql://localhost:3306/rooroster
com.chariot.roster roo> database properties set --key database.username --value root
com.chariot.roster roo> database properties set --key database.password --value password
com.chariot.roster roo> entity --class ~.domain.Student
Roo goodness for Entities
Annotations:
@RooEntity
@Entity (JPA)
Fields:
id
version
Methods:
count
findAll
findById
findEntries
persist
remove
merge
flush
toString
EntityManager
no-arg constructor
test integration --entity com.chariot.roster.domain.Student
Generates infrastructure
Manages Roo Artifacts
Spring Best Practices
RESTful
Spring MVC / Web Flow
Or
And
Not
Like
Ilike
IsNull
Equals
Between
LessThan
NotEquals
LessThanEquals
IsNotNull
GreaterThan
GreaterThanEquals
Member
roo> finder add --finderName findStudentsByFirstNameAndLastNameIlike --class ~.domain.Student
How can it help me? Why should I use it?
Maven
AspectJ
Eclipse/STS
my new little friend
say hello
"Very Nice...
Great Success"
* Persistence * JMS *SMTP *Security
* Integration Tests * Selenium Tests
DEMO Time!
YAY!!!
Contacts Info
gdickens@chariotsolutions.com
twitter.com/gdickens
linkedin.com/in/gordondickens
www.gordondickens.com
techcast.chariotsolutions.com
Interviews with industry leaders in new technology
Weekly news casts
ETECommunity Site:
phillyemergingtech.ning.comMore presentations by
Introduction to Grails
Gordon Dickens on
Introduction to Groovy on Grails - Created for Harrisburg Java Users Group 18-Mar-10