SlideShare a Scribd company logo
1 of 27
Download to read offline
Groovy And Grails
Harshad Oak
Rightrix Solutions
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Groovy Basics
• Scripting / Agile / Dynamic ...Language
• Syntax very close to Java
• Meant for Java developers.
• A powerful high level language for the Java
“platform”
• Groovy code Compiles to Java bytecode.
• You can get productive quickly
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Groovy Basics
• Open source using a BSD / Apache style licence
• Backed by JSR 241
• groovy.codehaus.org
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Groovy Installation
• Download binary
• Set GROOVY_HOME
• Add GROOVY_HOME/bin to your PATH
• Set JAVA_HOME
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Groovy with Java
• Use groovyc just like javac to produce bytecode
files
• Groovy integrates with the Bean Scripting
Framework, which allows you to embed any
scripting engine into your Java code
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Closures
• Closures are reusable blocks of code
• One or more program statements enclosed in
curly brackets
• Closures do not require a class or a method
name
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Closures
• Can be passed around like a variable
• The statements within a closure are not
executed until the call() is made
• Return is using an explicit return statement or
the value of the last executed statement
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Dynamic Methods
• Adding new methods to an object at runtime
• Intercept non-existent method calls
• Used extensively in Grails
• Meta-Object Protocol
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Groovy Features
• Language Constructs
• List & Maps support
• XML Capabilities
• Swing Capabilities
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Groovlets and GSP
• Groovy alternatives for Servlets and JSP
• Will work on any J2EE container.
• Add JAR files
• Tweak web.xml
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Groovlets and GSP
• Implicit Variables
• request ServletRequest
• response ServletResponse -
• context ServletContext
• application ServletContext
• session getSession(false)
• out response.getWriter()
• sout response.getOutputStream()
• html new MarkupBuilder(out)
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails
• Web Framework inspired by Ruby On Rails
• Latest version is 0.2.1
• Coding by convention paradigm
• Reduce the need for configuration files and
other boilerplate code
• File names are important
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails
• Provides several commands to auto generate
common requirements in a web app.
• Based on open source technologies like Spring,
Hibernate and SiteMesh
• Grails hides underlying complexity
• Focus is on rapid development and simplicity
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails Installation
• Extract contents
• Set GRAILS_HOME environment variable
• Add GRAILS_HOMEbin to the PATH variable
• Run the grails command from the command
prompt to check usage
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails Application Structure
Controllers
Domain Classes
Views
Normal J2EE web
application
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
GORM
• Domain Classes are objects that are mapped to
the database
• Uses Hibernate 3 underneath
• Link domain classes using relationships
• Provide powerful dynamic methods for CRUD
(Create/Read/Update/Delete) operations
• An HSQL database comes built-in with Grails
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails Development
• Example -Develop a Clothes Manager web
application
• Use MySQL database
•Setup DB
•Setup ApplicationDataSource
• Create Domain Classes
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails Development - Domain
Classes
• Create Domain Classes
• Cabinet.groovy
• Shirt.groovy
• Trouser.groovy
• Define relationships
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails Development
-Controllers
• Controllers are responsible for handling the
requests in the web application
• Use grails -generate-all to generate controllers
for our 3 domain classes
• Once controller is done processing a request, it
has to delegate to an appropriate view
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails Development -Views
• Controllers delegate to view based on a
convention mechanism
• So list closure in ShirtController will delegate to
the view /grails-app/views/shirt/list.gsp or
/grails-app/views/shirt/list.jsp.
• Note that you can use JSPs
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails Development -Deploy
• Built in Resin server
• Directly run your application by using the grails
run-app command
• Lets use Tomcat instead
• WAR file creation using grails war
• Deploy the WAR file just like any other J2EE
WAR file
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails Custom View and
Controller
• Grails currently only auto generates views based
on a domain class
• Manually create a new view
• Edit web.xml for mapping the new view
• Deploy and try out on Tomcat
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails Services
• Services are named in the format
XXService.groovy
• Directory /grails-app/services
• Can have Business Logic
• You can call these services from within
controllers
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails Tags
• Range of tags for both GSPs and JSPs
• No configuration
• No updating of TLD descriptors
• Edit grails-apptaglibApplicationTagLib.groovy
or create a new file XXTagLib.groovy
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails - Ajax
• Can work with Prototype, Yahoo or Dojo
• Configure the library and then just use the grails
tags
• Use render method to send text, markup, JSON
or OpenRico responses
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Grails
• Testing
• IDE Integration
• Validation
Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06
Thank You
• Further Reading
• groovy.codehaus.org
• grails.org
• Several books in the works
• Groovy in Action (Manning)
• Groovy Programming: An Introduction for Java
Developers (Morgan Kaufmann)
Harshad Oak - harshad@rightrix.com

More Related Content

What's hot

IPWB and IPFS at WAC2017
IPWB and IPFS at WAC2017IPWB and IPFS at WAC2017
IPWB and IPFS at WAC2017David Dias
 
Semantics, rdf and drupal
Semantics, rdf and drupalSemantics, rdf and drupal
Semantics, rdf and drupalGokul Nk
 
Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Stefan Adolf
 
Serverless Big Data Architecture on Google Cloud Platform at Credit OK
Serverless Big Data Architecture on Google Cloud Platform at Credit OKServerless Big Data Architecture on Google Cloud Platform at Credit OK
Serverless Big Data Architecture on Google Cloud Platform at Credit OKKriangkrai Chaonithi
 
Integrating Drupal with a Triple Store
Integrating Drupal with a Triple StoreIntegrating Drupal with a Triple Store
Integrating Drupal with a Triple StoreBarry Norton
 
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...Restlet
 
MongoDB SF Python
MongoDB SF PythonMongoDB SF Python
MongoDB SF PythonMike Dirolf
 
Synchronization with CouchDB and PouchDB
Synchronization with CouchDB and PouchDBSynchronization with CouchDB and PouchDB
Synchronization with CouchDB and PouchDBEU Edge
 
MongoDB and MongoMK Source Event
MongoDB and MongoMK Source EventMongoDB and MongoMK Source Event
MongoDB and MongoMK Source EventYuval Ararat
 
Object data manager Tutorials
Object data manager TutorialsObject data manager Tutorials
Object data manager Tutorialsjivandip7
 
Scaling Redis: Dmitry Polyakovsky
Scaling Redis: Dmitry PolyakovskyScaling Redis: Dmitry Polyakovsky
Scaling Redis: Dmitry PolyakovskyRedis Labs
 
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?ArangoDB Database
 
Neo4j tms
Neo4j tmsNeo4j tms
Neo4j tms_mdev_
 
Getting Started with Riak - NoSQL Live 2010 - Boston
Getting Started with Riak - NoSQL Live 2010 - BostonGetting Started with Riak - NoSQL Live 2010 - Boston
Getting Started with Riak - NoSQL Live 2010 - BostonRusty Klophaus
 
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
Living with SQL and NoSQL at craigslist, a Pragmatic ApproachLiving with SQL and NoSQL at craigslist, a Pragmatic Approach
Living with SQL and NoSQL at craigslist, a Pragmatic ApproachJeremy Zawodny
 
Last Month in PHP - December 2015
Last Month in PHP - December 2015Last Month in PHP - December 2015
Last Month in PHP - December 2015Eric Poe
 
Batch import of large RDF datasets into Semantic MediaWiki
Batch import of large RDF datasets into Semantic MediaWikiBatch import of large RDF datasets into Semantic MediaWiki
Batch import of large RDF datasets into Semantic MediaWikiSamuel Lampa
 
Introduction to RethinkDB and Horizon.js
Introduction to RethinkDB and Horizon.jsIntroduction to RethinkDB and Horizon.js
Introduction to RethinkDB and Horizon.jschuck h
 

What's hot (20)

IPWB and IPFS at WAC2017
IPWB and IPFS at WAC2017IPWB and IPFS at WAC2017
IPWB and IPFS at WAC2017
 
Semantics, rdf and drupal
Semantics, rdf and drupalSemantics, rdf and drupal
Semantics, rdf and drupal
 
Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019Gatsby (Code.Talks) 2019
Gatsby (Code.Talks) 2019
 
Serverless Big Data Architecture on Google Cloud Platform at Credit OK
Serverless Big Data Architecture on Google Cloud Platform at Credit OKServerless Big Data Architecture on Google Cloud Platform at Credit OK
Serverless Big Data Architecture on Google Cloud Platform at Credit OK
 
Integrating Drupal with a Triple Store
Integrating Drupal with a Triple StoreIntegrating Drupal with a Triple Store
Integrating Drupal with a Triple Store
 
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
Cassandra Summit 2015 - Building a multi-tenant API PaaS with DataStax Enterp...
 
MongoDB SF Python
MongoDB SF PythonMongoDB SF Python
MongoDB SF Python
 
Synchronization with CouchDB and PouchDB
Synchronization with CouchDB and PouchDBSynchronization with CouchDB and PouchDB
Synchronization with CouchDB and PouchDB
 
MongoDB and MongoMK Source Event
MongoDB and MongoMK Source EventMongoDB and MongoMK Source Event
MongoDB and MongoMK Source Event
 
Intro ror
Intro rorIntro ror
Intro ror
 
Object data manager Tutorials
Object data manager TutorialsObject data manager Tutorials
Object data manager Tutorials
 
Scaling Redis: Dmitry Polyakovsky
Scaling Redis: Dmitry PolyakovskyScaling Redis: Dmitry Polyakovsky
Scaling Redis: Dmitry Polyakovsky
 
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
gVisor, Kata Containers, Firecracker, Docker: Who is Who in the Container Space?
 
Neo4j tms
Neo4j tmsNeo4j tms
Neo4j tms
 
Getting Started with Riak - NoSQL Live 2010 - Boston
Getting Started with Riak - NoSQL Live 2010 - BostonGetting Started with Riak - NoSQL Live 2010 - Boston
Getting Started with Riak - NoSQL Live 2010 - Boston
 
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
Living with SQL and NoSQL at craigslist, a Pragmatic ApproachLiving with SQL and NoSQL at craigslist, a Pragmatic Approach
Living with SQL and NoSQL at craigslist, a Pragmatic Approach
 
Last Month in PHP - December 2015
Last Month in PHP - December 2015Last Month in PHP - December 2015
Last Month in PHP - December 2015
 
Batch import of large RDF datasets into Semantic MediaWiki
Batch import of large RDF datasets into Semantic MediaWikiBatch import of large RDF datasets into Semantic MediaWiki
Batch import of large RDF datasets into Semantic MediaWiki
 
Yace 3.0
Yace 3.0Yace 3.0
Yace 3.0
 
Introduction to RethinkDB and Horizon.js
Introduction to RethinkDB and Horizon.jsIntroduction to RethinkDB and Horizon.js
Introduction to RethinkDB and Horizon.js
 

Viewers also liked

Viewers also liked (7)

Median kanssa kasvamassa
Median kanssa kasvamassaMedian kanssa kasvamassa
Median kanssa kasvamassa
 
Navarro fdz elena_gb_ing
Navarro fdz elena_gb_ingNavarro fdz elena_gb_ing
Navarro fdz elena_gb_ing
 
career options
career optionscareer options
career options
 
Aquest soc jo
Aquest soc joAquest soc jo
Aquest soc jo
 
William’s workshops
William’s workshopsWilliam’s workshops
William’s workshops
 
Een serie
Een serieEen serie
Een serie
 
Part 1
Part 1Part 1
Part 1
 

Similar to Groovy grailstutorial

Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013Gavin Hogan
 
GlusterFS Containers
GlusterFS ContainersGlusterFS Containers
GlusterFS ContainersMohamed Ashiq
 
Fast web development using groovy on grails
Fast web development using groovy on grailsFast web development using groovy on grails
Fast web development using groovy on grailsAnshuman Biswal
 
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011Gaelyk update - Guillaume Laforge - SpringOne2GX 2011
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011Guillaume Laforge
 
Gaelyk - JFokus 2011 - Guillaume Laforge
Gaelyk - JFokus 2011 - Guillaume LaforgeGaelyk - JFokus 2011 - Guillaume Laforge
Gaelyk - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
intoduction to Grails Framework
intoduction to Grails Frameworkintoduction to Grails Framework
intoduction to Grails FrameworkHarshdeep Kaur
 
Devoxx - The Groovy Ecosystem
Devoxx - The Groovy EcosystemDevoxx - The Groovy Ecosystem
Devoxx - The Groovy EcosystemAndres Almiray
 
Rapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for JavaRapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for JavaKunal Dabir
 
Grails 101
Grails 101Grails 101
Grails 101Lim Kin
 
Greach 2014 - Road to Grails 3.0
Greach 2014  - Road to Grails 3.0Greach 2014  - Road to Grails 3.0
Greach 2014 - Road to Grails 3.0graemerocher
 
FOSDEM '18 - Tools for large scale collection and analysis of source code re...
FOSDEM '18  - Tools for large scale collection and analysis of source code re...FOSDEM '18  - Tools for large scale collection and analysis of source code re...
FOSDEM '18 - Tools for large scale collection and analysis of source code re...seoul_engineer
 
GraalVM and Oracle's Documentation Trends.pdf
GraalVM and Oracle's Documentation Trends.pdfGraalVM and Oracle's Documentation Trends.pdf
GraalVM and Oracle's Documentation Trends.pdfohupalo
 
Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gatesStrannik_2013
 

Similar to Groovy grailstutorial (20)

Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013
 
Gluster containers!
Gluster containers!Gluster containers!
Gluster containers!
 
GlusterFS Containers
GlusterFS ContainersGlusterFS Containers
GlusterFS Containers
 
Fast web development using groovy on grails
Fast web development using groovy on grailsFast web development using groovy on grails
Fast web development using groovy on grails
 
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011Gaelyk update - Guillaume Laforge - SpringOne2GX 2011
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011
 
Gaelyk - JFokus 2011 - Guillaume Laforge
Gaelyk - JFokus 2011 - Guillaume LaforgeGaelyk - JFokus 2011 - Guillaume Laforge
Gaelyk - JFokus 2011 - Guillaume Laforge
 
intoduction to Grails Framework
intoduction to Grails Frameworkintoduction to Grails Framework
intoduction to Grails Framework
 
Devoxx - The Groovy Ecosystem
Devoxx - The Groovy EcosystemDevoxx - The Groovy Ecosystem
Devoxx - The Groovy Ecosystem
 
Rapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for JavaRapid Application Development on Google App Engine for Java
Rapid Application Development on Google App Engine for Java
 
Groovy and noteworthy
Groovy and noteworthyGroovy and noteworthy
Groovy and noteworthy
 
Grails 101
Grails 101Grails 101
Grails 101
 
GraphQL-ify your APIs
GraphQL-ify your APIsGraphQL-ify your APIs
GraphQL-ify your APIs
 
Polyglot Grails
Polyglot GrailsPolyglot Grails
Polyglot Grails
 
Greach 2014 - Road to Grails 3.0
Greach 2014  - Road to Grails 3.0Greach 2014  - Road to Grails 3.0
Greach 2014 - Road to Grails 3.0
 
FOSDEM '18 - Tools for large scale collection and analysis of source code re...
FOSDEM '18  - Tools for large scale collection and analysis of source code re...FOSDEM '18  - Tools for large scale collection and analysis of source code re...
FOSDEM '18 - Tools for large scale collection and analysis of source code re...
 
GraalVM and Oracle's Documentation Trends.pdf
GraalVM and Oracle's Documentation Trends.pdfGraalVM and Oracle's Documentation Trends.pdf
GraalVM and Oracle's Documentation Trends.pdf
 
Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gates
 
Spring boot
Spring bootSpring boot
Spring boot
 
GWT-Basics
GWT-BasicsGWT-Basics
GWT-Basics
 
GWT-Basics
GWT-BasicsGWT-Basics
GWT-Basics
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
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
 
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
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
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
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
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
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
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
 
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 ...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Groovy grailstutorial

  • 1. Groovy And Grails Harshad Oak Rightrix Solutions
  • 2. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Groovy Basics • Scripting / Agile / Dynamic ...Language • Syntax very close to Java • Meant for Java developers. • A powerful high level language for the Java “platform” • Groovy code Compiles to Java bytecode. • You can get productive quickly
  • 3. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Groovy Basics • Open source using a BSD / Apache style licence • Backed by JSR 241 • groovy.codehaus.org
  • 4. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Groovy Installation • Download binary • Set GROOVY_HOME • Add GROOVY_HOME/bin to your PATH • Set JAVA_HOME
  • 5. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Groovy with Java • Use groovyc just like javac to produce bytecode files • Groovy integrates with the Bean Scripting Framework, which allows you to embed any scripting engine into your Java code
  • 6. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Closures • Closures are reusable blocks of code • One or more program statements enclosed in curly brackets • Closures do not require a class or a method name
  • 7. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Closures • Can be passed around like a variable • The statements within a closure are not executed until the call() is made • Return is using an explicit return statement or the value of the last executed statement
  • 8. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Dynamic Methods • Adding new methods to an object at runtime • Intercept non-existent method calls • Used extensively in Grails • Meta-Object Protocol
  • 9. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Groovy Features • Language Constructs • List & Maps support • XML Capabilities • Swing Capabilities
  • 10. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Groovlets and GSP • Groovy alternatives for Servlets and JSP • Will work on any J2EE container. • Add JAR files • Tweak web.xml
  • 11. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Groovlets and GSP • Implicit Variables • request ServletRequest • response ServletResponse - • context ServletContext • application ServletContext • session getSession(false) • out response.getWriter() • sout response.getOutputStream() • html new MarkupBuilder(out)
  • 12. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails • Web Framework inspired by Ruby On Rails • Latest version is 0.2.1 • Coding by convention paradigm • Reduce the need for configuration files and other boilerplate code • File names are important
  • 13. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails • Provides several commands to auto generate common requirements in a web app. • Based on open source technologies like Spring, Hibernate and SiteMesh • Grails hides underlying complexity • Focus is on rapid development and simplicity
  • 14. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails Installation • Extract contents • Set GRAILS_HOME environment variable • Add GRAILS_HOMEbin to the PATH variable • Run the grails command from the command prompt to check usage
  • 15. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails Application Structure Controllers Domain Classes Views Normal J2EE web application
  • 16. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 GORM • Domain Classes are objects that are mapped to the database • Uses Hibernate 3 underneath • Link domain classes using relationships • Provide powerful dynamic methods for CRUD (Create/Read/Update/Delete) operations • An HSQL database comes built-in with Grails
  • 17. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails Development • Example -Develop a Clothes Manager web application • Use MySQL database •Setup DB •Setup ApplicationDataSource • Create Domain Classes
  • 18. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails Development - Domain Classes • Create Domain Classes • Cabinet.groovy • Shirt.groovy • Trouser.groovy • Define relationships
  • 19. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails Development -Controllers • Controllers are responsible for handling the requests in the web application • Use grails -generate-all to generate controllers for our 3 domain classes • Once controller is done processing a request, it has to delegate to an appropriate view
  • 20. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails Development -Views • Controllers delegate to view based on a convention mechanism • So list closure in ShirtController will delegate to the view /grails-app/views/shirt/list.gsp or /grails-app/views/shirt/list.jsp. • Note that you can use JSPs
  • 21. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails Development -Deploy • Built in Resin server • Directly run your application by using the grails run-app command • Lets use Tomcat instead • WAR file creation using grails war • Deploy the WAR file just like any other J2EE WAR file
  • 22. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails Custom View and Controller • Grails currently only auto generates views based on a domain class • Manually create a new view • Edit web.xml for mapping the new view • Deploy and try out on Tomcat
  • 23. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails Services • Services are named in the format XXService.groovy • Directory /grails-app/services • Can have Business Logic • You can call these services from within controllers
  • 24. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails Tags • Range of tags for both GSPs and JSPs • No configuration • No updating of TLD descriptors • Edit grails-apptaglibApplicationTagLib.groovy or create a new file XXTagLib.groovy
  • 25. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails - Ajax • Can work with Prototype, Yahoo or Dojo • Configure the library and then just use the grails tags • Use render method to send text, markup, JSON or OpenRico responses
  • 26. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Grails • Testing • IDE Integration • Validation
  • 27. Harshad Oak - Groovy and Grails Tutorial - 17th Aug 06 Thank You • Further Reading • groovy.codehaus.org • grails.org • Several books in the works • Groovy in Action (Manning) • Groovy Programming: An Introduction for Java Developers (Morgan Kaufmann) Harshad Oak - harshad@rightrix.com