Más contenido relacionado
Similar a Grails Overview (20)
Más de Christopher Bartling (11)
Grails Overview
- 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.
- 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.
- 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.
- 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.
- 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.