Spring Roo 2.0
César Ordiñana & Enrique Ruiz
Spring Roo 2.0 Preview
What is Spring Roo
Current GA release: Spring Roo 1.3.2
What’s new in Spring Roo 2.0
Live demo
What is Spring Roo?
An easy-to-use development tool for quickly building web
applications in the Java programming language
_ _ _ _ _ _ _ _ _ _ _ _
/ _ _  / _ _  / _ _ 
/ / _ / / / / / / / /
/ _ , _ / / _ / / / _ / /
/ _ / | _ |  _ _ _ _ /  _ _ _ _ / 2 . 0 . 0 . M 2
W e l c o m e t o S p r i n g R o o . F o r a s s i s t a n c e p r e s s T A B o r t y p e " h i n t " t h e n h i t E N T E R .
S p r i n g R o o E a s t e r n G r e y U I s t a r t e d a t ' h t t p : / / l o c a l h o s t : 9 1 9 1 / '
r o o >
What Spring Roo is NOT
Spring Roo is not a framework, it is not used in runtime.
Spring Roo engine features
Code generation engine
Programmers code (.java) isolated from generated code
(.aj)
Roo will never overwrite programmers code
Passive and active code generation
Runtime performance not affected by Roo
Why use it?
Higher productivity
Stock-Standard Java and Spring
Bootstraping, maintenance and evolution
Spring Roo 1.x
Applications based on
old technologies
Deprecated
architecture Active
Record
Generated code should
be easier to customize
Extremely simple UI
Basic REST support
Spring Roo 2.0: a new
philosophy
Focused on newer Spring technologies
Create Spring Boot applications
Java-based configuration model
Generate as few code as possible
Easier code customization
Thymeleaf view layer
Demo: New features
Spring IO platform and Boot applications
Global project settings
Conditional command parameters
push-in command
Full support for Spring Data repositories
Improved REST services
New view: Thymeleaf, Bootstrap and JQuery datatables
Create a new project
New > Project > Spring Roo
r o o > p r o j e c t s e t u p - - t o p L e v e l P a c k a g e o r g . s p r i n g i o . t i c k e t
- - p r o j e c t N a m e " S p r i n g I O T i c k e t s " - - j a v a 8 - - p a c k a g i n g J A R
Spring IO and Boot
application
Spring IO and Boot in the pom.xml
Main Boot Application class
Data Access Layer
r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - -
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - d a t a b a s e N a m e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - f o r c e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - h o s t N a m e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - j n d i D a t a S o u r c e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - p a s s w o r d
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - p r o f i l e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - u s e r N a m e
Improved usability
r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - -
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - - f o r c e
j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - - p r o f i l e
r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y
Domain model
Easily create your JPA domain model with the entity jpa
and field add commands.
r o o > e n t i t y j p a - - c l a s s ~ . m o d e l . T i c k e t
~ . m o d e l . T i c k e t r o o > f i e l d s t r i n g - - f i e l d N a m e n a m e
- - c o m m e n t " T h e t i c k e t ' s n a m e " - - n o t N u l l
- - s i z e M i n 5 - - s i z e M a x 2 0
@ M i n ( 1 )
@ M a x ( 1 0 0 0 )
p r i v a t e I n t e g e r q u a n t i t y ;
~ . m o d e l . T i c k e t r o o > f i e l d n u m b e r - - f i e l d N a m e p r i c e
- - t y p e j a v a . l a n g . I n t e g e r
- - c o m m e n t " T h e s e l l i n g p r i c e "
- - m i n 0 - - m a x 1 0 0 0
Tests
Create a unit test
r o o > t e s t u n i t - - c l a s s ~ . m o d e l . T i c k e t
Customize the code
Overwrite Roo generated methods
TicketTest.java
p u b l i c c l a s s T i c k e t T e s t {
p r i v a t e T i c k e t t i c k e t ;
@ B e f o r e p u b l i c v o i d s e t u p ( ) {
t h i s . t i c k e t = n e w T i c k e t ( ) ;
t h i s . t i c k e t . s e t N a m e ( " E a r l y B i r d " ) ;
t h i s . t i c k e t . s e t Q u a n t i t y ( 7 5 ) ;
t h i s . t i c k e t . s e t P r i c e ( 2 1 9 ) ;
t h i s . t i c k e t . s e t I d ( 1 l ) ;
t h i s . t i c k e t . s e t V e r s i o n ( 1 ) ;
}
}
Customize the code (II)
Create your own methods
TicketTest.java
p u b l i c c l a s s T i c k e t T e s t {
@ T e s t
p u b l i c v o i d c h e c k T o S t r i n g C r e a t e s E x p e c t e d V a l u e ( ) {
a s s e r t E q u a l s ( " E a r l y B i r d , 7 5 , 2 1 9 , 1 , 1 " ,
t i c k e t . t o S t r i n g ( ) ) ;
}
}
Customize the code (III)
New command: push-in
r o o > p u s h - i n - - c l a s s ~ . m o d e l . T i c k e t - - m e t h o d t o S t r i n g
Test.java
p u b l i c S t r i n g t o S t r i n g ( ) {
r e t u r n R e f l e c t i o n T o S t r i n g B u i l d e r . t o S t r i n g ( t h i s ,
T o S t r i n g S t y l e . S I M P L E _ S T Y L E ) ;
}
Project settings
Define the project standards and let Roo control them for
you
r o o > s e t t i n g s a d d - - n a m e s p r i n g . r o o . j p a . r e q u i r e . s c h e m a - o b j e c t - n a m e
- - v a l u e t r u e
r o o > e n t i t y j p a - - c l a s s ~ . m o d e l . C u s t o m e r
Y o u m u s t s p e c i f y o p t i o n ' t a b l e ' f o r t h i s c o m m a n d
More domain model
Ticket → Customer
r o o > s c r i p t - - f i l e ~ / E s c r i t o r i o / c u s t o m e r s . r o o
Repository
r o o > r e p o s i t o r y j p a - - e n t i t y ~ . m o d e l . T i c k e t
r o o > r e p o s i t o r y j p a - - a l l - - p a c k a g e ~ . r e p o s i t o r y
Repository queries
r o o > f i n d e r a d d - - c l a s s ~ . m o d e l . T i c k e t
- - n a m e f i n d B y A v a i l a b l e G r e a t e r T h a n A n d N a m e C o n t a i n i n g O r d e r B y N a m e A s c
Service Layer
r o o > s e r v i c e - - e n t i t y ~ . m o d e l . T i c k e t
- - r e p o s i t o r y ~ . m o d e l . T i c k e t R e p o s i t o r y
- - i n t e r f a c e ~ . s e r v i c e . T i c k e t S e r v i c e
r o o > s e r v i c e - - a l l - - a p i P a c k a g e ~ . s e r v i c e . a p i
- - i m p l P a c k a g e ~ . s e r v i c e . i m p l
Your business logic
r o o > p u s h - i n - - c l a s s ~ . s e r v i c e . i m p l . C u s t o m e r S e r v i c e I m p l - - m e t h o d s a v e
CustomerServiceImpl.java
p r i v a t e f i n a l T i c k e t S e r v i c e t i c k e t S e r v i c e ;
@ A u t o w i r e d
p u b l i c C u s t o m e r S e r v i c e I m p l ( C u s t o m e r R e p o s i t o r y c u s t o m e r R e p o s i t o r y ,
T i c k e t S e r v i c e t i c k e t S e r v i c e ) {
t h i s . c u s t o m e r R e p o s i t o r y = c u s t o m e r R e p o s i t o r y ;
t h i s . t i c k e t S e r v i c e = t i c k e t S e r v i c e ;
}
p r i v a t e v o i d u p d a t e T i c k e t Q u a n t i t y ( C u s t o m e r e n t i t y ) {
i f ( e n t i t y . g e t I d ( ) ! = n u l l ) {
T i c k e t t i c k e t = e n t i t y . g e t T i c k e t ( ) ;
t i c k e t . s e t Q u a n t i t y ( t i c k e t . g e t Q u a n t i t y ( ) - 1 ) ;
t i c k e t S e r v i c e . s a v e ( t i c k e t ) ;
}
}
Your business logic (II)
CustomerServiceImpl.java
@ T r a n s a c t i o n a l ( r e a d O n l y = f a l s e )
p u b l i c C u s t o m e r s a v e ( C u s t o m e r e n t i t y ) {
u p d a t e T i c k e t Q u a n t i t y ( e n t i t y ) ;
r e t u r n c u s t o m e r R e p o s i t o r y . s a v e ( e n t i t y ) ;
}
@ T r a n s a c t i o n a l ( r e a d O n l y = f a l s e )
p u b l i c L i s t < C u s t o m e r > s a v e ( I t e r a b l e < C u s t o m e r > e n t i t i e s ) {
f o r ( C u s t o m e r c u s t o m e r : e n t i t i e s ) {
u p d a t e T i c k e t Q u a n t i t y ( c u s t o m e r ) ;
}
r e t u r n c u s t o m e r R e p o s i t o r y . s a v e ( e n t i t i e s ) ;
}
Presentation Layer
You choose:
Control only → REST Services
Control and View → REST Services + Thymeleaf
Adding web support
w e b m v c s e t u p
REST Services
w e b m v c c o n t r o l l e r - - a l l - - p a c k a g e ~ . w e b
Generating the view
w e b m v c v i e w s e t u p - - t y p e T H Y M E L E A F
Customize the views
w e b m v c t e m p l a t e s s e t u p - - t y p e T H Y M E L E A F
Views and handler
methods
w e b m v c c o n t r o l l e r - - a l l - - p a c k a g e ~ . w e b - - r e s p o n s e T y p e T H Y M E L E A F
Powerful code generation
f i e l d s t r i n g - - f i e l d N a m e d e s c r i p t i o n
Roadmap
DTOs code generation
Non-CRUD REST services
Integration layer
Security layer
Auditing of persistent classes
WebJars integration
UI widgets
Questions?
 http://projects.spring.io/spring-roo/
 https://github.com/spring-projects/spring-roo
 http://stackoverflow.com/questions/tagged/spring-roo
 https://twitter.com/SpringRoo
 http://www.disid.com
Roo it!
Create your Boot applications with Spring Roo 2!

More Related Content

PPTX
[RECAP] Blackholes and Wormholes: Understand and Troubleshoot the “Magic” of ...
PDF
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
PDF
From Data to Knowledge
PDF
Metodo de einsten capacidad de transporte
PDF
Pdf check-list-de-llantas compress
PDF
An Introduction to PASETO Tokens
PDF
Josh Griffin - Examples of Work
DOC
11th rep of ese.cmdy .banu
[RECAP] Blackholes and Wormholes: Understand and Troubleshoot the “Magic” of ...
PyData Paris 2015 - Track 3.2 Serge Guelton et Pierrick Brunet
From Data to Knowledge
Metodo de einsten capacidad de transporte
Pdf check-list-de-llantas compress
An Introduction to PASETO Tokens
Josh Griffin - Examples of Work
11th rep of ese.cmdy .banu

What's hot (20)

PDF
PROJECT STORYBOARD: Increasing First Run Parts From 60% to 90%
PDF
Company Profile 2014 (Before Rebranding)
PDF
Robotic Process Automation (RPA)_Harvesting a Competitive Advantage
PPTX
Towards Exemplary Moodle Courses at YSJU
PDF
Google clarified structured data's effect on SEO
PDF
AUDIT TRAIL AND TRACEABLILTY OF PRODUCTS
PDF
Analysis by shloka
PDF
Francis cv 27 05-2013
PDF
Understanding Online Consumer Behavior in Fashion E-commerce by the applicati...
PDF
A Comparative Study of Data Management Maturity Models
PDF
military training
PDF
Accounting Class Project - Creating a Private Placement Memorandum
PPTX
A Comparative Study of Data Management Maturity Models
PPT
How IBM API Management use Informix and NoSQL
PPTX
Why the org_matters_shorter.jzt.2018sept25
PPTX
How Consumers use Digital Technology
PDF
Niles West v Glenbrook South 1984
PDF
estimaing assignment
PPT
Hrm hrp 2012
PDF
MICE in Abu Dhabi
PROJECT STORYBOARD: Increasing First Run Parts From 60% to 90%
Company Profile 2014 (Before Rebranding)
Robotic Process Automation (RPA)_Harvesting a Competitive Advantage
Towards Exemplary Moodle Courses at YSJU
Google clarified structured data's effect on SEO
AUDIT TRAIL AND TRACEABLILTY OF PRODUCTS
Analysis by shloka
Francis cv 27 05-2013
Understanding Online Consumer Behavior in Fashion E-commerce by the applicati...
A Comparative Study of Data Management Maturity Models
military training
Accounting Class Project - Creating a Private Placement Memorandum
A Comparative Study of Data Management Maturity Models
How IBM API Management use Informix and NoSQL
Why the org_matters_shorter.jzt.2018sept25
How Consumers use Digital Technology
Niles West v Glenbrook South 1984
estimaing assignment
Hrm hrp 2012
MICE in Abu Dhabi
Ad

Similar to Spring Roo 2.0 Preview at Spring I/O 2016 (20)

PDF
Breathe life into your designer!
PDF
Piotr Szotkowski about "Ruby smells"
PDF
PyLadies Talk: Learn to love the command line!
PPTX
Design and Fabrication for Motorized Automated Screw Jack
PDF
Meteor - not just for rockstars
PPTX
Newest copy _rockstar solutions
PPTX
eHarmony @ Phoenix Con 2016
PDF
cofaso Presentation
PDF
Testing Fuse Fabric with Pax Exam
PPTX
1-SYSTEM-ANALYSIS-AND-DESIGN-INTRODUCTION.pptx
PDF
Handout - Demonolithing Think Again (Devoxx GR 2025).pdf
PPTX
Creating Modern Metadata Systems with New Relic, Dow Jones [FutureStack16]
PDF
Code GPU with CUDA - Identifying performance limiters
PDF
Meteor WWNRW Intro
ODP
Running Puppet In Stand Alone Mode
PDF
Writing (Meteor) Code With Style
PDF
Customer_Testimonial_IFFCO.pdf
PPS
E xact micro 10 photometer v4
PDF
Taxmann's GST Mini Ready Reckoner | July 2020
PDF
Fast api
Breathe life into your designer!
Piotr Szotkowski about "Ruby smells"
PyLadies Talk: Learn to love the command line!
Design and Fabrication for Motorized Automated Screw Jack
Meteor - not just for rockstars
Newest copy _rockstar solutions
eHarmony @ Phoenix Con 2016
cofaso Presentation
Testing Fuse Fabric with Pax Exam
1-SYSTEM-ANALYSIS-AND-DESIGN-INTRODUCTION.pptx
Handout - Demonolithing Think Again (Devoxx GR 2025).pdf
Creating Modern Metadata Systems with New Relic, Dow Jones [FutureStack16]
Code GPU with CUDA - Identifying performance limiters
Meteor WWNRW Intro
Running Puppet In Stand Alone Mode
Writing (Meteor) Code With Style
Customer_Testimonial_IFFCO.pdf
E xact micro 10 photometer v4
Taxmann's GST Mini Ready Reckoner | July 2020
Fast api
Ad

Recently uploaded (20)

PPTX
Computer Software - Technology and Livelihood Education
PDF
Website Design Services for Small Businesses.pdf
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PDF
CCleaner 6.39.11548 Crack 2025 License Key
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PPTX
GSA Content Generator Crack (2025 Latest)
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
AI Guide for Business Growth - Arna Softech
PDF
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Computer Software - Technology and Livelihood Education
Website Design Services for Small Businesses.pdf
Monitoring Stack: Grafana, Loki & Promtail
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
CCleaner 6.39.11548 Crack 2025 License Key
Oracle Fusion HCM Cloud Demo for Beginners
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
GSA Content Generator Crack (2025 Latest)
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Autodesk AutoCAD Crack Free Download 2025
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
DNT Brochure 2025 – ISV Solutions @ D365
Designing Intelligence for the Shop Floor.pdf
Time Tracking Features That Teams and Organizations Actually Need
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
AI Guide for Business Growth - Arna Softech
Top 10 Software Development Trends to Watch in 2025 🚀.pdf
Wondershare Recoverit Full Crack New Version (Latest 2025)
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access

Spring Roo 2.0 Preview at Spring I/O 2016

  • 1. Spring Roo 2.0 César Ordiñana & Enrique Ruiz
  • 2. Spring Roo 2.0 Preview What is Spring Roo Current GA release: Spring Roo 1.3.2 What’s new in Spring Roo 2.0 Live demo
  • 3. What is Spring Roo? An easy-to-use development tool for quickly building web applications in the Java programming language _ _ _ _ _ _ _ _ _ _ _ _ / _ _ / _ _ / _ _ / / _ / / / / / / / / / _ , _ / / _ / / / _ / / / _ / | _ | _ _ _ _ / _ _ _ _ / 2 . 0 . 0 . M 2 W e l c o m e t o S p r i n g R o o . F o r a s s i s t a n c e p r e s s T A B o r t y p e " h i n t " t h e n h i t E N T E R . S p r i n g R o o E a s t e r n G r e y U I s t a r t e d a t ' h t t p : / / l o c a l h o s t : 9 1 9 1 / ' r o o >
  • 4. What Spring Roo is NOT Spring Roo is not a framework, it is not used in runtime.
  • 5. Spring Roo engine features Code generation engine Programmers code (.java) isolated from generated code (.aj) Roo will never overwrite programmers code Passive and active code generation Runtime performance not affected by Roo
  • 6. Why use it? Higher productivity Stock-Standard Java and Spring Bootstraping, maintenance and evolution
  • 7. Spring Roo 1.x Applications based on old technologies Deprecated architecture Active Record Generated code should be easier to customize Extremely simple UI Basic REST support
  • 8. Spring Roo 2.0: a new philosophy Focused on newer Spring technologies Create Spring Boot applications Java-based configuration model Generate as few code as possible Easier code customization Thymeleaf view layer
  • 9. Demo: New features Spring IO platform and Boot applications Global project settings Conditional command parameters push-in command Full support for Spring Data repositories Improved REST services New view: Thymeleaf, Bootstrap and JQuery datatables
  • 10. Create a new project New > Project > Spring Roo r o o > p r o j e c t s e t u p - - t o p L e v e l P a c k a g e o r g . s p r i n g i o . t i c k e t - - p r o j e c t N a m e " S p r i n g I O T i c k e t s " - - j a v a 8 - - p a c k a g i n g J A R
  • 11. Spring IO and Boot application Spring IO and Boot in the pom.xml Main Boot Application class
  • 12. Data Access Layer r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - d a t a b a s e N a m e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - f o r c e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - h o s t N a m e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - j n d i D a t a S o u r c e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - p a s s w o r d j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - p r o f i l e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e P O S T G R E S - - u s e r N a m e
  • 13. Improved usability r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - - j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - - f o r c e j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y - - p r o f i l e r o o > j p a s e t u p - - p r o v i d e r H I B E R N A T E - - d a t a b a s e H 2 _ I N _ M E M O R Y
  • 14. Domain model Easily create your JPA domain model with the entity jpa and field add commands. r o o > e n t i t y j p a - - c l a s s ~ . m o d e l . T i c k e t ~ . m o d e l . T i c k e t r o o > f i e l d s t r i n g - - f i e l d N a m e n a m e - - c o m m e n t " T h e t i c k e t ' s n a m e " - - n o t N u l l - - s i z e M i n 5 - - s i z e M a x 2 0 @ M i n ( 1 ) @ M a x ( 1 0 0 0 ) p r i v a t e I n t e g e r q u a n t i t y ; ~ . m o d e l . T i c k e t r o o > f i e l d n u m b e r - - f i e l d N a m e p r i c e - - t y p e j a v a . l a n g . I n t e g e r - - c o m m e n t " T h e s e l l i n g p r i c e " - - m i n 0 - - m a x 1 0 0 0
  • 15. Tests Create a unit test r o o > t e s t u n i t - - c l a s s ~ . m o d e l . T i c k e t
  • 16. Customize the code Overwrite Roo generated methods TicketTest.java p u b l i c c l a s s T i c k e t T e s t { p r i v a t e T i c k e t t i c k e t ; @ B e f o r e p u b l i c v o i d s e t u p ( ) { t h i s . t i c k e t = n e w T i c k e t ( ) ; t h i s . t i c k e t . s e t N a m e ( " E a r l y B i r d " ) ; t h i s . t i c k e t . s e t Q u a n t i t y ( 7 5 ) ; t h i s . t i c k e t . s e t P r i c e ( 2 1 9 ) ; t h i s . t i c k e t . s e t I d ( 1 l ) ; t h i s . t i c k e t . s e t V e r s i o n ( 1 ) ; } }
  • 17. Customize the code (II) Create your own methods TicketTest.java p u b l i c c l a s s T i c k e t T e s t { @ T e s t p u b l i c v o i d c h e c k T o S t r i n g C r e a t e s E x p e c t e d V a l u e ( ) { a s s e r t E q u a l s ( " E a r l y B i r d , 7 5 , 2 1 9 , 1 , 1 " , t i c k e t . t o S t r i n g ( ) ) ; } }
  • 18. Customize the code (III) New command: push-in r o o > p u s h - i n - - c l a s s ~ . m o d e l . T i c k e t - - m e t h o d t o S t r i n g Test.java p u b l i c S t r i n g t o S t r i n g ( ) { r e t u r n R e f l e c t i o n T o S t r i n g B u i l d e r . t o S t r i n g ( t h i s , T o S t r i n g S t y l e . S I M P L E _ S T Y L E ) ; }
  • 19. Project settings Define the project standards and let Roo control them for you r o o > s e t t i n g s a d d - - n a m e s p r i n g . r o o . j p a . r e q u i r e . s c h e m a - o b j e c t - n a m e - - v a l u e t r u e r o o > e n t i t y j p a - - c l a s s ~ . m o d e l . C u s t o m e r Y o u m u s t s p e c i f y o p t i o n ' t a b l e ' f o r t h i s c o m m a n d
  • 20. More domain model Ticket → Customer r o o > s c r i p t - - f i l e ~ / E s c r i t o r i o / c u s t o m e r s . r o o
  • 21. Repository r o o > r e p o s i t o r y j p a - - e n t i t y ~ . m o d e l . T i c k e t r o o > r e p o s i t o r y j p a - - a l l - - p a c k a g e ~ . r e p o s i t o r y
  • 22. Repository queries r o o > f i n d e r a d d - - c l a s s ~ . m o d e l . T i c k e t - - n a m e f i n d B y A v a i l a b l e G r e a t e r T h a n A n d N a m e C o n t a i n i n g O r d e r B y N a m e A s c
  • 23. Service Layer r o o > s e r v i c e - - e n t i t y ~ . m o d e l . T i c k e t - - r e p o s i t o r y ~ . m o d e l . T i c k e t R e p o s i t o r y - - i n t e r f a c e ~ . s e r v i c e . T i c k e t S e r v i c e r o o > s e r v i c e - - a l l - - a p i P a c k a g e ~ . s e r v i c e . a p i - - i m p l P a c k a g e ~ . s e r v i c e . i m p l
  • 24. Your business logic r o o > p u s h - i n - - c l a s s ~ . s e r v i c e . i m p l . C u s t o m e r S e r v i c e I m p l - - m e t h o d s a v e CustomerServiceImpl.java p r i v a t e f i n a l T i c k e t S e r v i c e t i c k e t S e r v i c e ; @ A u t o w i r e d p u b l i c C u s t o m e r S e r v i c e I m p l ( C u s t o m e r R e p o s i t o r y c u s t o m e r R e p o s i t o r y , T i c k e t S e r v i c e t i c k e t S e r v i c e ) { t h i s . c u s t o m e r R e p o s i t o r y = c u s t o m e r R e p o s i t o r y ; t h i s . t i c k e t S e r v i c e = t i c k e t S e r v i c e ; } p r i v a t e v o i d u p d a t e T i c k e t Q u a n t i t y ( C u s t o m e r e n t i t y ) { i f ( e n t i t y . g e t I d ( ) ! = n u l l ) { T i c k e t t i c k e t = e n t i t y . g e t T i c k e t ( ) ; t i c k e t . s e t Q u a n t i t y ( t i c k e t . g e t Q u a n t i t y ( ) - 1 ) ; t i c k e t S e r v i c e . s a v e ( t i c k e t ) ; } }
  • 25. Your business logic (II) CustomerServiceImpl.java @ T r a n s a c t i o n a l ( r e a d O n l y = f a l s e ) p u b l i c C u s t o m e r s a v e ( C u s t o m e r e n t i t y ) { u p d a t e T i c k e t Q u a n t i t y ( e n t i t y ) ; r e t u r n c u s t o m e r R e p o s i t o r y . s a v e ( e n t i t y ) ; } @ T r a n s a c t i o n a l ( r e a d O n l y = f a l s e ) p u b l i c L i s t < C u s t o m e r > s a v e ( I t e r a b l e < C u s t o m e r > e n t i t i e s ) { f o r ( C u s t o m e r c u s t o m e r : e n t i t i e s ) { u p d a t e T i c k e t Q u a n t i t y ( c u s t o m e r ) ; } r e t u r n c u s t o m e r R e p o s i t o r y . s a v e ( e n t i t i e s ) ; }
  • 26. Presentation Layer You choose: Control only → REST Services Control and View → REST Services + Thymeleaf
  • 27. Adding web support w e b m v c s e t u p
  • 28. REST Services w e b m v c c o n t r o l l e r - - a l l - - p a c k a g e ~ . w e b
  • 29. Generating the view w e b m v c v i e w s e t u p - - t y p e T H Y M E L E A F
  • 30. Customize the views w e b m v c t e m p l a t e s s e t u p - - t y p e T H Y M E L E A F
  • 31. Views and handler methods w e b m v c c o n t r o l l e r - - a l l - - p a c k a g e ~ . w e b - - r e s p o n s e T y p e T H Y M E L E A F
  • 32. Powerful code generation f i e l d s t r i n g - - f i e l d N a m e d e s c r i p t i o n
  • 33. Roadmap DTOs code generation Non-CRUD REST services Integration layer Security layer Auditing of persistent classes WebJars integration UI widgets
  • 34. Questions?  http://projects.spring.io/spring-roo/  https://github.com/spring-projects/spring-roo  http://stackoverflow.com/questions/tagged/spring-roo  https://twitter.com/SpringRoo  http://www.disid.com
  • 35. Roo it! Create your Boot applications with Spring Roo 2!