By Graeme RocherRoad to Grails 3.0
Agenda
§ State of Nation
§ What’s new in Grails 2.3?
§ What’s planned for Grails 2.4?
§ What’s planned for Grails 3.0?...
State of Nation
§ Grails 2.3.7 most recent version
§ One release per month
§ Hundreds of bugs fixed in the last 3
month...
What’s new in Grails 2.3?
• Forked Execution and Test Daemon
• Dependency Resolution with Aether
• Complete Server-Side RE...
What’s new in Grails 2.3?
• XSS Prevention
• Hibernate 4 Support (via Plugin)
• RESTful Scaffolding v2.0
• Controller Name...
Aether & Dependency Management
• Aether == Same dependency
resolution engine as Maven
– No snapshot troubles
– Same local ...
REST: URL Mappings
• RESTful Mappings
– Single or Multiple resources
– Versioning
– Nested resources
• New url-mappings-re...
REST: @Resource Transformation
• Automatically exposes a
domain class as a REST
resource
• Configurable formats
• Configur...
REST: The respond method
• Sends the most
appropriate response for
the given object
• For HTML calculates a
model by conve...
REST: HAL, JSON, XML Renderers
• Rendering customizable
in resources.groovy
• HAL, Atom, Vnd.Error
renders included
• Flex...
REST: Scaffolding 2.0
• Scaffolding support now a plugin
– http://grails.org/plugin/scaffolding
• Generated controllers no...
REST: Misc Goodies
• grails.rest.RestfulController
– Controller base class for inheriting RESTful actions
• The respond me...
Async: Promise Primitives
• Foundational API for Async
programming
• Includes notion of Promise
• Ability to combine / cha...
Async: @DelegateAsync Transform
• Transform any synchronous
API into an asynchronous
one
• Takes each method and
returns a...
Async: GORM
• Makes all GORM methods
async
• Deals with binding session
to background thread
• Works across all
datastores...
Async: Request Processing
• Handle requests
asynchronously
• Uses Servlet 3.0 async
under the covers
• Create asynchronous...
Data Binder: @BindingFormat
• Per property formatting
• Extensible
!17
!
class	
  Person	
  {	
  
	
  @BindingFormat('MMdd...
Data Binder: @BindUsing
• For cases where more
flexibility is needed
• Can be applied to class 

or property
• Takes a clo...
Data Binding: XML/JSON Command Objects
• Can now bind XML/JSON
data to command objects
• Binding can be customized
using t...
Data Binding: Auto Query if Domain Object
• If command object is a
domain class query on id
• Passes null if domain class
...
XSS Prevention
• All GSP expressions and scriptlets now escaped by
default
• Double-encoding prevention
• New raw method t...
Other Goodies: Hibernate 4 Support
• Hibernate 3 and 4 binary incompatible, so new plugin
• Not all plugins that work with...
Other Goodies: @Transactional Transform
• Can be applied to any class
• No proxies required!
• Replacement for Spring’s
@T...
Other Goodies: @DirtyCheck Transform
• Can be applied to any class
to add dirty checking
• Tracks calls to setters that
mo...
Other Goodies: Action Error Handlers
• Actions that define an exception as the first argument get
invoked if the exception...
Other Goodies: Controller Namespaces
• Controllers can now define a namespace
• URL Mappings can map to a specific namespa...
!
Q & A
Grails 2.3
2.3
!
The Future
Grails 2.4
2.4
Grails 2.4: Goals
• Spring 4.0 Upgrade
• Java 8 Support
• Groovy 2.3 Upgrade
• Improved @CompileStatic Support
• Asset Pip...
Spring 4.0
• Native GroovyBeanDefinitionReader
(ported from BeanBuilder)
– https://spring.io/blog/2014/03/03/groovy-
bean-...
Groovy 2.3
• Traits
• Java 8
• Implicit closure coercion
• Lots more!
• http://groovy.codehaus.org/
Roadmap
!31
Asset Pipeline Plugin
• Resources replaced with Asset
Pipeline
– https://github.com/bertramdev/asset-
pipeline/wiki/Why-as...
Modularization
!33
grails-web
grails-web-mvc
grails-web-sitemesh
grails-web-gsp grails-web-jsp
grails-web-servlet
grails-w...
Standalone
• GORM for Hibernate 4 in Spring Boot
– https://gist.github.com/graemerocher/d31648899fdb461609fb
• GORM for Mo...
!
The Future
Grails 3.0
3.0
Grails 3.0: Goals
• Embrace Gradle
• Abstract Packaging / Deployment
• Reach outside the Servlet Container
• App Profiles:...
Grails 3.0: Goals
• Plugin Model / Event Driven
• Support Multi Project Builds
• Support Micro Services
• Remove Bloat
• R...
Grails 3.0: Gradle
• Deprecate existing build system
• Replace with Gradle build
• Easier now everything is forked in 2.3....
Grails 3.0: App Profiles
• Each profile will have distinct plugins, runtimes and
packaging (JAR, WAR etc.)
!39
!
$	
  grai...
Grails 3.0 Plugin Delineation
!40
grails.sh
static void
main
Gradle
Build
Forked Grails Runtime
test-app
run-app
console
s...
Grails 3.0 Deprecations / Removals
• Servlet 2.5 support (no web.xml)
• Gant & Current Build System
• GDoc - Replaced by A...
Grails 3.0: Challenges
• Compatibility
– Plugins
– Build System
• Modularization
– Servlet API independence
– Refactoring
...
!
Q & A
Grails 3.0
3.0
Stay Connected.
!
!
!
!
Web: grails.org
Twitter: twitter.com/grailsframework
LinkedIn: http://linkedin.com/groups/Grails-U...
Upcoming SlideShare
Loading in...5
×

Greach 2014 - Road to Grails 3.0

2,478

Published on

Keynote by Graeme Rocher detailing the roadmap for Grails up to 3.0

Published in: Technology

Greach 2014 - Road to Grails 3.0

  1. 1. By Graeme RocherRoad to Grails 3.0
  2. 2. Agenda § State of Nation § What’s new in Grails 2.3? § What’s planned for Grails 2.4? § What’s planned for Grails 3.0? § Summary / Q & A
  3. 3. State of Nation § Grails 2.3.7 most recent version § One release per month § Hundreds of bugs fixed in the last 3 months § More than 1,000 plugins now for Grails
  4. 4. What’s new in Grails 2.3? • Forked Execution and Test Daemon • Dependency Resolution with Aether • Complete Server-Side REST Support • Async Programmings APIs • New Data Binding APIs !4 2.3
  5. 5. What’s new in Grails 2.3? • XSS Prevention • Hibernate 4 Support (via Plugin) • RESTful Scaffolding v2.0 • Controller Namespaces • ... and much, much more !5 2.3
  6. 6. Aether & Dependency Management • Aether == Same dependency resolution engine as Maven – No snapshot troubles – Same local repo – No Ivy bugs • New dependency-report command to visualize graph !6
  7. 7. REST: URL Mappings • RESTful Mappings – Single or Multiple resources – Versioning – Nested resources • New url-mappings-report command to mappings !7
  8. 8. REST: @Resource Transformation • Automatically exposes a domain class as a REST resource • Configurable formats • Configuration HTTP methods !8 import  grails.rest.*   ! @Resource   class  Person  {          String  name   }
  9. 9. REST: The respond method • Sends the most appropriate response for the given object • For HTML calculates a model by convention and delegates to view
 !9 class  PersonController   {   def  index()  {   respond  Book.list()   }   }
  10. 10. REST: HAL, JSON, XML Renderers • Rendering customizable in resources.groovy • HAL, Atom, Vnd.Error renders included • Flexible and complete !10 import  grails.rest.render.hal.*   beans  =  {    halBookRenderer(HalJsonRenderer,                                      rest.test.Book)   } import  grails.rest.render.xml.*   beans  =  {          bookRenderer(XmlRenderer,                                      Book)  {                  includes  =  ['title']          }   }
  11. 11. REST: Scaffolding 2.0 • Scaffolding support now a plugin – http://grails.org/plugin/scaffolding • Generated controllers now RESTful • New generate-async- controller command for Async support !11
  12. 12. REST: Misc Goodies • grails.rest.RestfulController – Controller base class for inheriting RESTful actions • The respond method – Chooses most appropriate response format • Versioning support via URL mapping or Accept-Version header • Find out more http://grails.org/doc/2.3.x/guide/ webServices.html#REST !12
  13. 13. Async: Promise Primitives • Foundational API for Async programming • Includes notion of Promise • Ability to combine / chain promises !13 import  static   grails.async.Promises.*   ! def  p1  =  task  {  2  *  2  }   def  p2  =  task  {  4  *  4  }   def  p3  =  task  {  8  *  8  }   assert  [  4,  16,  64  ]  ==   waitAll(p1,  p2,  p3)
  14. 14. Async: @DelegateAsync Transform • Transform any synchronous API into an asynchronous one • Takes each method and returns a promise !14 ! import  grails.async.*   ! class  AsyncBookService  {        @DelegateAsync          BookService  bookService   }  
  15. 15. Async: GORM • Makes all GORM methods async • Deals with binding session to background thread • Works across all datastores (MongoDB, GORM for REST etc.) !15 ! def  p1  =  Person.async.get(1)   def  p2  =  Person.async.get(2)   def  p3  =  Person.async.get(3)   ! def  results  =                  waitAll(p1,  p2,  p3)  
  16. 16. Async: Request Processing • Handle requests asynchronously • Uses Servlet 3.0 async under the covers • Create asynchronous models !16 import  static   grails.async.Promises.*   ! class  PersonController  {      def  index()  {        tasks  books:  Book.async.list(),                  total:  Book.async.count(),                  otherValue:  {                        //  do  hard  work                  }        }   }
  17. 17. Data Binder: @BindingFormat • Per property formatting • Extensible !17 ! class  Person  {    @BindingFormat('MMddyyyy')    Date  birthDate    @BindingFormat('Uppercase')    String  salutation   }
  18. 18. Data Binder: @BindUsing • For cases where more flexibility is needed • Can be applied to class 
 or property • Takes a closure or a class
 that implements 
 BindingHelper !18 ! class  Person  {      @BindUsing({                  obj,  source  -­‐>                          source['name']?                          .toUpperCase()    })    String  salutation   }
  19. 19. Data Binding: XML/JSON Command Objects • Can now bind XML/JSON data to command objects • Binding can be customized using the BindingSource and BindingSourceCreator interfaces !19 ! class  PersonController   {      def  save(PersonCmd  p)          {          ...      }   }  
  20. 20. Data Binding: Auto Query if Domain Object • If command object is a domain class query on id • Passes null if domain class not found • If found binds XML, JSON or params !20 ! class  PersonController   {      def  save(Person  p)  {          ...      }   }  
  21. 21. XSS Prevention • All GSP expressions and scriptlets now escaped by default • Double-encoding prevention • New raw method to mark data as safe !21 ! //  Inside  GSP   <section>${raw(page.content)}</section>  
  22. 22. Other Goodies: Hibernate 4 Support • Hibernate 3 and 4 binary incompatible, so new plugin • Not all plugins that work with Hibernate 3 will work with Hibernate 4 !22 ! //  add  to  BuildConfig   compile  ‘:hibernate::hibernate4:4.3.4.2’  
  23. 23. Other Goodies: @Transactional Transform • Can be applied to any class • No proxies required! • Replacement for Spring’s @Transactional annotation !23 import   grails.transactions.*   ! @Transactional   class  PersonService  {   ...   }
  24. 24. Other Goodies: @DirtyCheck Transform • Can be applied to any class to add dirty checking • Tracks calls to setters that modify state • Classes implement the DirtyCheckable interface !24 @DirtyCheck   class  Person  {   ...   }   def  p  =      new  Person(name:'Bob')   p.trackChanges()   assert  !p.hasChanged()   p.name  =  'Fred'   assert  p.hasChanged()
  25. 25. Other Goodies: Action Error Handlers • Actions that define an exception as the first argument get invoked if the exception is thrown from any other action !25 ! class  PersonController  {        ...        def  tooOld(TooOldException  e)  {              render  view:  'tooOld'              }   }
  26. 26. Other Goodies: Controller Namespaces • Controllers can now define a namespace • URL Mappings can map to a specific namespace !26 ! class  PersonController  {        ...        static  namespace  =  'admins'               }  
  27. 27. ! Q & A Grails 2.3 2.3
  28. 28. ! The Future Grails 2.4 2.4
  29. 29. Grails 2.4: Goals • Spring 4.0 Upgrade • Java 8 Support • Groovy 2.3 Upgrade • Improved @CompileStatic Support • Asset Pipeline Plugin • Moduralization of Codebase • GORM & GSP Standalone !29 3.02.4
  30. 30. Spring 4.0 • Native GroovyBeanDefinitionReader (ported from BeanBuilder) – https://spring.io/blog/2014/03/03/groovy- bean-configuration-in-spring-framework-4 • Spring Web Socket – https://github.com/zyro23/grails-spring- websocket !30
  31. 31. Groovy 2.3 • Traits • Java 8 • Implicit closure coercion • Lots more! • http://groovy.codehaus.org/ Roadmap !31
  32. 32. Asset Pipeline Plugin • Resources replaced with Asset Pipeline – https://github.com/bertramdev/asset- pipeline/wiki/Why-asset-pipeline-over- grails-resources-plugin • Full documentation – http://bertramdev.github.io/asset- pipeline/ • Many thanks to David Estes! !32
  33. 33. Modularization !33 grails-web grails-web-mvc grails-web-sitemesh grails-web-gsp grails-web-jsp grails-web-servlet grails-web-common grails-core grails-encoder grails-project-api grails-validation
  34. 34. Standalone • GORM for Hibernate 4 in Spring Boot – https://gist.github.com/graemerocher/d31648899fdb461609fb • GORM for MongoDB in Spring Boot – https://gist.github.com/graemerocher/9683543 • GSP standalone coming !34
  35. 35. ! The Future Grails 3.0 3.0
  36. 36. Grails 3.0: Goals • Embrace Gradle • Abstract Packaging / Deployment • Reach outside the Servlet Container • App Profiles: Netty, Servlet, Batch, Hadoop • Deployment with run-app • Extend the reach of Grails ! !36 3.03.0
  37. 37. Grails 3.0: Goals • Plugin Model / Event Driven • Support Multi Project Builds • Support Micro Services • Remove Bloat • Reduce Dependencies • Discourage “Monolothic App” development !37 3.03.0
  38. 38. Grails 3.0: Gradle • Deprecate existing build system • Replace with Gradle build • Easier now everything is forked in 2.3.x • All the flexibility of a powerful build system • Plugins can provide Gradle extensions !38
  39. 39. Grails 3.0: App Profiles • Each profile will have distinct plugins, runtimes and packaging (JAR, WAR etc.) !39 ! $  grails  create-­‐app  myapp  -­‐-­‐profile=netty     $  cd  myapp   $  grails  package   $  java  -­‐jar  target/myapp.jar   !
  40. 40. Grails 3.0 Plugin Delineation !40 grails.sh static void main Gradle Build Forked Grails Runtime test-app run-app console shell Codegen Plugins Build Time Plugins Runtime Plugins
  41. 41. Grails 3.0 Deprecations / Removals • Servlet 2.5 support (no web.xml) • Gant & Current Build System • GDoc - Replaced by AsciiDoctor • Integration Tests - Replaced by more Mixins • Converters / Codecs plugins - Replaced by Groovy extensions • Filters - Replaced by new mechanism !41
  42. 42. Grails 3.0: Challenges • Compatibility – Plugins – Build System • Modularization – Servlet API independence – Refactoring !42 3.0
  43. 43. ! Q & A Grails 3.0 3.0
  44. 44. Stay Connected. ! ! ! ! Web: grails.org Twitter: twitter.com/grailsframework LinkedIn: http://linkedin.com/groups/Grails-User-Group-39757 Google +: https://plus.google.com/communities/ 109558563916416343008
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×