what's new in grails 2 · what's new in groovy 1.8? ... new ast transformations @log...
TRANSCRIPT
![Page 1: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/1.jpg)
© 2010 SpringSource, A division of VMware. All rights reserved
CONFIDENTIALCONFIDENTIAL
What's New in Grails 2.0Burt Beckwith
SpringSource
![Page 2: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/2.jpg)
2CONFIDENTIAL 2CONFIDENTIAL
Who Am I
Java developer for over 12 years
Background in Spring, Hibernate, Spring Security
Grails developer for 4 years
SpringSource employee on the Grails team
Created or reworked over 35 Grails plugins
http://burtbeckwith.com/blog/
https://twitter.com/#!/burtbeckwith
![Page 3: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/3.jpg)
3CONFIDENTIAL 3CONFIDENTIAL
Development Environment Features
![Page 4: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/4.jpg)
4CONFIDENTIAL 4CONFIDENTIAL
New Console UI & Interactive Mode
![Page 5: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/5.jpg)
5CONFIDENTIAL 5CONFIDENTIAL
Better Unit Test Template
![Page 6: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/6.jpg)
6CONFIDENTIAL 6CONFIDENTIAL
Better Documentation Template
![Page 7: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/7.jpg)
7CONFIDENTIAL 7CONFIDENTIAL
Enhanced Error Reporting
![Page 8: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/8.jpg)
8CONFIDENTIAL 8CONFIDENTIAL
Database Console
Available at http://localhost:8080/appname/dbconsole in dev environment; can be enabled in other environments
![Page 9: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/9.jpg)
9CONFIDENTIAL 9CONFIDENTIAL
Plugin Portal Usage Tracking
Opt-in usage tracking of plugins
![Page 10: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/10.jpg)
10CONFIDENTIAL 10CONFIDENTIAL
Upgraded Libraries
![Page 11: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/11.jpg)
11CONFIDENTIAL 11CONFIDENTIAL
What's new in Groovy 1.8?
![Page 12: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/12.jpg)
12CONFIDENTIAL 12CONFIDENTIAL
What's new in Groovy 1.8?
Nicer DSLs with command chains expressions
Runtime performance improvements
GPars bundled
Closure enhancements
Builtin JSON support
New AST transformations
![Page 13: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/13.jpg)
13CONFIDENTIAL 13CONFIDENTIAL
Command Chains Expressions
Simple example:
• turn left then right• Was turn(left).then(right)
These are equivalent:
• take 2.pills, of: chloroquinine, after: 6.hours• take(2).pills(of).chloroquinine(after).6(hours)• take 2 pills of chloroquinine after 6 hours
![Page 14: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/14.jpg)
14CONFIDENTIAL 14CONFIDENTIAL
Runtime performance improvements
Significant runtime improvements for primitive type operations
• Classical Fibonacci example 13x faster!
• almost as fast as Java
Some direct method calls
Current work being done for static type checking
• http://blackdragsview.blogspot.com/2011/10/feeling-grumpy.html
![Page 15: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/15.jpg)
15CONFIDENTIAL 15CONFIDENTIAL
GPars bundled
GPars is bundled in the Groovy distribution
Covers a wide range of parallel and concurrent paradigms:
• Actors
• Fork/join
• Map/filter/reduce
• Dataflow
• Agents
• STM
• Parallel arrays
• Executors
• and more ...
![Page 16: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/16.jpg)
16CONFIDENTIAL 16CONFIDENTIAL
Closure enhancements
Closure annotation parameters
Some more functional flavor
• composition
• trampoline
• memoization
Currying improvements
![Page 17: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/17.jpg)
17CONFIDENTIAL 17CONFIDENTIAL
Closure annotation parameters
@Retention(RetentionPolicy.RUNTIME)@interface Invariant { Class value() // a closure class}
@Invariant({number >= 0 })class Distance { float number
String unit}
def d = new Distance(number: 10, unit: "meters")def anno = Distance.getAnnotation(Invariant)def check = anno.value().newInstance(d, d)assert check(d)
![Page 18: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/18.jpg)
18CONFIDENTIAL 18CONFIDENTIAL
Built in JSON support
Consuming
Producing
Pretty-printing
import groovy.json.*
def json = new JsonBuilder()json.person { name 'Guillaume' age 33 pets 'Hector', 'Felix'}println json.toString()println json.toPrettyString()
{"person":{"name":"Guillaume","age":33,"pets":"Hector","Felix"]}}{ "person": { "name": "Guillaume", "age": 33, "pets": [ "Hector", "Felix" ] }}
![Page 19: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/19.jpg)
19CONFIDENTIAL 19CONFIDENTIAL
New AST transformations
@Log
@Field
@AutoClone
@AutoExternalizable
@ThreadInterrupt,
@TimedInterrupt,
@ConditionalInterrupt
@InheritConstructor
@Canonical
• @ToString
• @EqualsAndHashCode
• @TupleConstructor
@WithReadLock
@WithWriteLock
![Page 20: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/20.jpg)
20CONFIDENTIAL 20CONFIDENTIAL
New Automatic Reloading
![Page 21: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/21.jpg)
21CONFIDENTIAL 21CONFIDENTIAL
New Automatic Reloading
Reloading in run-app works with
• Typed service references
• Domain classes
• src/groovy, src/java
![Page 22: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/22.jpg)
22CONFIDENTIAL 22CONFIDENTIAL
New Automatic Reloading
Reloading in run-app works with
• Typed service references
• Domain classes
• src/groovy, src/java
Any command with -reloading
![Page 23: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/23.jpg)
23CONFIDENTIAL 23CONFIDENTIAL
New Automatic Reloading
Reloading in run-app works with
• Typed service references
• Domain classes
• src/groovy, src/java
Any command with -reloading
Interactive mode and integration tests
![Page 24: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/24.jpg)
24CONFIDENTIAL 24CONFIDENTIAL
Binary Plugins
Package pre-compiled plugins into JAR files
Deployable as standard JARs to Maven repositories
Declared as JAR dependencies
Commercial plugins more viable
No special IDE integration needed
$ grails package-plugin –binary
![Page 25: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/25.jpg)
25CONFIDENTIAL 25CONFIDENTIAL
Web Features
![Page 26: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/26.jpg)
26CONFIDENTIAL 26CONFIDENTIAL
HTML5 Scaffolding
![Page 27: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/27.jpg)
27CONFIDENTIAL 27CONFIDENTIAL
New APIs
Page Rendering
Link Generation
PageRenderer groovyPageRenderervoid welcomeUser(User user) { def contents = groovyPageRenderer.render( view: "/emails/welcome", model: [user: user]) ...}
LinkGenerator grailsLinkGeneratorString generateLink() { grailsLinkGenerator.link( controller: "book", action: "list")}
![Page 28: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/28.jpg)
28CONFIDENTIAL 28CONFIDENTIAL
Advanced Static Resource Handling
Integrated resource plugin into core
• http://grails.org/plugin/resources
Tuning static resources no longer a headache
• gzip (http://grails.org/plugin/zipped-resources)
• cache (http://grails.org/plugin/cached-resources)
• De-duplication
• Bundling
New tags to ease integration
• img
• external
• javascript
![Page 29: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/29.jpg)
29CONFIDENTIAL 29CONFIDENTIAL
Bundling Static Resources
modules = { core { dependsOn 'utils' resource url: '/js/core.js', disposition: 'head' resource url: '/js/ui.js' resource url: '/css/main.css' resource url: '/css/branding.css' resource url: '/css/print.css', attrs: [media: 'print'] } utils { dependsOn 'jquery' resource url: '/js/utils.js' }}
![Page 30: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/30.jpg)
30CONFIDENTIAL 30CONFIDENTIAL
Zipping and Caching
$ grails installplugin cachedresources$ grails installplugin zippedresources
plugins { runtime ":hibernate:$grailsVersion" runtime ":jquery:1.7.1" runtime ":resources:1.1.5" build ":tomcat:$grailsVersion"
runtime ":cachedresources:1.0" runtime ":zippedresources:1.0"}
Or add dependency in BuildConfig.groovy:
![Page 31: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/31.jpg)
31CONFIDENTIAL 31CONFIDENTIAL
Persistence Features
![Page 32: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/32.jpg)
32CONFIDENTIAL 32CONFIDENTIAL
GORM API
![Page 33: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/33.jpg)
33CONFIDENTIAL 33CONFIDENTIAL
GORM API
![Page 34: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/34.jpg)
34CONFIDENTIAL 34CONFIDENTIAL
GORM API
Plugins should not assume Hibernate is available
![Page 35: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/35.jpg)
35CONFIDENTIAL 35CONFIDENTIAL
GORM Plugins
Redis - http://grails.org/plugin/redis-gorm
MongoDB - http://grails.org/plugin/mongodb
Amazon SimpleDB - http://grails.org/plugin/simpledb
Neo4j - http://grails.org/plugin/neo4j
Riak - http://grails.org/plugin/riak
GORM JPA - http://grails.org/plugin/gorm-jpa
Hibernate - http://grails.org/plugin/hibernate
![Page 36: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/36.jpg)
36CONFIDENTIAL 36CONFIDENTIAL
Where Queries
![Page 37: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/37.jpg)
37CONFIDENTIAL 37CONFIDENTIAL
Where Queries
New, compile-time checked query DSL
def query = Person.where { firstName == "Bart"}Person bart = query.find()
![Page 38: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/38.jpg)
38CONFIDENTIAL 38CONFIDENTIAL
Where Queries
New, compile-time checked query DSL
Uses native Groovy operators ==, !=, >, <, <=, >= etc.
def query = Person.where { firstName == "Fred" && !(lastName == 'Simpson')}
def query = Person.where { firstName == "Bart"}Person bart = query.find()
![Page 39: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/39.jpg)
39CONFIDENTIAL 39CONFIDENTIAL
Where Queries
New, compile-time checked query DSL
Uses native Groovy operators ==, !=, >, <, <=, >= etc.
Aggregate functions supported avg, sum, max, min etc.
def query = Person.where { age > avg(age)}
def query = Person.where { firstName == "Fred" && !(lastName == 'Simpson')}
def query = Person.where { firstName == "Bart"}Person bart = query.find()
![Page 40: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/40.jpg)
40CONFIDENTIAL 40CONFIDENTIAL
Multiple Data Sources
Support for defining multiple scoped data sources
class ZipCode { String code static mapping = { datasource 'auditing' }}
![Page 41: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/41.jpg)
41CONFIDENTIAL 41CONFIDENTIAL
Multiple Data Sources
Support for defining multiple scoped data sources
Each data source accessible via static property
def zipCode = ZipCode.auditing.get(42)
class ZipCode { String code static mapping = { datasource 'auditing' }}
![Page 42: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/42.jpg)
42CONFIDENTIAL 42CONFIDENTIAL
SQL Database Migration
Hibernate 'update'+
Production data=
?
![Page 43: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/43.jpg)
43CONFIDENTIAL 43CONFIDENTIAL
SQL Database Migration
Hibernate 'update'+
Production data=
![Page 44: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/44.jpg)
44CONFIDENTIAL 44CONFIDENTIAL
GORM Plugins
Install the Database Migration plugin:
Official Docs at:
• http://grails-plugins.github.com/grails-database-migration/
$ grails installplugin databasemigration
![Page 45: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/45.jpg)
45CONFIDENTIAL 45CONFIDENTIAL
SQL Database Migration
Pre-production, Hibernate 'update' or 'create-drop'
![Page 46: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/46.jpg)
46CONFIDENTIAL 46CONFIDENTIAL
SQL Database Migration
Pre-production, Hibernate 'update' or 'create-drop'
dbm-generate-changelogdbm-changelog-sync
![Page 47: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/47.jpg)
47CONFIDENTIAL 47CONFIDENTIAL
SQL Database Migration
Pre-production, Hibernate 'update' or 'create-drop'
dbm-generate-changelogdbm-changelog-sync
Change domain model
dbm-gorm-diffdbm-update
![Page 48: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/48.jpg)
48CONFIDENTIAL 48CONFIDENTIAL
SQL Reverse Engineering
![Page 49: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/49.jpg)
49CONFIDENTIAL 49CONFIDENTIAL
SQL Reverse Engineering
$ grails install-plugin db-reverse-engineer$ grails db-reverse-engineer
![Page 50: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/50.jpg)
50CONFIDENTIAL 50CONFIDENTIAL
SQL Reverse Engineering
class Person { String name Integer age Date dateCreated ...}
$ grails install-plugin db-reverse-engineer$ grails db-reverse-engineer
![Page 51: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/51.jpg)
51CONFIDENTIAL 51CONFIDENTIAL
Other GORM Improvements
Abstract base domain classes
• These now result in a table
![Page 52: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/52.jpg)
52CONFIDENTIAL 52CONFIDENTIAL
Other GORM Improvements
Abstract base domain classes
• These now result in a table
findOrCreateWhere()
findOrSaveWhere()
![Page 53: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/53.jpg)
53CONFIDENTIAL 53CONFIDENTIAL
Other GORM Improvements
Abstract base domain classes
• These now result in a table
findOrCreateWhere()
findOrSaveWhere()
def user = User.findByLogin('admin')if (!user) { user = new User(login: 'admin') user.save(failOnError: true)}
![Page 54: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/54.jpg)
54CONFIDENTIAL 54CONFIDENTIAL
Other GORM Improvements
Abstract base domain classes
• These now result in a table
findOrCreateWhere()
findOrSaveWhere()
def user = User.findByLogin('admin')if (!user) { user = new User(login: 'admin') user.save(failOnError: true)}
def user = User.findOrSaveWhere(login: 'admin')
![Page 55: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/55.jpg)
55CONFIDENTIAL 55CONFIDENTIAL
Better Unit Testing
![Page 56: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/56.jpg)
56CONFIDENTIAL 56CONFIDENTIAL
Unit Testing Pre-2.0
![Page 57: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/57.jpg)
57CONFIDENTIAL 57CONFIDENTIAL
Unit Testing Pre-2.0
• mockDomain() had only partial GORM support
• always lagged changes in GORM
![Page 58: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/58.jpg)
58CONFIDENTIAL 58CONFIDENTIAL
Unit Testing Pre-2.0
• mockDomain() had only partial GORM support
• always lagged changes in GORM
Inheritance-based
• hierarchy duplicated for Spock
• difficult to extend
![Page 59: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/59.jpg)
59CONFIDENTIAL 59CONFIDENTIAL
Unit Testing Pre-2.0
• mockDomain() had only partial GORM support
• always lagged changes in GORM
Inheritance-based
• hierarchy duplicated for Spock
• difficult to extend
Weak support for web-related testing
• controllers
• tag libraries
![Page 60: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/60.jpg)
60CONFIDENTIAL 60CONFIDENTIAL
The Mixin Approach
@TestFor(MyController)@Mock(Person)class MyControllerUnitTests { protected void setUp() { new Person(...).save() new Person(...).save() }
void testIndex() { def model = controller.index() ... }}
![Page 61: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/61.jpg)
61CONFIDENTIAL 61CONFIDENTIAL
Support for testing...
![Page 62: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/62.jpg)
62CONFIDENTIAL 62CONFIDENTIAL
Support for testing...
Tag libraries
![Page 63: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/63.jpg)
63CONFIDENTIAL 63CONFIDENTIAL
Support for testing...
Tag libraries
Command objects
![Page 64: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/64.jpg)
64CONFIDENTIAL 64CONFIDENTIAL
Support for testing...
Tag libraries
Command objects
XML & JSON responses
![Page 65: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/65.jpg)
65CONFIDENTIAL 65CONFIDENTIAL
Support for testing...
Tag libraries
Command objects
XML & JSON responses
File upload
![Page 66: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/66.jpg)
66CONFIDENTIAL 66CONFIDENTIAL
Support for testing...
Tag libraries
Command objects
XML & JSON responses
File upload
View and template rendering
![Page 67: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/67.jpg)
67CONFIDENTIAL 67CONFIDENTIAL
Support for testing...
Tag libraries
Command objects
XML & JSON responses
File upload
View and template rendering
Filters
![Page 68: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/68.jpg)
68CONFIDENTIAL 68CONFIDENTIAL
Support for testing...
Tag libraries
Command objects
XML & JSON responses
File upload
View and template rendering
Filters
URL mappings
![Page 69: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/69.jpg)
69CONFIDENTIAL 69CONFIDENTIAL
Support for testing...
Tag libraries
Command objects
XML & JSON responses
File upload
View and template rendering
Filters
URL mappings
Criteria queries
![Page 70: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/70.jpg)
70CONFIDENTIAL 70CONFIDENTIAL
Support for testing...
Tag libraries
Command objects
XML & JSON responses
File upload
View and template rendering
Filters
URL mappings
Criteria queries
and more!
![Page 71: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/71.jpg)
71CONFIDENTIAL 71CONFIDENTIAL
Grails in the Cloud
![Page 72: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/72.jpg)
72CONFIDENTIAL 72CONFIDENTIAL
For the Future
A continued focus on
•Reliability
•User experience
•Modularity
•More cloud
![Page 73: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/73.jpg)
73CONFIDENTIAL 73CONFIDENTIAL
Demo
![Page 74: What's New in Grails 2 · What's new in Groovy 1.8? ... New AST transformations @Log @Field @AutoClone @AutoExternalizable @ThreadInterrupt, @TimedInterrupt, @ConditionalInterrupt](https://reader035.vdocuments.us/reader035/viewer/2022071219/6057b4cba242b6199609bc8c/html5/thumbnails/74.jpg)
74CONFIDENTIAL 74CONFIDENTIAL
Thank You
Questions?