• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Introduction to Grails (Groovy vs Java and Grails vs Rails are included)

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



Introduction to Grails , Groovs vs Java, Grails vs Rails

Introduction to Grails , Groovs vs Java, Grails vs Rails



Total Views
Views on SlideShare
Embed Views



0 Embeds 0

No embeds



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

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

    • 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