Grails 2.0 Update
Upcoming SlideShare
Loading in...5
×
 

Grails 2.0 Update

on

  • 3,037 views

See what's new in Grails 2.0

See what's new in Grails 2.0

Statistics

Views

Total Views
3,037
Views on SlideShare
3,035
Embed Views
2

Actions

Likes
5
Downloads
58
Comments
0

2 Embeds 2

http://us-w1.rockmelt.com 1
http://tweetedtimes.com 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Grails 2.0 Update Grails 2.0 Update Presentation Transcript

  • What’s new in 2.0 Peter Ledbrook SpringSource t: @pledbrook g: +PeterLedbrook e: pledbrook@vmware.comWednesday, 2 May 12
  • The Year in Grails • Grails 1.3 –Plugins in Dependency DSL, Groovy 1.7, Named Queries etc. • More and more plugins –Spring Security Core et al. –RabbitMQ –Gemfire –Resources, etc. • NoSQL –Redis, MongoDB, Riak, etc. 2Wednesday, 2 May 12
  • High Profile Sites 3Wednesday, 2 May 12 View slide
  • Grails Continued Growth Number of Plugins800600400200 0 2008 2009 2010 2011 4Wednesday, 2 May 12 View slide
  • Development Environment FeaturesWednesday, 2 May 12
  • New Console UI & Interactive Mode 6Wednesday, 2 May 12
  • Better Unit Test Template 7Wednesday, 2 May 12
  • Better Documentation Template 8Wednesday, 2 May 12
  • Enhanced Error Reporting 9Wednesday, 2 May 12
  • H2 Console • Available at http://localhost:8080/app/dbconsole in development only! 10Wednesday, 2 May 12
  • Plugin Portal Usage Tracking • Opt-in usage tracking of plugins 11Wednesday, 2 May 12
  • Upgraded Libraries 12Wednesday, 2 May 12
  • 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 13Wednesday, 2 May 12
  • 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 14Wednesday, 2 May 12
  • Web FeaturesWednesday, 2 May 12
  • Methods as Actions and Binding Arguments • Actions are now declared as public methods def save(String name, int age) { // remaining } • Form parameters bound to method arguments <g:form name="myForm" action="save"> <input name="name" /> <input name="age" /> </g:form> 16Wednesday, 2 May 12
  • HTML5 Scaffolding 17Wednesday, 2 May 12
  • New APIs • Page Rendering PageRenderer renderer void welcomeUser(User user) { def contents = renderer.render(view:"/emails/welcome", model:[user: user]) ... } • Link Generation LinkGenerator generator def generateLink() { generator.link(controller:"book", action:"list") } 18Wednesday, 2 May 12
  • Servlet 3.0 Async • Servlet 3.0 async API supported for async response rendering def index() { def ctx = startAsync() ctx.start { new Book(title:"The Stand").save() render template:"books", model:[books: Book.list() ] ctx.complete() } } 19Wednesday, 2 May 12
  • 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 20Wednesday, 2 May 12
  • 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 } } 21Wednesday, 2 May 12
  • Zipping and Caching $ grails install-plugin cached-resources $ grails install-plugin zipped-resources 22Wednesday, 2 May 12
  • Other Web Novelties • jQuery now the default • Easy Date Parsing def val = params.date(myDate, dd-MM-yyyy) • Customizable URL formats • Filter exclusions 23Wednesday, 2 May 12
  • Persistence FeaturesWednesday, 2 May 12
  • GORM API • Plugins should not assume Hibernate! 25Wednesday, 2 May 12
  • GORM Plugins • Redis - http://grails.org/plugin/redis-gorm • MongoDB - http://grails.org/plugin/mongodb • Amazon SimpleDB - http://grails.org/plugin/simpledb • Amazon DynamoDB - http://grails.org/plugin/dynamodb • 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 26Wednesday, 2 May 12
  • Where Queries • New, compile-time checked query DSL def query = Person.where { firstName == "Bart" } Person bart = query.find() • Uses native Groovy operators ==, !=, >, <, <=, >= etc def query = Person.where { firstName == "Fred" && !(lastName == Simpson) } • Aggregate functions supported avg, sum, max, min etc. def query = Person.where { age > avg(age) } 27Wednesday, 2 May 12
  • Multiple Data Sources • Support for defining multiple scoped data sources class ZipCode { String code static mapping = { datasource auditing } } • Each data source accessible via static property def zipCode = ZipCode.auditing.get(42) 28Wednesday, 2 May 12
  • SQL Database Migration Hibernate ‘update’ + Production data = ? 29Wednesday, 2 May 12
  • SQL Database Migration • Install the Database Migration plugin: $ grails install-plugin database-migration • Official Docs at: – http://grails-plugins.github.com/grails-database-migration/ 30Wednesday, 2 May 12
  • SQL Database Migration Pre-production, Hibernate ‘update’ or ‘create-drop’ dbm-generate-changelog dbm-changelog-sync Change domain model dbm-gorm-diff dbm-update 31Wednesday, 2 May 12
  • SQL Reverse Engineering $ grails install-plugin db-reverse-engineer $ grails db-reverse-engineer class Person { String name Integer age ... } 32Wednesday, 2 May 12
  • 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) 33Wednesday, 2 May 12
  • Better Unit TestingWednesday, 2 May 12
  • Unit Testing 1.x • 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 35Wednesday, 2 May 12
  • The Mixin Approach @TestFor(MyController) @Mock(Person) class MyControllerUnitTests { void setUp() { new Person(...).save() new Person(...).save() } void testIndex() { def model = this.controller.index() ... } } 36Wednesday, 2 May 12
  • Spockified @TestFor(MyController) @Mock(Person) class MyControllerUnitSpec extends Specification { void loadPeople() { new Person(...).save() new Person(...).save() } def Test index action() { given: Some people loadPeople() when: The index action is called def model = this.controller.index() then: The people variable is in the model model.people != null } } 37Wednesday, 2 May 12
  • In-Memory GORM • Full GORM implementation against ConcurrentHashMap • Based on GORM for NoSQL codebase • Support for – Criteria queries – Where queries – Dynamic finders – Detached criteria 38Wednesday, 2 May 12
  • Support for testing... • Tag libraries • Command objects • XML & JSON responses • File upload • View and template rendering • Filters • URL mappings • Criteria queries • and more! 39Wednesday, 2 May 12
  • Contributions • 110+ pull requests on grails-core • 60+ pull requests on grails-docs • More and more plugins • GitHub for the win! – grails-core – grails-docs – grails-website – grails-maven – and many, many plugins 40Wednesday, 2 May 12
  • Grails in the Cloud 41Wednesday, 2 May 12
  • Roadmap 42Wednesday, 2 May 12
  • Thank you! Questions? 43Wednesday, 2 May 12