Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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...
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 nev...
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 easie...
Spring Roo 2.0: a new
philosophy
Focused on newer Spring technologies
Create Spring Boot applications
Java-based configura...
Demo: New features
Spring IO platform and Boot applications
Global project settings
Conditional command parameters
push-in...
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 . ...
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 ...
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...
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 - -...
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...
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 ...
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 ...
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...
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...
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...
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 ...
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 ...
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 ...
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 ...
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
WebJar...
Questions?
 http://projects.spring.io/spring-roo/
 https://github.com/spring-projects/spring-roo
 http://stackoverflow....
Roo it!
Create your Boot applications with Spring Roo 2!
Upcoming SlideShare
Loading in …5
×

Spring Roo 2.0 Preview at Spring I/O 2016

1,161 views

Published on

In this talk we are going to present a preview of Spring Roo 2.0, a rewrite of the code generating tool for the development of Java web applications based on current Spring technologies like Spring Boot, Spring Data, etc.

Published in: Software
  • Be the first to comment

Spring Roo 2.0 Preview at Spring I/O 2016

  1. 1. Spring Roo 2.0 César Ordiñana & Enrique Ruiz
  2. 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. 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. 4. What Spring Roo is NOT Spring Roo is not a framework, it is not used in runtime.
  5. 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. 6. Why use it? Higher productivity Stock-Standard Java and Spring Bootstraping, maintenance and evolution
  7. 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. 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. 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. 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. 11. Spring IO and Boot application Spring IO and Boot in the pom.xml Main Boot Application class
  12. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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. 26. Presentation Layer You choose: Control only → REST Services Control and View → REST Services + Thymeleaf
  27. 27. Adding web support w e b m v c s e t u p
  28. 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. 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. 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. 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. 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. 33. Roadmap DTOs code generation Non-CRUD REST services Integration layer Security layer Auditing of persistent classes WebJars integration UI widgets
  34. 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. 35. Roo it! Create your Boot applications with Spring Roo 2!

×