SlideShare a Scribd company logo
1 of 25
Introduction to Grails
By Avi Perez
 Groovy at Glance
◦ Features
◦ Data Types
◦ Closures
◦ Advance Examples
 Grails
 Demo
Outline
◦ Agile and Dynamic language
◦ JVM bounded – compiled to java byte code
◦ Increase productivity
 Java developers - almost-zero learning curve
 Simplifies testing
 Reducing scaffolding code
◦ Current version 2.0
◦ performance issues
Groovy at Glance
Intoduction
 Semicolons are optional. Use them if you like
(though you must use them to put several
statements on one line).
 The return keyword is optional.
 Methods and classes are public by default.
 Inner classes use closures instead.
Groovy at Glance
Intoduction
 The throws clause in a method signature is
not checked by the Groovy compiler, because
there is no difference between checked and
unchecked exceptions
 Groovy supports regular expressions natively
Groovy at Glance
Intoduction
 Lists:
◦ def list= [9, 4, 2, 10, 5]
◦ assert list.max() == 10
◦ assert list.min() == 2
◦ assert [6,3,9,2,7,1,5].sort() == [1,2,3,5,6,7,9]
◦ assert [1,2,3].reverse() == [3,2,1]
◦ assert 5..8 == [5,6,7,8]
◦ assert ('a'..'g')[ 3..5 ] == ['d','e','f']
 Dates Formats:
◦ def date = new Date().parse('yyyy/MM/dd', '1973/07/09')
Groovy at Glance
Hands on…
 Maps
◦ def family = [dad:"John" , mom:"Jane", son:"John"]
◦ GPath notation
 def x = [ ['a':11, 'b':12], ['a':21, 'b':22] ]
assert x.a == [11, 21]
 assert [ 'a', 7, 'b', [2,3] ].groupBy{ it.class } ==
[ (String.class): ['a', 'b'], (Integer.class): [ 7 ], (ArrayList.class): [[2,3]] ]
Groovy at Glance
Intoduction
 Closures
◦ a "code block" or a method pointer that is defined and then
executed at a later point
◦ Simple Examples
 def clos = { println “Hey Groovy!" }
clos() //prints “Hey Groovy!“
 def closure = { param -> param + 1 }
def answer = [1, 2].collect(closure)
assert answer == [2, 3]
Groovy at Glance
Intoduction
 Methods returning
def geocode(String location)
{
// implementation
return [48.824068, 2.531733] //for Paris, France
}
def (lat, long) = geocode("Paris, France")
assert lat == 48.824068 assert long == 2.531733
 Safe navigation
◦ def foo = null
◦ def bar = foo?.something?.myMethod()
Groovy at Glance
Hands on…
 Regular Expressions support
 Extracting Hashtags from twitter:
◦ def val=“Every time #Israel is attacked their land expands, but they have not yet
received all the land #God promised them http://tinyurl.com/2fr96y6”
◦ def hashTags = val.findAll("#[A-Za-z0-9_]+")
Groovy at Glance
Hands on…
 Constructing Objects
Class Expando{
def name
def location
def id
}
def bean = new Expando(name:"James", location:"London", id:123)
Groovy at Glance
Hands on…
 File IO
◦ Text
def fileContent = new File(fileName).text
◦ EachLine
Nik.txt
My name is Ayush.
But you can call me Nik.
I am fully devoted to Java and want to something extra for java
def number=new File ('Nik.txt').eachLine {
line -> number++
println "$number: $line"
Groovy at Glance
Hands on…
 static def CAR_RECORDS = ''' <records>
 <car name="HSV Maloo" make="Holden" year="2006">
 <country>Australia</country>
 <record type="speed">Production Pickup Truck with speed of
271kph</record>
 </car>
 <car name="P50" make="Peel" year="1962">
 <country>Isle of Man</country>
 <record type="size">Smallest Street-Legal Car at 99cm wide and 59 kg in
weight</record>
 </car>
 <car name="Royale" make="Bugatti" year="1931">
 <country>France</country>
 <record type="price">Most Valuable Car at $15 million</record>
 </car>
 </records> '''
Groovy at Glance
Hands on…
 XML Parsing XmlSluper (Similar to JSON parsing
JSONSluper() )
def records = new
XmlSlurper().parseText(XmlExamples.CAR_RECORDS)
◦ All Elements:
def allRecords = records.car
◦ Counting children:
assert 3 == allRecords.size() def allNodes =
records.depthFirst().collect{ it }
Groovy at Glance
Hands on…
 Groovy at Glance
◦ Features
◦ Data Types
◦ Closures
◦ Advance Examples
 Grails
 Demo
Outline
 Grails
◦ Open source web application platform
◦ Convention over Configuration
 Any grails application looks the same
 No need for XML mapping files
◦ Powerful MVC framework
 Power by Spring and Hibernate
 Model / Domain Layer
 View Layer (GSP)
 Controller
Introduction Grails
Introduction Grails
Grails Architecture
 Convention over configuration
◦ Domains – Model layer
◦ Controller – Controller layer
◦ Views – Groovy server pages
◦ Taglib – Dynamic Tag libararies
◦ Services – Service layer
◦ Conf – all configuration sources
◦ I18n
Introduction Grails
Grails Architecture
 POGO
 GORM Support
Introduction Grails
Models….
Introduction Grails
Controllers….
Introduction Grails
Services….
Introduction Grails
Testing….
 conf/DataSource.groovy
◦ Data Base Connections
 conf/UrlMapping.groovy
◦ Web application rounting
 conf/Config.groovy
◦ General configurations(mime mapping,logging)
 conf/BuildConfig.groovy
◦ Ivymaven dependencies
Introduction Grails
Configurations….
 Groovy at Glance
◦ Features
◦ Data Types
◦ Closures
◦ Advance Examples
 Grails
 Demo
Outline

More Related Content

What's hot

Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersKirk Kimmel
 
2018-06-06 @nuxtjs/auth with Django Rest Framework
2018-06-06 @nuxtjs/auth with Django Rest Framework2018-06-06 @nuxtjs/auth with Django Rest Framework
2018-06-06 @nuxtjs/auth with Django Rest FrameworkRyo Nagaoka
 
Using the Command Line with Magento
Using the Command Line with MagentoUsing the Command Line with Magento
Using the Command Line with MagentoMatthew Haworth
 
Vi INFOTECH shell-scripting_syllabus
Vi INFOTECH shell-scripting_syllabusVi INFOTECH shell-scripting_syllabus
Vi INFOTECH shell-scripting_syllabusViINFOTECH
 
Linux fundamental - Chap 00 shell
Linux fundamental - Chap 00 shellLinux fundamental - Chap 00 shell
Linux fundamental - Chap 00 shellKenny (netman)
 
Parboiled explained
Parboiled explainedParboiled explained
Parboiled explainedPaul Popoff
 
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingAsynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingSteve Rhoades
 
Embedding Groovy in a Java Application
Embedding Groovy in a Java ApplicationEmbedding Groovy in a Java Application
Embedding Groovy in a Java ApplicationPaolo Predonzani
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part AKazuchika Sekiya
 
Closures for Java
Closures for JavaClosures for Java
Closures for Javanextlib
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Apache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemApache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemKostas Saidis
 
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hourDevoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hourAnton Arhipov
 

What's hot (20)

Virtual domains
Virtual domainsVirtual domains
Virtual domains
 
Perl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one linersPerl - laziness, impatience, hubris, and one liners
Perl - laziness, impatience, hubris, and one liners
 
2018-06-06 @nuxtjs/auth with Django Rest Framework
2018-06-06 @nuxtjs/auth with Django Rest Framework2018-06-06 @nuxtjs/auth with Django Rest Framework
2018-06-06 @nuxtjs/auth with Django Rest Framework
 
nginx mod PSGI
nginx mod PSGInginx mod PSGI
nginx mod PSGI
 
Using the Command Line with Magento
Using the Command Line with MagentoUsing the Command Line with Magento
Using the Command Line with Magento
 
Swift Study #7
Swift Study #7Swift Study #7
Swift Study #7
 
Vi INFOTECH shell-scripting_syllabus
Vi INFOTECH shell-scripting_syllabusVi INFOTECH shell-scripting_syllabus
Vi INFOTECH shell-scripting_syllabus
 
Linux fundamental - Chap 00 shell
Linux fundamental - Chap 00 shellLinux fundamental - Chap 00 shell
Linux fundamental - Chap 00 shell
 
Parboiled explained
Parboiled explainedParboiled explained
Parboiled explained
 
Asynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time MessagingAsynchronous PHP and Real-time Messaging
Asynchronous PHP and Real-time Messaging
 
Embedding Groovy in a Java Application
Embedding Groovy in a Java ApplicationEmbedding Groovy in a Java Application
Embedding Groovy in a Java Application
 
お題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part Aお題でGroovyプログラミング: Part A
お題でGroovyプログラミング: Part A
 
Tesbv
TesbvTesbv
Tesbv
 
Closures for Java
Closures for JavaClosures for Java
Closures for Java
 
Os Secoske
Os SecoskeOs Secoske
Os Secoske
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Bash Scripting Workshop
Bash Scripting WorkshopBash Scripting Workshop
Bash Scripting Workshop
 
Apache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemApache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystem
 
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hourDevoxx Ukraine 2018 - Kotlin DSL in under an hour
Devoxx Ukraine 2018 - Kotlin DSL in under an hour
 
Codable routing
Codable routingCodable routing
Codable routing
 

Similar to Introduction to Grails

GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume LaforgeGR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume LaforgeGR8Conf
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneAndres Almiray
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Wsloffenauer
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyJames Williams
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingAndres Almiray
 
Social harvesting - Webbots
Social harvesting - WebbotsSocial harvesting - Webbots
Social harvesting - WebbotsAvi Perez
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGuillaume Laforge
 
LISA QooxdooTutorial Slides
LISA QooxdooTutorial SlidesLISA QooxdooTutorial Slides
LISA QooxdooTutorial SlidesTobias Oetiker
 
Learning groovy -EU workshop
Learning groovy  -EU workshopLearning groovy  -EU workshop
Learning groovy -EU workshopadam1davis
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for JavaCharles Anderson
 
Groovy for Java Developers
Groovy for Java DevelopersGroovy for Java Developers
Groovy for Java DevelopersAndres Almiray
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebMikel Torres Ugarte
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoRodolfo Carvalho
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyAndres Almiray
 
Groovy and Grails talk
Groovy and Grails talkGroovy and Grails talk
Groovy and Grails talkdesistartups
 
LISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsLISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsTobias Oetiker
 

Similar to Introduction to Grails (20)

GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume LaforgeGR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
 
Groovy.pptx
Groovy.pptxGroovy.pptx
Groovy.pptx
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
OpenLogic
OpenLogicOpenLogic
OpenLogic
 
Boosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with GroovyBoosting Your Testing Productivity with Groovy
Boosting Your Testing Productivity with Groovy
 
Javaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 GroovytestingJavaone2008 Bof 5101 Groovytesting
Javaone2008 Bof 5101 Groovytesting
 
Social harvesting - Webbots
Social harvesting - WebbotsSocial harvesting - Webbots
Social harvesting - Webbots
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
 
Clojure And Swing
Clojure And SwingClojure And Swing
Clojure And Swing
 
LISA QooxdooTutorial Slides
LISA QooxdooTutorial SlidesLISA QooxdooTutorial Slides
LISA QooxdooTutorial Slides
 
Learning groovy -EU workshop
Learning groovy  -EU workshopLearning groovy  -EU workshop
Learning groovy -EU workshop
 
Groovy!
Groovy!Groovy!
Groovy!
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for Java
 
Groovy for Java Developers
Groovy for Java DevelopersGroovy for Java Developers
Groovy for Java Developers
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo Web
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
 
GTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with GroovyGTAC Boosting your Testing Productivity with Groovy
GTAC Boosting your Testing Productivity with Groovy
 
Groovy and Grails talk
Groovy and Grails talkGroovy and Grails talk
Groovy and Grails talk
 
LISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial HandoutsLISA Qooxdoo Tutorial Handouts
LISA Qooxdoo Tutorial Handouts
 

Recently uploaded

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Recently uploaded (20)

Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Introduction to Grails

  • 2.  Groovy at Glance ◦ Features ◦ Data Types ◦ Closures ◦ Advance Examples  Grails  Demo Outline
  • 3. ◦ Agile and Dynamic language ◦ JVM bounded – compiled to java byte code ◦ Increase productivity  Java developers - almost-zero learning curve  Simplifies testing  Reducing scaffolding code ◦ Current version 2.0 ◦ performance issues Groovy at Glance Intoduction
  • 4.  Semicolons are optional. Use them if you like (though you must use them to put several statements on one line).  The return keyword is optional.  Methods and classes are public by default.  Inner classes use closures instead. Groovy at Glance Intoduction
  • 5.  The throws clause in a method signature is not checked by the Groovy compiler, because there is no difference between checked and unchecked exceptions  Groovy supports regular expressions natively Groovy at Glance Intoduction
  • 6.  Lists: ◦ def list= [9, 4, 2, 10, 5] ◦ assert list.max() == 10 ◦ assert list.min() == 2 ◦ assert [6,3,9,2,7,1,5].sort() == [1,2,3,5,6,7,9] ◦ assert [1,2,3].reverse() == [3,2,1] ◦ assert 5..8 == [5,6,7,8] ◦ assert ('a'..'g')[ 3..5 ] == ['d','e','f']  Dates Formats: ◦ def date = new Date().parse('yyyy/MM/dd', '1973/07/09') Groovy at Glance Hands on…
  • 7.  Maps ◦ def family = [dad:"John" , mom:"Jane", son:"John"] ◦ GPath notation  def x = [ ['a':11, 'b':12], ['a':21, 'b':22] ] assert x.a == [11, 21]  assert [ 'a', 7, 'b', [2,3] ].groupBy{ it.class } == [ (String.class): ['a', 'b'], (Integer.class): [ 7 ], (ArrayList.class): [[2,3]] ] Groovy at Glance Intoduction
  • 8.  Closures ◦ a "code block" or a method pointer that is defined and then executed at a later point ◦ Simple Examples  def clos = { println “Hey Groovy!" } clos() //prints “Hey Groovy!“  def closure = { param -> param + 1 } def answer = [1, 2].collect(closure) assert answer == [2, 3] Groovy at Glance Intoduction
  • 9.  Methods returning def geocode(String location) { // implementation return [48.824068, 2.531733] //for Paris, France } def (lat, long) = geocode("Paris, France") assert lat == 48.824068 assert long == 2.531733  Safe navigation ◦ def foo = null ◦ def bar = foo?.something?.myMethod() Groovy at Glance Hands on…
  • 10.  Regular Expressions support  Extracting Hashtags from twitter: ◦ def val=“Every time #Israel is attacked their land expands, but they have not yet received all the land #God promised them http://tinyurl.com/2fr96y6” ◦ def hashTags = val.findAll("#[A-Za-z0-9_]+") Groovy at Glance Hands on…
  • 11.  Constructing Objects Class Expando{ def name def location def id } def bean = new Expando(name:"James", location:"London", id:123) Groovy at Glance Hands on…
  • 12.  File IO ◦ Text def fileContent = new File(fileName).text ◦ EachLine Nik.txt My name is Ayush. But you can call me Nik. I am fully devoted to Java and want to something extra for java def number=new File ('Nik.txt').eachLine { line -> number++ println "$number: $line" Groovy at Glance Hands on…
  • 13.  static def CAR_RECORDS = ''' <records>  <car name="HSV Maloo" make="Holden" year="2006">  <country>Australia</country>  <record type="speed">Production Pickup Truck with speed of 271kph</record>  </car>  <car name="P50" make="Peel" year="1962">  <country>Isle of Man</country>  <record type="size">Smallest Street-Legal Car at 99cm wide and 59 kg in weight</record>  </car>  <car name="Royale" make="Bugatti" year="1931">  <country>France</country>  <record type="price">Most Valuable Car at $15 million</record>  </car>  </records> ''' Groovy at Glance Hands on…
  • 14.  XML Parsing XmlSluper (Similar to JSON parsing JSONSluper() ) def records = new XmlSlurper().parseText(XmlExamples.CAR_RECORDS) ◦ All Elements: def allRecords = records.car ◦ Counting children: assert 3 == allRecords.size() def allNodes = records.depthFirst().collect{ it } Groovy at Glance Hands on…
  • 15.  Groovy at Glance ◦ Features ◦ Data Types ◦ Closures ◦ Advance Examples  Grails  Demo Outline
  • 16.  Grails ◦ Open source web application platform ◦ Convention over Configuration  Any grails application looks the same  No need for XML mapping files ◦ Powerful MVC framework  Power by Spring and Hibernate  Model / Domain Layer  View Layer (GSP)  Controller Introduction Grails
  • 18.  Convention over configuration ◦ Domains – Model layer ◦ Controller – Controller layer ◦ Views – Groovy server pages ◦ Taglib – Dynamic Tag libararies ◦ Services – Service layer ◦ Conf – all configuration sources ◦ I18n Introduction Grails Grails Architecture
  • 19.  POGO  GORM Support Introduction Grails Models….
  • 23.  conf/DataSource.groovy ◦ Data Base Connections  conf/UrlMapping.groovy ◦ Web application rounting  conf/Config.groovy ◦ General configurations(mime mapping,logging)  conf/BuildConfig.groovy ◦ Ivymaven dependencies Introduction Grails Configurations….
  • 24.
  • 25.  Groovy at Glance ◦ Features ◦ Data Types ◦ Closures ◦ Advance Examples  Grails  Demo Outline