2. Content
What is Grails?
Why full stack?
What is Groovy?
Grails vs Rails
Groovy vs Java
Testing in Grails
Examples
3. Grails ( on Rails) is an
Open Source,
full stack,
web application framework for the Java Virtual
Machine.
It uses the Groovy programming language which
is an
agile, object oriented & dynamic programming
language
for the Java Virtual Machine.
What is Grails?
4. What is Grails?
Rapid Web Application Development Framework
For the JVM,
Inspired by Ruby on Rails, Django and others.
5. What is Grails?
Convention over Configuration (CoC),
Don’t Repeat Yourself (DRY).
7. How Grails is full stack
framework?-1
Normally when you build applications, you
need…
Database management (ORM)
Presentation (User Interface)
Service Layer
Configuration
Grails will provide you functionality to all
those areas so you don't need to look for a
set of frameworks, just use one.
8. Grails attempts to solve as many pieces of
the web development puzzle through the core
technology and its associated plug-ins.
An easy to use Object Relational Mapping
(ORM) layer built on Hibernate,
An expressive view technology called Groovy
Server Pages (GSP),
A controller layer built on Spring MVC,
How Grails is full stack
framework?-2
9. A controller layer built on Spring
MVC?
Basic controller logic,
Data binding and validation,
Runtime configurations,
Transactions.
10. A command line scripting environment built on
the Groovy-powered Gant,
An embedded Tomcat container which is
configured for on the fly reloading,
Dependency injection with the inbuilt Spring
container,
How Grails is full stack
framework?-3
11. Support for internationalization (i18n) built on
Spring's core MessageSource concept,
A transactional service layer built on Spring's
transaction abstraction.
How Grails is full stack
framework?-4
12. All of these are
made easy to use
through the power of
the Groovy language
and the extensive use
of
Domain Specific
Languages (DSLs)
Why full stack?
14. What is Groovy?
Groovy is an object-oriented programming
language for the Java platform.
It is a dynamic language with features similar
to those of Python, Ruby, Perl, and Smalltalk.
It can be used as a scripting language for the
Java Platform, is dynamically compiled to Java
Virtual Machine (JVM).
16. Grails vs Rails - 1
Groovy vs Ruby
API documentation better than Rails
Solid frameworks underneath, such as spring,
hibernate
Both has a active community, Rails more
popular, and more jobs, more books.
17. Grails vs Rails - 2
DB Migrations
GORM vs Active Record
REST
Faster than Rails, but used lot of memory,
cheaper hosting
Rails mature than Grails
Rails release/update more often
20. Groovy vs Java - 2
Closures
Native syntax for lists and maps
GroovyMarkup and GPath support
Native support for regular expressions
Polymorphic iteration and powerful switch
statement
Dynamic and static typing is supported - so
you can omit the type declarations on methods,
fields and variables
def clos = { println "hello!" }
clos() //prints "hello!"
21. In Java:
for (int i=0; i < len; i++) {...}
In Groovy
for (i in 0..len-1) {...} or
for (i in 0..<len) {...} or
len.times {...}.
Groovy vs Java - 3
22. 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. You can use
the this keyword inside static methods (which
refers to this class).
Methods and classes are public by default.
Protected in Groovy has the same meaning as
protected in Java.
Groovy vs Java - 4
25. Testing
Integration
To execute the JUnit integration tests you can
run:
grails test-app integration:integration
Unit
The following command will run all test types
in the
unit phase:
grails test-app unit:
26. Testing - Spock
Spock is a testing and specification framework
for Java and Groovy applications.
What makes it stand out from the crowd is its
beautiful and highly expressive specification
language.
This plug-in brings the power of Spock to
Grails.
grails test-app :spock
27. To run the all of the spock tests in the functional
phase you would run.
grails test-app functional:spock
More than one pattern can be specified.
grails test-app unit:spock integration:spock
Test and type/phase targetting can be applied at
the same time:
grails test-app integration: unit: some.org.**.*
(This would run all tests in the integration and unit
phases
that are in the package some.org or a subpackage.)
Testing - Spock
29. GGTS
The Groovy/Grails Tool Suite provides the best
Eclipse-powered development environment for
building Groovy and Grails applications.
GGTS provides support for the latest versions
of Groovy and Grails, and comes on top of the
latest Eclipse releases.
35. Summary
Grails is built on proven & solid OSS bricks
Spring: IoC, DI, Spring MVC, transactions…
Hibernate: ORM, querying mechanism
Groovy: for everything that matters
SiteMesh: page layout and composition
Quartz: for job scheduling
AJAX: integration with different libraries
Jetty & HSQLDB: for fast development cycles
36. Has it got to be complex?
But it’s slow to start with
Seting up the project takes time
It gets complicated pretty rapidly
Dive into Spring & Hibernate to wire
everything together
There are so many layers
DAOs, DTOs, more abstraction
layers
Too many configuration files
Often too much XML for everything
Struts / Spring / Hibernate is okay…