SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
  What
is
Grails
and
why
should
I
care?



  Building
on
Java’s
strengths



  The
Groovy
language


  A
tour
of
Grails



  Ancillary
tools
useful
in
Grails

              ©
2009
DevJam
‐
All
rights
reserved.


  Web
application
development
environment


  Built
on
the
Java
Platform

  Groovy
as
the
primary
language

    Java
can
also
be
used
and
intermixed
with
Groovy

    seamlessly

  Favors
Convention
over
Configuration

    Similar
in
spirit
to
Ruby
on
Rails




               ©
2009
DevJam
‐
All
rights
reserved.


  Java
web
development
can
be
tedious

  The
JVM,
class
libraries,
and
frameworks
are

   the
real
strength
of
the
Java
Platform

  Groovy
is
an
excellent
dynamic
language
for

   the
JVM

    Compiles
to
Java
bytecode
(.class
files)

  Favor
convention
over
configuration

    Grails
is
an
opinionated
framework

  Enhances
productivity

              ©
2009
DevJam
‐
All
rights
reserved.


  Built
on
top
of
the
Java
Virtual
Machine

    Maturity

    Optimization
and
performance

    Runtime
familiarity


  Integration
with
Java
applications



    Groovy
classes
are
Java
classes

    Reuse
what
works
from
traditional
Java
stack

     ▪  Java
EE:
Servlet
API,
JDBC,
JMS


     ▪  Hibernate,
Spring
Framework,
Spring
MVC,
SiteMesh

                 ©
2009
DevJam
‐
All
rights
reserved.


©
2009
DevJam
‐
All
rights
reserved.


  Hibernate


     Object/relational
mapping
(ORM)

  Spring
Framework

     Dependency
injection
services

     Application
lifecycle
facilities

  Spring
MVC

     Web
framework

  SiteMesh


     User
interface
layout
and
theming
facilities


               ©
2009
DevJam
‐
All
rights
reserved.


  Grails
convention
dictates…


    Where
components
reside
in
the
application

    How
the
component
is
named

    How
the
component
is
wired
and
collaborates

     with
other
application
components

    How
applications
can
be
extended
through
the

     use
of
third‐party
plugins




             ©
2009
DevJam
‐
All
rights
reserved.


  Standardized
configuration

     Log4j,
database
datasources

     Autowiring
and
dependency
injection
of

    components

  Standardized
build

     Gant
scripts

  Standardized
domain
model

     GORM
facilities
injected
into
domain
objects

  Standardized
services

     Automatic
transaction
support


              ©
2009
DevJam
‐
All
rights
reserved.


  Features
inspired
from
Python,
Ruby,
and

   Smalltalk

  Can
be
compiled
to
Java
bytecode

  Groovy
classes
are
Java
classes

    Groovy
can
seamlessly
use
Java
classes

    Java
can
seamlessly
use
Groovy
classes*

  Lots
of
new
languages
features

    GPath,
GString,
internal
iterators,
closures,
Meta‐
    Object
Protocol
(MOP),
and
many
others

              ©
2009
DevJam
‐
All
rights
reserved.


  JDBC
is
used
for
communicating
with

   databases

  HSQLDB:
default
datasource

  DataSource.groovy


    Configuration
of
DataSources
for
all
your

     environments

    Easy
to
switch
to
a
different
database,
even
across

     different
deployments



              ©
2009
DevJam
‐
All
rights
reserved.


  Domain
classes
are
central
to
a
Grails

   application

  Located
in
grails‐app/domain

  All
attributes
persistent
unless
marked
in
the


   transients
property

  No
getters
and
setters
necessary

  Validators:
specified
in
constraints
property

  GORM
mapping:
customized
in
the
mapping

   property

             ©
2009
DevJam
‐
All
rights
reserved.


  Grails
Object
Relational
Mapping

     Leverages
Hibernate

  Automatically
maps
domain
objects
to

   database

  Provides
query
and
update
facilities

    Finding
objects
in
the
persistence
store
(findBy…

     methods).

    Persistence
lifecycle
methods
(save,
update,

     delete).

    Criteria
and
HQL
query
facilities.

              ©
2009
DevJam
‐
All
rights
reserved.


  No
need
to
extend
a
common
persistent
base

  class

    Grails
injects
GORM
functionality
into
objects
at

    run‐time.

  Declare
properties
for
your
domain
objects


    The
id
or
version
properties
are
injected

     automatically.

    All
properties
are
not
null/required
by
default



              ©
2009
DevJam
‐
All
rights
reserved.


  Associations

    One‐to‐one,
one‐to‐many,
many‐to‐many

    Uni‐directional
and
bi‐directional


    Owners
defined
by
using
belongsTo
property

  Inheritance
hierarchies

    Table‐per‐hierarchy:
All
classes
map
to
a
single

     table

    Table‐per‐subclass:
Each
class
maps
to
its
own

     table
and
JOINs
are
used

              ©
2009
DevJam
‐
All
rights
reserved.


  Retrieving
objects

    get(), getAll(), read()
  Listing
objects

    list(), listOrderBy*() methods

    order, sort, offset, and
max
named

    arguments

  Dynamic
finders
(findBy*())

    Use
property
names
of
the
class

    Support
for
many
expressions
in
finder
method

              ©
2009
DevJam
‐
All
rights
reserved.


  Built
on
Hibernate’s
Criteria
API

  Groovy
builder
is
used
to
build
up
the
criteria

    Hierarchy
of
method
calls
and
closures
for

    building
tree‐like
structures

  Each
domain
class
has
a
createCriteria()

  method

    Call
get,
list,
scroll,
or
count
on
criteria

    The
criteria
builder
is
used
to
restrict
the
query

  Supports
associations
and
projections

               ©
2009
DevJam
‐
All
rights
reserved.


  Support
for
Hibernate
Query
Language

   find(hql), findAll(hql), and

    executeQuery(hql) for
queries

   executeUpdate(hql)
for
DML‐style

    opera3ons
(sets
of
updates
or
deletes)

   Support
for
positional
and
named
parameters





            ©
2009
DevJam
‐
All
rights
reserved.


  Handles
HTTP
requests
and
determines

   rendering
responsibility

  Many
objects
are
available
to
your
controller

   closures

    log,
params,
request,
response,
session,

    servletContext,
flash

  Interceptors
on
a
controller

    beforeInterceptor
and
afterInterceptor
closures



             ©
2009
DevJam
‐
All
rights
reserved.


File
upload/multipart
requests

 
       Automatic
binding
to
domain
objects

       <g:uploadForm />
     Binary
response
writing

 
       response.outputStream


       response.contentType
       Overloaded
<<
operator
to
append
content

     Request
InputStream
reading

 
       def incomingText =
                      request.inputStream.text

                 ©
2009
DevJam
‐
All
rights
reserved.


  Built
upon
Spring’s
validation
framework

    org.springframework.validation
package

  Domain
objects
have
validation
baked
in

    save()
and
validate()
methods
trigger
validation

    Validation
errors
populate
errors
property
on

    domain
object

  Errors

    Interrogate
the
domain
object
instance

    hasErrors()
method
and
errors
property

              ©
2009
DevJam
‐
All
rights
reserved.


  Similar
to
JSPs

  Utilizes
GPath
and
GStrings
and
other
cool

   Groovy
language
features

  Automatic
discovery
of
Grails
taglibs

  Support
for
templates

    Small
snippets
of
view
code
that
other
views
can

     use

    Useful
for
AJAX
responses



              ©
2009
DevJam
‐
All
rights
reserved.


  Grails
ships
with
a
standard
set
of
taglibs

     Iteration,
filtering,
switching,
logical
taglibs

     HTML
markup
creation:
links,
forms,
form
fields,

     date
picker

    Validation
error
checking
and
rendering

    Paginating
views

    View
template
rendering
(reusable
sub‐views)

  Custom
taglibs
are
easy

     Groovy
class
with
a
TagLib
suffix
and
resides
in

    grails‐app/taglib
directory

              ©
2009
DevJam
‐
All
rights
reserved.


  Grails
uses
Prototype
library
by
default           


    Easily
changed
to
another
JavaScript
provider

   through
Grails
plugin
system

  Grails
taglibs
insulate
you
from
the
raw

  JavaScript

    Remote
links,
remote
forms,
remote
form
fields,

   before
and
after
callbacks,
event
handling,
effects,

   animations



             ©
2009
DevJam
‐
All
rights
reserved.


  Grails
has
built‐in
support
for
managing

   message
bundles,
locales

  Message
files
are
managed
in
the
grails‐app/
   i18n
directory

  Grails
taglib
can
be
used
to
retrieve
messages

   from
message
bundles

    Supports
parameterized
messaging

  Support
for
special
URL
mappings
to
support

  encoding
locale
information
in
the
URI

             ©
2009
DevJam
‐
All
rights
reserved.


  Allows
for
centralization
of
application

  behavior

    Necessary
component
in
any
non‐trivial
Grails

    application

  Transactional
by
default,
set
through
the

   transactional
property

  Use
the
expose
property
to
expose
a
service

   via
remoting
to
other
processes

    Use
with
various
remoting
plugins

              ©
2009
DevJam
‐
All
rights
reserved.


  Reflection
and
the
Groovy
MetaClass

are

   used
to
scaffold
CRUD
functionality

  Enable
in
the
controller
class…


class UserController {

    def scaffold = User
    …
}


            ©
2009
DevJam
‐
All
rights
reserved.


  Extension
mechanism
for
integrating
third‐
   party
functionality

  About
80
or
so
plugins
today
and
many
more

   coming
on
board

    AJAX,
JavaScript,
Flex/Flash,
UI
widgets

    Security,
Crypto,
CAPTCHA,
CAS

    Database
migration,
code
coverage,
functional

     testing

    Many
others…find
at
grails.org/plugin/list

              ©
2009
DevJam
‐
All
rights
reserved.


  Swing
GUI
console

  Allows
execution
of
arbitrary
Groovy

   statements

  Your
Grails
domain
model
is
accessible
in
this

   environment

    GORM
facilities
are
available

    Great
way
to
tinker
and
play
with
your
domain

    object
model


              ©
2009
DevJam
‐
All
rights
reserved.


  Eclipse

    Plugin
available,
but
the
story
is
not
good
at
the

    moment

  NetBeans

    Groovy
and
Grails
support
in
version
6.5

  IntelliJ
IDEA

    JetGroovy
plugin
by
JetBrains
offers
good
support

     for
Grails

    Seems
to
be
the
leader
at
the
moment

               ©
2009
DevJam
‐
All
rights
reserved.


  Take
Grails
on
a
test
drive!

     grails.org

  Books

     Groovy
in
Action

     The
Definitive
Guide
to
Grails,
Second
Edition

     Beginning
Groovy
and
Grails

     Grails
in
Action

     Groovy
and
Grails
Recipes

     Grails
Persistence
with
GORM
and
GSQL


                  ©
2009
DevJam
‐
All
rights
reserved.


Coaching
and
Developing
Agility



          www.devjam.com




    ©
2009
DevJam
‐
All
rights
reserved.



Contenu connexe

Similaire à Grails Overview

Inside Picnik: How We Built Picnik (and What We Learned Along the Way)
Inside Picnik: How We Built Picnik (and What We Learned Along the Way)Inside Picnik: How We Built Picnik (and What We Learned Along the Way)
Inside Picnik: How We Built Picnik (and What We Learned Along the Way)jjhuff
 
UW ADC - Course 3 - Class 1 - User Stories And Acceptance Testing
UW ADC - Course 3 - Class 1 - User Stories And Acceptance TestingUW ADC - Course 3 - Class 1 - User Stories And Acceptance Testing
UW ADC - Course 3 - Class 1 - User Stories And Acceptance TestingChris Sterling
 
GIPA
GIPAGIPA
GIPAESUG
 
Roll-out of the NYU HSL Website and Drupal CMS
Roll-out of the NYU HSL Website and Drupal CMSRoll-out of the NYU HSL Website and Drupal CMS
Roll-out of the NYU HSL Website and Drupal CMSChris Evjy
 
The Yahoo Open Stack
The Yahoo Open StackThe Yahoo Open Stack
The Yahoo Open StackMegan Eskey
 
Building


















 Terrier by
 Open
 Collaboration
Building


















 Terrier by
 Open
 CollaborationBuilding


















 Terrier by
 Open
 Collaboration
Building


















 Terrier by
 Open
 CollaborationCrai Macdonald
 
Sapo BUS Hands-On
Sapo BUS Hands-OnSapo BUS Hands-On
Sapo BUS Hands-Oncodebits
 
Fedora App Slide 2009 Hastac
Fedora App Slide 2009 HastacFedora App Slide 2009 Hastac
Fedora App Slide 2009 HastacLoretta Auvil
 
Yakov Fain - Design Patterns a Deep Dive
Yakov Fain - Design Patterns a Deep DiveYakov Fain - Design Patterns a Deep Dive
Yakov Fain - Design Patterns a Deep Dive360|Conferences
 
The Lean Startup at Web 2.0 Expo
The Lean Startup at Web 2.0 ExpoThe Lean Startup at Web 2.0 Expo
The Lean Startup at Web 2.0 ExpoVenture Hacks
 
Understanding Customer Choice May 09 Rwg
Understanding Customer Choice May 09 RwgUnderstanding Customer Choice May 09 Rwg
Understanding Customer Choice May 09 Rwgandyh47
 
2009 05 01 How To Build A Lean Startup Step By Step
2009 05 01 How To Build A Lean Startup Step By Step2009 05 01 How To Build A Lean Startup Step By Step
2009 05 01 How To Build A Lean Startup Step By StepEric Ries
 
How To Create An Interactive Keynote
How To Create An Interactive KeynoteHow To Create An Interactive Keynote
How To Create An Interactive KeynoteJacqui Sharp
 
HA+DRBD+Postgres - PostgresWest '08
HA+DRBD+Postgres - PostgresWest '08HA+DRBD+Postgres - PostgresWest '08
HA+DRBD+Postgres - PostgresWest '08Jesse Young
 

Similaire à Grails Overview (20)

Mobile Marketing Forum - MOOGA
Mobile Marketing Forum - MOOGAMobile Marketing Forum - MOOGA
Mobile Marketing Forum - MOOGA
 
Inside Picnik: How We Built Picnik (and What We Learned Along the Way)
Inside Picnik: How We Built Picnik (and What We Learned Along the Way)Inside Picnik: How We Built Picnik (and What We Learned Along the Way)
Inside Picnik: How We Built Picnik (and What We Learned Along the Way)
 
UW ADC - Course 3 - Class 1 - User Stories And Acceptance Testing
UW ADC - Course 3 - Class 1 - User Stories And Acceptance TestingUW ADC - Course 3 - Class 1 - User Stories And Acceptance Testing
UW ADC - Course 3 - Class 1 - User Stories And Acceptance Testing
 
GIPA
GIPAGIPA
GIPA
 
From Work To Word
From Work To WordFrom Work To Word
From Work To Word
 
Roll-out of the NYU HSL Website and Drupal CMS
Roll-out of the NYU HSL Website and Drupal CMSRoll-out of the NYU HSL Website and Drupal CMS
Roll-out of the NYU HSL Website and Drupal CMS
 
The Yahoo Open Stack
The Yahoo Open StackThe Yahoo Open Stack
The Yahoo Open Stack
 
Building


















 Terrier by
 Open
 Collaboration
Building


















 Terrier by
 Open
 CollaborationBuilding


















 Terrier by
 Open
 Collaboration
Building


















 Terrier by
 Open
 Collaboration
 
Rich Web Clients 20081118
Rich Web Clients 20081118Rich Web Clients 20081118
Rich Web Clients 20081118
 
Sapo BUS Hands-On
Sapo BUS Hands-OnSapo BUS Hands-On
Sapo BUS Hands-On
 
HTML Parsing With Hpricot
HTML Parsing With HpricotHTML Parsing With Hpricot
HTML Parsing With Hpricot
 
Fedora App Slide 2009 Hastac
Fedora App Slide 2009 HastacFedora App Slide 2009 Hastac
Fedora App Slide 2009 Hastac
 
Yakov Fain - Design Patterns a Deep Dive
Yakov Fain - Design Patterns a Deep DiveYakov Fain - Design Patterns a Deep Dive
Yakov Fain - Design Patterns a Deep Dive
 
The Lean Startup at Web 2.0 Expo
The Lean Startup at Web 2.0 ExpoThe Lean Startup at Web 2.0 Expo
The Lean Startup at Web 2.0 Expo
 
Cutbots - Presentation
Cutbots - PresentationCutbots - Presentation
Cutbots - Presentation
 
A new King has rise "The mobile phone"
A new King has rise "The mobile phone"A new King has rise "The mobile phone"
A new King has rise "The mobile phone"
 
Understanding Customer Choice May 09 Rwg
Understanding Customer Choice May 09 RwgUnderstanding Customer Choice May 09 Rwg
Understanding Customer Choice May 09 Rwg
 
2009 05 01 How To Build A Lean Startup Step By Step
2009 05 01 How To Build A Lean Startup Step By Step2009 05 01 How To Build A Lean Startup Step By Step
2009 05 01 How To Build A Lean Startup Step By Step
 
How To Create An Interactive Keynote
How To Create An Interactive KeynoteHow To Create An Interactive Keynote
How To Create An Interactive Keynote
 
HA+DRBD+Postgres - PostgresWest '08
HA+DRBD+Postgres - PostgresWest '08HA+DRBD+Postgres - PostgresWest '08
HA+DRBD+Postgres - PostgresWest '08
 

Plus de Christopher Bartling

JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma Christopher Bartling
 
Acceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmAcceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmChristopher Bartling
 
JavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaJavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaChristopher Bartling
 
Acceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsAcceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsChristopher Bartling
 
iPhone OS: The Next Killer Platform
iPhone OS: The Next Killer PlatformiPhone OS: The Next Killer Platform
iPhone OS: The Next Killer PlatformChristopher Bartling
 

Plus de Christopher Bartling (11)

JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma
 
Acceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvmAcceptance Test-driven Development with Cucumber-jvm
Acceptance Test-driven Development with Cucumber-jvm
 
JavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and KarmaJavaScript TDD with Jasmine and Karma
JavaScript TDD with Jasmine and Karma
 
Building Tropo Apps with Grails
Building Tropo Apps with GrailsBuilding Tropo Apps with Grails
Building Tropo Apps with Grails
 
CoffeeScript By Example
CoffeeScript By ExampleCoffeeScript By Example
CoffeeScript By Example
 
Acceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And FriendsAcceptance Test Driven Development With Spec Flow And Friends
Acceptance Test Driven Development With Spec Flow And Friends
 
Introduction To Grails
Introduction To GrailsIntroduction To Grails
Introduction To Grails
 
Cucumber, Cuke4Duke, and Groovy
Cucumber, Cuke4Duke, and GroovyCucumber, Cuke4Duke, and Groovy
Cucumber, Cuke4Duke, and Groovy
 
Test Driven In Groovy
Test Driven In GroovyTest Driven In Groovy
Test Driven In Groovy
 
iPhone OS: The Next Killer Platform
iPhone OS: The Next Killer PlatformiPhone OS: The Next Killer Platform
iPhone OS: The Next Killer Platform
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 

Grails Overview

  • 1.
  • 2.   What
is
Grails
and
why
should
I
care?
   Building
on
Java’s
strengths
   The
Groovy
language
   A
tour
of
Grails
   Ancillary
tools
useful
in
Grails
 ©
2009
DevJam
‐
All
rights
reserved.


  • 3.   Web
application
development
environment

   Built
on
the
Java
Platform
   Groovy
as
the
primary
language
   Java
can
also
be
used
and
intermixed
with
Groovy
 seamlessly
   Favors
Convention
over
Configuration
   Similar
in
spirit
to
Ruby
on
Rails
 ©
2009
DevJam
‐
All
rights
reserved.


  • 4.   Java
web
development
can
be
tedious
   The
JVM,
class
libraries,
and
frameworks
are
 the
real
strength
of
the
Java
Platform
   Groovy
is
an
excellent
dynamic
language
for
 the
JVM
   Compiles
to
Java
bytecode
(.class
files)
   Favor
convention
over
configuration
   Grails
is
an
opinionated
framework
   Enhances
productivity
 ©
2009
DevJam
‐
All
rights
reserved.


  • 5.   Built
on
top
of
the
Java
Virtual
Machine
   Maturity
   Optimization
and
performance
   Runtime
familiarity

   Integration
with
Java
applications


   Groovy
classes
are
Java
classes
   Reuse
what
works
from
traditional
Java
stack
 ▪  Java
EE:
Servlet
API,
JDBC,
JMS

 ▪  Hibernate,
Spring
Framework,
Spring
MVC,
SiteMesh
 ©
2009
DevJam
‐
All
rights
reserved.


  • 7.   Hibernate

   Object/relational
mapping
(ORM)
   Spring
Framework
   Dependency
injection
services
   Application
lifecycle
facilities
   Spring
MVC
   Web
framework
   SiteMesh

   User
interface
layout
and
theming
facilities
 ©
2009
DevJam
‐
All
rights
reserved.


  • 8.   Grails
convention
dictates…

   Where
components
reside
in
the
application
   How
the
component
is
named
   How
the
component
is
wired
and
collaborates
 with
other
application
components
   How
applications
can
be
extended
through
the
 use
of
third‐party
plugins
 ©
2009
DevJam
‐
All
rights
reserved.


  • 9.   Standardized
configuration
   Log4j,
database
datasources
   Autowiring
and
dependency
injection
of
 components
   Standardized
build
   Gant
scripts
   Standardized
domain
model
   GORM
facilities
injected
into
domain
objects
   Standardized
services
   Automatic
transaction
support

 ©
2009
DevJam
‐
All
rights
reserved.


  • 10.   Features
inspired
from
Python,
Ruby,
and
 Smalltalk
   Can
be
compiled
to
Java
bytecode
   Groovy
classes
are
Java
classes
   Groovy
can
seamlessly
use
Java
classes
   Java
can
seamlessly
use
Groovy
classes*
   Lots
of
new
languages
features
   GPath,
GString,
internal
iterators,
closures,
Meta‐ Object
Protocol
(MOP),
and
many
others
 ©
2009
DevJam
‐
All
rights
reserved.


  • 11.   JDBC
is
used
for
communicating
with
 databases
   HSQLDB:
default
datasource
   DataSource.groovy

   Configuration
of
DataSources
for
all
your
 environments
   Easy
to
switch
to
a
different
database,
even
across
 different
deployments
 ©
2009
DevJam
‐
All
rights
reserved.


  • 12.   Domain
classes
are
central
to
a
Grails
 application
   Located
in
grails‐app/domain
   All
attributes
persistent
unless
marked
in
the

 transients
property
   No
getters
and
setters
necessary
   Validators:
specified
in
constraints
property
   GORM
mapping:
customized
in
the
mapping
 property
 ©
2009
DevJam
‐
All
rights
reserved.


  • 13.   Grails
Object
Relational
Mapping
   Leverages
Hibernate
   Automatically
maps
domain
objects
to
 database
   Provides
query
and
update
facilities
   Finding
objects
in
the
persistence
store
(findBy…
 methods).
   Persistence
lifecycle
methods
(save,
update,
 delete).
   Criteria
and
HQL
query
facilities.
 ©
2009
DevJam
‐
All
rights
reserved.


  • 14.   No
need
to
extend
a
common
persistent
base
 class
   Grails
injects
GORM
functionality
into
objects
at
 run‐time.
   Declare
properties
for
your
domain
objects

   The
id
or
version
properties
are
injected
 automatically.
   All
properties
are
not
null/required
by
default
 ©
2009
DevJam
‐
All
rights
reserved.


  • 15.   Associations
   One‐to‐one,
one‐to‐many,
many‐to‐many
   Uni‐directional
and
bi‐directional

   Owners
defined
by
using
belongsTo
property
   Inheritance
hierarchies
   Table‐per‐hierarchy:
All
classes
map
to
a
single
 table
   Table‐per‐subclass:
Each
class
maps
to
its
own
 table
and
JOINs
are
used
 ©
2009
DevJam
‐
All
rights
reserved.


  • 16.   Retrieving
objects
   get(), getAll(), read()   Listing
objects
   list(), listOrderBy*() methods
   order, sort, offset, and
max
named
 arguments
   Dynamic
finders
(findBy*())
   Use
property
names
of
the
class
   Support
for
many
expressions
in
finder
method
 ©
2009
DevJam
‐
All
rights
reserved.


  • 17.   Built
on
Hibernate’s
Criteria
API
   Groovy
builder
is
used
to
build
up
the
criteria
   Hierarchy
of
method
calls
and
closures
for
 building
tree‐like
structures
   Each
domain
class
has
a
createCriteria()
 method
   Call
get,
list,
scroll,
or
count
on
criteria
   The
criteria
builder
is
used
to
restrict
the
query
   Supports
associations
and
projections
 ©
2009
DevJam
‐
All
rights
reserved.


  • 18.   Support
for
Hibernate
Query
Language
   find(hql), findAll(hql), and
 executeQuery(hql) for
queries
   executeUpdate(hql)
for
DML‐style
 opera3ons
(sets
of
updates
or
deletes)
   Support
for
positional
and
named
parameters
 ©
2009
DevJam
‐
All
rights
reserved.


  • 19.   Handles
HTTP
requests
and
determines
 rendering
responsibility
   Many
objects
are
available
to
your
controller
 closures
   log,
params,
request,
response,
session,
 servletContext,
flash
   Interceptors
on
a
controller
   beforeInterceptor
and
afterInterceptor
closures
 ©
2009
DevJam
‐
All
rights
reserved.


  • 20. File
upload/multipart
requests
     Automatic
binding
to
domain
objects
   <g:uploadForm /> Binary
response
writing
     response.outputStream

   response.contentType   Overloaded
<<
operator
to
append
content
 Request
InputStream
reading
     def incomingText = request.inputStream.text ©
2009
DevJam
‐
All
rights
reserved.


  • 21.   Built
upon
Spring’s
validation
framework
   org.springframework.validation
package
   Domain
objects
have
validation
baked
in
   save()
and
validate()
methods
trigger
validation
   Validation
errors
populate
errors
property
on
 domain
object
   Errors
   Interrogate
the
domain
object
instance
   hasErrors()
method
and
errors
property
 ©
2009
DevJam
‐
All
rights
reserved.


  • 22.   Similar
to
JSPs
   Utilizes
GPath
and
GStrings
and
other
cool
 Groovy
language
features
   Automatic
discovery
of
Grails
taglibs
   Support
for
templates
   Small
snippets
of
view
code
that
other
views
can
 use
   Useful
for
AJAX
responses
 ©
2009
DevJam
‐
All
rights
reserved.


  • 23.   Grails
ships
with
a
standard
set
of
taglibs
   Iteration,
filtering,
switching,
logical
taglibs
   HTML
markup
creation:
links,
forms,
form
fields,
 date
picker
   Validation
error
checking
and
rendering
   Paginating
views
   View
template
rendering
(reusable
sub‐views)
   Custom
taglibs
are
easy
   Groovy
class
with
a
TagLib
suffix
and
resides
in
 grails‐app/taglib
directory
 ©
2009
DevJam
‐
All
rights
reserved.


  • 24.   Grails
uses
Prototype
library
by
default 

   Easily
changed
to
another
JavaScript
provider
 through
Grails
plugin
system
   Grails
taglibs
insulate
you
from
the
raw
 JavaScript
   Remote
links,
remote
forms,
remote
form
fields,
 before
and
after
callbacks,
event
handling,
effects,
 animations
 ©
2009
DevJam
‐
All
rights
reserved.


  • 25.   Grails
has
built‐in
support
for
managing
 message
bundles,
locales
   Message
files
are
managed
in
the
grails‐app/ i18n
directory
   Grails
taglib
can
be
used
to
retrieve
messages
 from
message
bundles
   Supports
parameterized
messaging
   Support
for
special
URL
mappings
to
support
 encoding
locale
information
in
the
URI
 ©
2009
DevJam
‐
All
rights
reserved.


  • 26.   Allows
for
centralization
of
application
 behavior
   Necessary
component
in
any
non‐trivial
Grails
 application
   Transactional
by
default,
set
through
the
 transactional
property
   Use
the
expose
property
to
expose
a
service
 via
remoting
to
other
processes
   Use
with
various
remoting
plugins
 ©
2009
DevJam
‐
All
rights
reserved.


  • 27.   Reflection
and
the
Groovy
MetaClass

are
 used
to
scaffold
CRUD
functionality
   Enable
in
the
controller
class…
 class UserController { def scaffold = User … } ©
2009
DevJam
‐
All
rights
reserved.


  • 28.   Extension
mechanism
for
integrating
third‐ party
functionality
   About
80
or
so
plugins
today
and
many
more
 coming
on
board
   AJAX,
JavaScript,
Flex/Flash,
UI
widgets
   Security,
Crypto,
CAPTCHA,
CAS
   Database
migration,
code
coverage,
functional
 testing
   Many
others…find
at
grails.org/plugin/list
 ©
2009
DevJam
‐
All
rights
reserved.


  • 29.   Swing
GUI
console
   Allows
execution
of
arbitrary
Groovy
 statements
   Your
Grails
domain
model
is
accessible
in
this
 environment
   GORM
facilities
are
available
   Great
way
to
tinker
and
play
with
your
domain
 object
model
 ©
2009
DevJam
‐
All
rights
reserved.


  • 30.   Eclipse
   Plugin
available,
but
the
story
is
not
good
at
the
 moment
   NetBeans
   Groovy
and
Grails
support
in
version
6.5
   IntelliJ
IDEA
   JetGroovy
plugin
by
JetBrains
offers
good
support
 for
Grails
   Seems
to
be
the
leader
at
the
moment
 ©
2009
DevJam
‐
All
rights
reserved.


  • 31.   Take
Grails
on
a
test
drive!
   grails.org
   Books
   Groovy
in
Action
   The
Definitive
Guide
to
Grails,
Second
Edition
   Beginning
Groovy
and
Grails
   Grails
in
Action
   Groovy
and
Grails
Recipes
   Grails
Persistence
with
GORM
and
GSQL
 ©
2009
DevJam
‐
All
rights
reserved.


  • 32. Coaching
and
Developing
Agility
 www.devjam.com
 ©
2009
DevJam
‐
All
rights
reserved.