SlideShare a Scribd company logo
Groovy & Grails Rain 2010-1-15
目录 Groovy Grails Demo
Web Frameworks
How do we choose?
Grails vs Rails Groovy vs Ruby API documentation better than Rails Solid frameworks underneath, such as spring, hibernate Both has a active community, Rails more popular, and more jobs, more books.
Grails vs Rails DB Migrations GORM vs Active Record REST Webserver Faster than Rails, but used lot of memory, cheaper hosting Rails mature than Grails Rails release/update more often
Groovy Groovy 是一种基于 JVM 的敏捷开发语言,它结合了 Python 、 Ruby 和 Smalltalk 的许多强大的特性。 支持 DSL 对于 Java 开发人员几乎没有学习难度 可以编译成字节码
Hello Groovy def name='World'; println "Hello $name!"
Groovy vs Java default imports closures   native  syntax  for lists and maps  GroovyMarkup  and GPath support  native support for  regular expressions   polymorphic  iteration  and powerful  switch statement   dynamic and static typing is supported - so you can omit the type declarations on methods, fields and variables  you can embed expressions inside  strings   lots of new helper methods added to the  JDK   simpler syntax for writing  beans  for both properties and adding event listeners  safe navigation  using the ?. operator, e.g. "variable?.field" and "variable?.method()" - no more nested ifs to check for null clogging up your code
Default imports java.io.*  java.lang.*  java.math.BigDecimal  java.math.BigInteger  java.net.*  java.util.*  groovy.lang.*  groovy.util.*
Commons int[] a = {1,2,3};  -> int[] a = [1,2,3]  for (int i=0; i < len; i++) {...}  -> for (i in 0..len-1) {...}  -> len.times {...}
Others to know Semicolons are optional You can use the this keyword inside static methods  The return keyword is optional  The throws clause in a method signature is not checked by the Groovy compiler  You will not get compile errors like you would in Java for using undefined members or passing arguments of the wrong type.
Cloure square = { it * it }  square(9) // 81 [ 1, 2, 3, 4 ].collect(square)  // =[ 1, 4, 9, 16 ]
Grails 快速 Web 开发框架 基于 Groovy 编程语言 构建于 Spring 、 Hibernate 和其它标准 Java 框架之上  高效的一站式框架
 
Success Stories
MVC Model : Domain class Person { String name } View : gsp 、 taglib Controller : XxxController class PersonController { def create = {} def save = {} def view = {} }
Scaffold class XxxController { def scaffold = Domain }
GORM CRUD : save 、 get 、 delete 、 list findBy* findAllBy* findWhere findAllWhere find(sql) count/countBy* exists list/listOrderBy withCriteria executeQuery(HSQL)
Taglib if/else/elseif/while/set/collect/each/grep/findAll meta/header/cookie pageProperty/layoutHeader/layoutTitle/layoutBody/applyLayout resource/javascript/include/render textField/textArea/radio/checkBox/form/ remoteField/formRemote/remoteLink
Service 在 grails-app/service 目录 命名约定 XxxService
Testing unit Integration GroovyTestCase GrailsUnitTestCase GroovyPagesTestCase ControllerUnitTestCase TagLibUnitTestCase WebFlowTestCase
Plugins Over 340 Security : Acegi 、 Shiro Ajax : Prototype 、 jQuery 、 YUI 、 GWT UI : GrailsUI 、 RichUI Report : Dynamic Jasper Jobs : Quartz  Web 2.0: Feeds 、 Taggable 、 Commentable Workflow : grailsflow 、 jbpm Editor : FCKeditor
Tools IDE: Eclipse 3.5 、 NetBeans 6.8 、 IDEA 9 、 Spring STS 2.3.0 Editor : E-Texteditor 、 Textmate 、 GEdit Build : Maven 、 Ant 、 Ivy WebContainer : Tomcat 、 Jetty Database : HSQL 、 MySQL GRAG
Books
Tutorials Mastering Grails @  IBM  developerWorks Cookbook Tutorials Articles Twitter and Google Maps  mashup  in 20 minutes with Grails   Securing a Grails application using Spring and  Acegi  Security   A Grails-Powered  Blog  (Part 1) A Grails-Powered  Blog  (Part 2)
Presentations http://grailspodcast.com/blog/list Grails  JavaOne  2006 Slides Groovy & Grails Seminar   Bending GORM: 5-minute Techniques for Enterprise Integration Grails 1.1 Testing - Unit, Integration, Functional (July 2009)   Getting Started with Grails
Roadmap Grails 1.3 support groovy 1.7 , standalone GSP , Deployment and resolution of plugins from Maven repositories Grails 2.0 modular deployment with OSGi
App grails.org http://grails.org groovyblogs.org http://www.groovyblogs.org/ Weceem CMS http://www.weceem.org/ Groller http://code.google.com/p/rainboyan/
Demo Grails HelloWorld: 1) grails create-app helloworld 2) grails create-controller hello 3) edit HelloController.groovy 4) create say.gsp 5) grails run-app
Links http://www.grails.org http://www.grails.org/Tutorials http://www.jtict.com/blog/grails-vs-rails/ http://www.grails.org/GRAG
QA ?

More Related Content

PDF
Whats New In Groovy 1.6?
ODP
eXo EC - Groovy Programming Language
PDF
Spring-batch Groovy y Gradle
PPTX
Geb+spock: let your functional tests live long and prosper
PDF
Jedi knight
PDF
TDD with Spock @xpdays_ua
PDF
Groovy Finesse
PDF
Embedding Groovy in a Java Application
Whats New In Groovy 1.6?
eXo EC - Groovy Programming Language
Spring-batch Groovy y Gradle
Geb+spock: let your functional tests live long and prosper
Jedi knight
TDD with Spock @xpdays_ua
Groovy Finesse
Embedding Groovy in a Java Application

What's hot (20)

PDF
GradleのREPLプラグイン紹介 #jggug
PPT
Google Web Toolkit
KEY
Groovy & Grails
ODP
Django On Jython (for Portland and Boulder Python user groups presentations)
PDF
Hands on the Gradle
KEY
うさぎ組 in G* WorkShop -うさみみの日常-
PDF
Gwt Presentation
PDF
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
PDF
Aprende, contribuye, y surfea Cloud Native Java - GuateJUG 2021
PPTX
GWTcon 2015 - Best development practices for GWT web applications
PDF
APIs Rest com NodeJS
PDF
(C)NodeJS
PDF
Apache Groovy: the language and the ecosystem
PDF
Building Rich Internet Applications Using Google Web Toolkit
PDF
An Introduction to Gradle for Java Developers
PDF
TypeScriptについて
PDF
Introduction to Griffon
PDF
Towards component based web UI with ReactJS
KEY
Introduction To Grails
GradleのREPLプラグイン紹介 #jggug
Google Web Toolkit
Groovy & Grails
Django On Jython (for Portland and Boulder Python user groups presentations)
Hands on the Gradle
うさぎ組 in G* WorkShop -うさみみの日常-
Gwt Presentation
"How to Use Bazel to Manage Monorepos: The Grammarly Front-End Team’s Experie...
Aprende, contribuye, y surfea Cloud Native Java - GuateJUG 2021
GWTcon 2015 - Best development practices for GWT web applications
APIs Rest com NodeJS
(C)NodeJS
Apache Groovy: the language and the ecosystem
Building Rich Internet Applications Using Google Web Toolkit
An Introduction to Gradle for Java Developers
TypeScriptについて
Introduction to Griffon
Towards component based web UI with ReactJS
Introduction To Grails
Ad

Viewers also liked (9)

PDF
javerosmx-2015-marzo-groovy-java8-comparison
PDF
Intro a Grails @ ITESCA
DOCX
Antral small concept note
PPT
Grails敏捷项目开发
PDF
How To Make A Great Pbj
PDF
NFC and Commerce combined
PPTX
Introduction to Grails Framework
PDF
JVM Reactive Programming
PDF
Eclipsecon09 Introduction To Groovy
javerosmx-2015-marzo-groovy-java8-comparison
Intro a Grails @ ITESCA
Antral small concept note
Grails敏捷项目开发
How To Make A Great Pbj
NFC and Commerce combined
Introduction to Grails Framework
JVM Reactive Programming
Eclipsecon09 Introduction To Groovy
Ad

Similar to Groovy & Grails (20)

PDF
Groovy & Grails for Spring/Java developers
PDF
Grails紹介
ODP
Groovygrailsnetbeans 12517452668498-phpapp03
PDF
Grailsx@ロンドンへ行ってきた報告。
POT
intoduction to Grails Framework
PPT
Groovy & Grails: Scripting for Modern Web Applications
PDF
G*なクラウド 雲のかなたに ショートバージョン
PDF
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
PDF
Groovy - Grails as a modern scripting language for Web applications
PDF
Groovy and Grails
KEY
groovy & grails - lecture 9
KEY
Grails TV : an introduction into Grails & Groovy
PDF
G*ワークショップ in 仙台 Grails(とことん)入門
ODP
Grails 0.3-SNAPSHOT Presentation WJAX 2006 English
PDF
Grails 101
PDF
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
PPT
Grails Introduction - IJTC 2007
PDF
Groovy and Grails talk
PPT
Fast web development using groovy on grails
PPT
Introduction To Grails
Groovy & Grails for Spring/Java developers
Grails紹介
Groovygrailsnetbeans 12517452668498-phpapp03
Grailsx@ロンドンへ行ってきた報告。
intoduction to Grails Framework
Groovy & Grails: Scripting for Modern Web Applications
G*なクラウド 雲のかなたに ショートバージョン
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Groovy - Grails as a modern scripting language for Web applications
Groovy and Grails
groovy & grails - lecture 9
Grails TV : an introduction into Grails & Groovy
G*ワークショップ in 仙台 Grails(とことん)入門
Grails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 101
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
Grails Introduction - IJTC 2007
Groovy and Grails talk
Fast web development using groovy on grails
Introduction To Grails

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
sap open course for s4hana steps from ECC to s4
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Big Data Technologies - Introduction.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
DOCX
The AUB Centre for AI in Media Proposal.docx
Review of recent advances in non-invasive hemoglobin estimation
The Rise and Fall of 3GPP – Time for a Sabbatical?
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Encapsulation_ Review paper, used for researhc scholars
MYSQL Presentation for SQL database connectivity
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
sap open course for s4hana steps from ECC to s4
NewMind AI Weekly Chronicles - August'25 Week I
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
Big Data Technologies - Introduction.pptx
Network Security Unit 5.pdf for BCA BBA.
“AI and Expert System Decision Support & Business Intelligence Systems”
The AUB Centre for AI in Media Proposal.docx

Groovy & Grails

  • 1. Groovy & Grails Rain 2010-1-15
  • 4. How do we choose?
  • 5. Grails vs Rails Groovy vs Ruby API documentation better than Rails Solid frameworks underneath, such as spring, hibernate Both has a active community, Rails more popular, and more jobs, more books.
  • 6. Grails vs Rails DB Migrations GORM vs Active Record REST Webserver Faster than Rails, but used lot of memory, cheaper hosting Rails mature than Grails Rails release/update more often
  • 7. Groovy Groovy 是一种基于 JVM 的敏捷开发语言,它结合了 Python 、 Ruby 和 Smalltalk 的许多强大的特性。 支持 DSL 对于 Java 开发人员几乎没有学习难度 可以编译成字节码
  • 8. Hello Groovy def name='World'; println &quot;Hello $name!&quot;
  • 9. Groovy vs Java default imports closures native syntax for lists and maps GroovyMarkup and GPath support native support for regular expressions polymorphic iteration and powerful switch statement dynamic and static typing is supported - so you can omit the type declarations on methods, fields and variables you can embed expressions inside strings lots of new helper methods added to the JDK simpler syntax for writing  beans for both properties and adding event listeners safe navigation using the ?. operator, e.g. &quot;variable?.field&quot; and &quot;variable?.method()&quot; - no more nested ifs to check for null clogging up your code
  • 10. Default imports java.io.* java.lang.* java.math.BigDecimal java.math.BigInteger java.net.* java.util.* groovy.lang.* groovy.util.*
  • 11. Commons int[] a = {1,2,3}; -> int[] a = [1,2,3] for (int i=0; i < len; i++) {...} -> for (i in 0..len-1) {...} -> len.times {...}
  • 12. Others to know Semicolons are optional You can use the this keyword inside static methods The return keyword is optional The throws clause in a method signature is not checked by the Groovy compiler You will not get compile errors like you would in Java for using undefined members or passing arguments of the wrong type.
  • 13. Cloure square = { it * it } square(9) // 81 [ 1, 2, 3, 4 ].collect(square) // =[ 1, 4, 9, 16 ]
  • 14. Grails 快速 Web 开发框架 基于 Groovy 编程语言 构建于 Spring 、 Hibernate 和其它标准 Java 框架之上 高效的一站式框架
  • 15.  
  • 17. MVC Model : Domain class Person { String name } View : gsp 、 taglib Controller : XxxController class PersonController { def create = {} def save = {} def view = {} }
  • 18. Scaffold class XxxController { def scaffold = Domain }
  • 19. GORM CRUD : save 、 get 、 delete 、 list findBy* findAllBy* findWhere findAllWhere find(sql) count/countBy* exists list/listOrderBy withCriteria executeQuery(HSQL)
  • 20. Taglib if/else/elseif/while/set/collect/each/grep/findAll meta/header/cookie pageProperty/layoutHeader/layoutTitle/layoutBody/applyLayout resource/javascript/include/render textField/textArea/radio/checkBox/form/ remoteField/formRemote/remoteLink
  • 21. Service 在 grails-app/service 目录 命名约定 XxxService
  • 22. Testing unit Integration GroovyTestCase GrailsUnitTestCase GroovyPagesTestCase ControllerUnitTestCase TagLibUnitTestCase WebFlowTestCase
  • 23. Plugins Over 340 Security : Acegi 、 Shiro Ajax : Prototype 、 jQuery 、 YUI 、 GWT UI : GrailsUI 、 RichUI Report : Dynamic Jasper Jobs : Quartz Web 2.0: Feeds 、 Taggable 、 Commentable Workflow : grailsflow 、 jbpm Editor : FCKeditor
  • 24. Tools IDE: Eclipse 3.5 、 NetBeans 6.8 、 IDEA 9 、 Spring STS 2.3.0 Editor : E-Texteditor 、 Textmate 、 GEdit Build : Maven 、 Ant 、 Ivy WebContainer : Tomcat 、 Jetty Database : HSQL 、 MySQL GRAG
  • 25. Books
  • 26. Tutorials Mastering Grails @ IBM developerWorks Cookbook Tutorials Articles Twitter and Google Maps mashup in 20 minutes with Grails Securing a Grails application using Spring and Acegi Security A Grails-Powered Blog (Part 1) A Grails-Powered Blog (Part 2)
  • 27. Presentations http://grailspodcast.com/blog/list Grails JavaOne 2006 Slides Groovy & Grails Seminar Bending GORM: 5-minute Techniques for Enterprise Integration Grails 1.1 Testing - Unit, Integration, Functional (July 2009) Getting Started with Grails
  • 28. Roadmap Grails 1.3 support groovy 1.7 , standalone GSP , Deployment and resolution of plugins from Maven repositories Grails 2.0 modular deployment with OSGi
  • 29. App grails.org http://grails.org groovyblogs.org http://www.groovyblogs.org/ Weceem CMS http://www.weceem.org/ Groller http://code.google.com/p/rainboyan/
  • 30. Demo Grails HelloWorld: 1) grails create-app helloworld 2) grails create-controller hello 3) edit HelloController.groovy 4) create say.gsp 5) grails run-app
  • 31. Links http://www.grails.org http://www.grails.org/Tutorials http://www.jtict.com/blog/grails-vs-rails/ http://www.grails.org/GRAG
  • 32. QA ?