intro to grails
DESCRIPTION
Robert Fischer (Smokejumper Consulting)'s presentation introducing Grails given to the Triangle Java User Group.TRANSCRIPT
![Page 1: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/1.jpg)
Smokejumping GrailsRobert Fischer, Smokejumper Consultingrobert . fischer @ SmokejumperIT . com
Presented Nov 17th, 2008at the Triangle Java User Group (TriJUG)
1Tuesday, November 18, 2008
![Page 2: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/2.jpg)
Hi, I’m Robert2Tuesday, November 18, 2008
![Page 4: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/4.jpg)
Born and Raised in Perl4Tuesday, November 18, 2008
![Page 6: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/6.jpg)
Technical BloggerEnfranchisedMind.com• The Joy of BDD, or, Re-writing Your Code in
Mocks and Asserts is Not Unit Testing
• Functional (Meta)?Programming Stunts for Ruby and Groovy (and a Little Perl)
• 7 Actually Useful Things You Didn’t Know Static Typing Could Do: An Introduction for the Dynamic Language Enthusiast
• A Defense of Prototypes, or, Why Does Tom Christiansen Hate Perl?
6Tuesday, November 18, 2008
![Page 7: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/7.jpg)
Groovy/Grails Fanboy
• Introduced to Groovy/Grails at Carol.com, Active in Groovy Users of Minnesota
• Uses Grails as freelancer to quickly develop prototype applications
• Regular on IRC: FreeNode #groovy, #grails
• Active on Groovy and Grails mailing lists
• Autobase and BackgroundThread plugin
7Tuesday, November 18, 2008
![Page 8: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/8.jpg)
All Web App Development Should
Be Grails
8Tuesday, November 18, 2008
![Page 9: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/9.jpg)
No, Really.
• Stunningly simple development.
• Succinct code using a superset of Java.
• Sane defaults, straightforward configuration.
• Static typing as deemed useful by developer.
• Standard deployment approach.
• SpringSource backed and here to stay.
9Tuesday, November 18, 2008
![Page 10: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/10.jpg)
What Is Grails?
• Web application development framework/environment leveraging Java and Groovy.
• Convention-based MVC development with a set of powerful command-line tools.
• Powered by pre-configured and pre-integrated Spring, Hibernate, SiteMesh, and JUnit.
10Tuesday, November 18, 2008
![Page 11: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/11.jpg)
How Would YouLike Your Grails?
• Conceptually thin dynamic MVC framework
• Dynamic, succinct domain and controllers
• Run from source code check-out
• Mash-up with extensible plugin architecture
• Actually approachable best-of-breed Java stack
• Prepackaged Java environment and build system
• Builds a WAR to plug into existing deployments
• Hooks for existing Spring and Hibernate config
11Tuesday, November 18, 2008
![Page 12: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/12.jpg)
Grails BeforeYour Very Eyes!
Live Coding!
12Tuesday, November 18, 2008
![Page 13: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/13.jpg)
But Wait, There’s More!Plugins
• Functional Testingwebtest, selenium, fitnesse
• Rich User Interface (RIA)grails-ui, richui, gwt, flex, yui, iui
• Database Management: Autobase
• Background Tasks: BackgroundThread
• And dozens more: http://grails.org/plugins
13Tuesday, November 18, 2008
![Page 14: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/14.jpg)
Autobase
• Manages database state using a non-linear collection of database change sets.
• Leverages existing Grails database automation to minimize effort.
• Provides a Liquibase-based embedded DSL for database migrations.
• http://github.com/RobertFischer/autobase/wikis/
14Tuesday, November 18, 2008
![Page 15: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/15.jpg)
Example Migration
changeSet(id:'rename_bar_to_baz', author:'Robert'){ dropColumn(tableName:'foo', columnName:'baz') renameColumn(tableName:"foo", oldColumnName:"bar", newColumnName:"baz")}
15Tuesday, November 18, 2008
![Page 16: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/16.jpg)
Background Thread
• Provides a Spring bean that will execute arbitrary closures in the background.
• Handles some awkwardness around Hibernate sessions, and provides thread pooling and logging.
• http://grails.org/BackgroundThread+Plugin
16Tuesday, November 18, 2008
![Page 17: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/17.jpg)
BackgroundThread Usage Example
class FooService {
boolean transactional = false def backgroundService
def serviceMethod() { (1..<10).each { cnt -> backgroundService.execute("Logging '$cnt'”, { log.info("${cnt}") }) }
}
17Tuesday, November 18, 2008
![Page 18: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/18.jpg)
But What AboutJRuby on Rails?
18Tuesday, November 18, 2008
![Page 19: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/19.jpg)
My JRuby on RailsStreet Cred
• Work history in Rails, including last 5 months on a JRuby on Rails project
• Regular attendee, competition member, and one-time presenter at Ruby Users of Minnesota (RUM)
• Charlie “Headius” Nutter fan
19Tuesday, November 18, 2008
![Page 20: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/20.jpg)
Why NotJRuby on Rails?
• Although Java-in-Ruby is fairly slick, Ruby-in-Java is pretty rough and best mediated via Groovy metaprogramming
• GORM is superior to ActiveRecord
• http://www.oreillynet.com/ruby/blog/2007/05/bind_parameters_now.html
• GSPs are superior to ActionView
• Spring is superior to nothing
• Optional static typing is superior to pure dynamic typing
• You can code Grails without grokking its source
• Nobody is fired for choosing Java
20Tuesday, November 18, 2008
![Page 21: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/21.jpg)
The One Circumstance I Would Still Use Rails• Small CRUD-based app with its own DB
• No or very generous performance limits
• Owned by one or two developers
• Expected life cycle of less than a year
• Deployed system is without Java or is an Apache web server with mod_passenger and without mod_proxy or mod_jk
21Tuesday, November 18, 2008
![Page 22: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/22.jpg)
Your GrailsAdoption Plan
• Best approach: start with a roughly green-field proof-of-concept web application
• Use GRAG on SourceForge to generate a database front-end to impress your boss
• Wrap an existing Java web application in Grails and use web.xml (installed via “grails install-templates”) to map urls to servlets
22Tuesday, November 18, 2008
![Page 23: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/23.jpg)
Resources
• Home Pages:http://grails.orghttp://groovy.codehaus.org/
• Live Open Source ApplicationsGrails CrowdGrails.orgGroovy Blogs
• MediaGroovy & Grails PodcastGroovyMag
23Tuesday, November 18, 2008
![Page 25: Intro To Grails](https://reader036.vdocuments.us/reader036/viewer/2022062300/554f5765b4c905423f8b5692/html5/thumbnails/25.jpg)
Sold?Want to know more?• Robert is offering “Introduction to Groovy,
Grails, and AJAX” training in the Triangle on December 15th through 18th. Additional training courses will be offered next year.
• Subscribe to “Smokejumper Training” Google Group for more information.
• On-demand training, technical leadership, and mentoring services are also available.http://SmokejumperIT.com
25Tuesday, November 18, 2008