SlideShare ist ein Scribd-Unternehmen logo
1 von 37
GRAILS
Ezgi AYVAZOGLUApril 2014 - IZMIR
Content
 What is Grails?
 Why full stack?
 What is Groovy?
 Grails vs Rails
 Groovy vs Java
 Testing in Grails
 Examples
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?
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)
 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.
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
A controller layer built on Spring
MVC?
 Basic controller logic,
 Data binding and validation,
 Runtime configurations,
 Transactions.
 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
 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
 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?
Groovy
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).
Grails vs Rails
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.
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
Groovy vs Java
Default imports
 java.io.*
 java.lang.*
 java.math.BigDecimal
 java.math.BigInteger
 java.net.*
 java.util.*
 groovy.lang.*
 groovy.util.*
Groovy vs Java -1
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!"
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
 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
Groovy vs Java - 5
Testing
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:
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
 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
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
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.
GGTS
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
Demo
http://localhost:8080/gTunes/
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
Summary
=
+
+
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
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…
Thank You
Any question
Ezgi AYVAZOGLU

Weitere ähnliche Inhalte

Kürzlich hochgeladen

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Kürzlich hochgeladen (20)

The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

Empfohlen

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Empfohlen (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

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

  • 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
  • 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. 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
  • 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. 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. GGTS
  • 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
  • 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
  • 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…