Grails Overview
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share

Grails Overview

  • 2,703 views
Uploaded on

Overview of Grails, a Groovy and Java based web development platform.

Overview of Grails, a Groovy and Java based web development platform.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,703
On Slideshare
2,693
From Embeds
10
Number of Embeds
4

Actions

Shares
Downloads
87
Comments
0
Likes
2

Embeds 10

http://www.linkedin.com 6
https://www.linkedin.com 2
http://www.slideshare.net 1
http://www.slideee.com 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1.   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.


  • 2.   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.


  • 3.   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.


  • 4.   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.


  • 5. ©
2009
DevJam
‐
All
rights
reserved.


  • 6.   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.


  • 7.   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.


  • 8.   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.


  • 9.   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.


  • 10.   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.


  • 11.   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.


  • 12.   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.


  • 13.   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.


  • 14.   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.


  • 15.   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.


  • 16.   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.


  • 17.   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.


  • 18.   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.


  • 19. 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.


  • 20.   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.


  • 21.   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.


  • 22.   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.


  • 23.   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.


  • 24.   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.


  • 25.   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.


  • 26.   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.


  • 27.   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.


  • 28.   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.


  • 29.   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.


  • 30.   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.


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