GRAILS
Ezgi AYVAZOGLUApril 2014 - IZMIR
Content
 What is Grails?
 Why full stack?
 What is Groovy?
 Grails vs Rails
 Groovy vs Java
 Testing in Grails
 Exa...
Grails ( on Rails) is an
 Open Source,
 full stack,
 web application framework for the Java Virtual
Machine.
It uses th...
What is Grails?
Rapid Web Application Development Framework
 For the JVM,
 Inspired by Ruby on Rails, Django and others.
What is Grails?
 Convention over Configuration (CoC),
 Don’t Repeat Yourself (DRY).
Grails Architecture
How Grails is full stack
framework?-1
Normally when you build applications, you
need…
 Database management (ORM)
 Presen...
Grails attempts to solve as many pieces of
the web development puzzle through the core
technology and its associated plug-...
A controller layer built on Spring
MVC?
 Basic controller logic,
 Data binding and validation,
 Runtime configurations,...
 A command line scripting environment built on
the Groovy-powered Gant,
 An embedded Tomcat container which is
configure...
 Support for internationalization (i18n) built on
Spring's core MessageSource concept,
 A transactional service layer bu...
 All of these are
made easy to use
through the power of
the Groovy language
and the extensive use
of
Domain Specific
Lang...
Groovy
What is Groovy?
 Groovy is an object-oriented programming
language for the Java platform.
 It is a dynamic language with...
Grails vs Rails
Grails vs Rails - 1
 Groovy vs Ruby
 API documentation better than Rails
 Solid frameworks underneath, such as spring,
...
Grails vs Rails - 2
 DB Migrations
 GORM vs Active Record
 REST
 Faster than Rails, but used lot of memory,
cheaper ho...
Groovy vs Java
Default imports
 java.io.*
 java.lang.*
 java.math.BigDecimal
 java.math.BigInteger
 java.net.*
 java.util.*
 groov...
Groovy vs Java - 2
 Closures
 Native syntax for lists and maps
 GroovyMarkup and GPath support
 Native support for reg...
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....
 Semicolons are optional. Use them if you like
(though you must use them to put several
statements on one line).
 The re...
Groovy vs Java - 5
Testing
Testing
 Integration
To execute the JUnit integration tests you can
run:
grails test-app integration:integration
 Unit
T...
Testing - Spock
 Spock is a testing and specification framework
for Java and Groovy applications.
 What makes it stand o...
 To run the all of the spock tests in the functional
phase you would run.
grails test-app functional:spock
 More than on...
Tools
 IDE: GGTS, Eclipse 3.5、NetBeans 6.8、
IDEA 9、Spring STS 2.3.0
 Editor:E-Texteditor、Textmate、GEdit
 Build:Maven、An...
GGTS
 The Groovy/Grails Tool Suite provides the best
Eclipse-powered development environment for
building Groovy and Grai...
GGTS
Demo
Grails gTunes:
1) grails create-app gTunes
2) grails create-controller store
3) edit StoreController.groovy
4) write ...
Demo
http://localhost:8080/gTunes/
Examples
 http://www.nowtv.com/
 https://wwws.citruslane.com/#index
 http://www.vodafone.co.uk/
 http://grails.org/
 ...
Summary
=
+
+
Summary
 Grails is built on proven & solid OSS bricks
 Spring: IoC, DI, Spring MVC, transactions…
 Hibernate: ORM, quer...
Has it got to be complex?
 But it’s slow to start with
 Seting up the project takes time
 It gets complicated pretty ra...
Thank You
Any question
Ezgi AYVAZOGLU
Upcoming SlideShare
Loading in …5
×

Introduction to Grails (Groovy vs Java and Grails vs Rails are included)

2,657 views
2,370 views

Published on

Introduction to Grails , Groovs vs Java, Grails vs Rails

Published in: Software, Technology
1 Comment
3 Likes
Statistics
Notes
No Downloads
Views
Total views
2,657
On SlideShare
0
From Embeds
0
Number of Embeds
29
Actions
Shares
0
Downloads
61
Comments
1
Likes
3
Embeds 0
No embeds

No notes for slide

Introduction to Grails (Groovy vs Java and Grails vs Rails are included)

  1. 1. GRAILS Ezgi AYVAZOGLUApril 2014 - IZMIR
  2. 2. Content  What is Grails?  Why full stack?  What is Groovy?  Grails vs Rails  Groovy vs Java  Testing in Grails  Examples
  3. 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. 4. What is Grails? Rapid Web Application Development Framework  For the JVM,  Inspired by Ruby on Rails, Django and others.
  5. 5. What is Grails?  Convention over Configuration (CoC),  Don’t Repeat Yourself (DRY).
  6. 6. Grails Architecture
  7. 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. 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. 9. A controller layer built on Spring MVC?  Basic controller logic,  Data binding and validation,  Runtime configurations,  Transactions.
  10. 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. 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. 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?
  13. 13. Groovy
  14. 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).
  15. 15. Grails vs Rails
  16. 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. 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
  18. 18. Groovy vs Java
  19. 19. Default imports  java.io.*  java.lang.*  java.math.BigDecimal  java.math.BigInteger  java.net.*  java.util.*  groovy.lang.*  groovy.util.* Groovy vs Java -1
  20. 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. 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. 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
  23. 23. Groovy vs Java - 5
  24. 24. Testing
  25. 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. 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. 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
  28. 28. Tools  IDE: GGTS, Eclipse 3.5、NetBeans 6.8、 IDEA 9、Spring STS 2.3.0  Editor:E-Texteditor、Textmate、GEdit  Build:Maven、Ant、Ivy  WebContainer:Tomcat、Jetty  Database:HSQL、MySQL  GRAG
  29. 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.
  30. 30. GGTS
  31. 31. Demo Grails gTunes: 1) grails create-app gTunes 2) grails create-controller store 3) edit StoreController.groovy 4) write -> controller.index() assert 'Welcome to the gTunes store!'== response.text 5) grails run-app
  32. 32. Demo http://localhost:8080/gTunes/
  33. 33. Examples  http://www.nowtv.com/  https://wwws.citruslane.com/#index  http://www.vodafone.co.uk/  http://grails.org/  http://uros.com/  …  Twitter in 60 minutes! http://www.youtube.com/watch?v=pmT1zg8Cie4
  34. 34. Summary = + +
  35. 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. 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…
  37. 37. Thank You Any question Ezgi AYVAZOGLU

×