SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
Grails
High-velocity development for Spring applications
About Me
David Jacobs
● Web Developer since '98

● Groovy since '06          Twitter
                            @MetaThis
● Grails focus in '08-'09
What is Grails?
Grails is an open-source framework for high-velocity
development of Spring applications
 ● Sensible defaults
 ● Convention-over-configuration
 ● DRY
 ● Dynamic metaprogramming
 ● End-to-end integrated stack
 ● Enables you to focus on the business problem
Best-of-Breed Java Technologies
●   Spring
●   Spring MVC
●   Hibernate
●   log4j
●   jUnit
●   SiteMesh
Integrated Stack
●   Layers and technologies integrated and wired
    out-of-the-box
●   Default configurations based on industry best
    practices
    ●   80/20 rule
Directory Structure
●   grails-app - top level directory for Groovy sources
     ●   conf - Configuration sources.
     ●   controller - Web controllers - The C in MVC.
     ●   domain - The application domain.
     ●   i18n - Support for internationalization (i18n).
     ●   services - The service layer.
     ●   taglib - Tag libraries.
     ●   views - Groovy Server Pages.
●   scripts - Gant/Gradle scripts.
●   src - Supporting sources
     ●   groovy - Other Groovy sources
     ●   java - Other Java sources
●   test - Unit and integration test
GORM
●   Object Relational Mapping (ORM)
●   Data access layer
●   Simplifies configuration through conventions
●   Defaults to Hibernate implementation
     ● Provided as plugin, alternatives pluggable
●   Extends and simplifies data access APIs
●   Similar to ActiveRecord in Rails
GORM
Domain Modeling
//this is a complete Hibernate mapping!
class Employee {
    String firstName
    String lastName
    Date startDate
}
GORM
Dynamic CRUD
def employee = Employee.get(1)
employee.delete()
def newEmployee = new Employee(firstName: “Joe”, lastName: ”Programmer”)
newEmployee.save()
GORM
Dynamic finders
Employee.findByLastNameAndHireDateGreaterThan(“Jones”, someDate)


findBy and findAllBy
 ●   InList - In the list of given values
 ●   LessThan - less than the given value
 ●   LessThanEquals - less than or equal a give value
 ●   GreaterThan - greater than a given value
 ●   GreaterThanEquals - greater than or equal a given value
 ●   Like - Equivalent to a SQL like expression
 ●   Ilike - Similar to a Like, except case insensitive
 ●   NotEqual - Negates equality
 ●   Between - Between two values (requires two arguments)
 ●   IsNotNull - Not a null value (doesn't require an argument)
 ●   IsNull - Is a null value (doesn't require an argument)
GORM
Hibernate HQL
Employee.findAll("from Employee as e where e.lastName like :lastName", [lastName:"Jon%"])

//with pagination and sorting
Employee.findAll("from Employee as e where e.lastName like :lastName",
                 [lastName:"Jon%", max:10, offset:20, sort:"hireDate", order:"asc"])
GORM
Simplified Hibernate Criteria API
// Find incomplete tasks assigned to Jones where the company is Monsanto
// and the project name begins with “Rubic”, order by task name
def criteria = Tasks.createCriteria()
def tasks = criteria.list {
  eq(‘completed’, false)
  project{
    like(‘name’ ‘Rubic%’)
    company{
      eq(‘name’, ‘Monsanto’)
    }
    assignedEmployees{
      eq(‘lastName’, ‘Jones’)
    }
  }
  order(‘taskName’, ‘asc’)
}
Web Layer
●   Controllers built on Spring MVC
●   URL mapping conventions map requests to controllers
●   Naming and directory conventions map actions to views
●   Built-in AOP action interceptors
     ●   Every controller provides a beforeInterceptor and afterInterceptor
     ●   Specifiable by action, optionally with patterns and exclusions
●   Servlet objects and convenience extensions injected into controller actions at runtime and
    provided as implicit variables
     ●   servletContext, session, request, response, params, flash
Spring MVC
Request parameters parsed into multidimensional params map
     ●   Easily accessed with powerful Groovy map support.

<!-- HTML form -->
<input type=”text” name=”userName” />
//controller code
def userName = params.userName

<!-- HTML form with dot-notation for complex embedded objects -->
<input type=”text” name=”user.address.zipCode” />
<input type=”text” name=”user.address.state” />
//controller code
def zipCode = params.user.address.zipCode
def state = params.user.address.state
Data Binding
def save = {
    //bind params to new instance
    def user = new User(params)

    //persist
    user.save()
}


def update = {
    //get instance from database
    def user = User.get(params.id)
    //bind params
    user.properties = params
    user.save()
}
Request Format Transparency
Grails codecs (dynamic encode/decode methods) easily automap formats like XML and JSON to
the params map.

<!-- XML request -->
<user>
  <id>42</id>
  <address>
    <zipCode>63122</zipCode>
  </address>
</user>

//transparent to the controller code
def zipCode = params.user.address.zipCode
def user = new User(params.user)


Easily create custom codecs to support specific requirements
XML & JSON Marshalling
Groovy's popular XML support
+
Grails builders and codecs
+
Convenience methods

def list = {
    render Project.list() as XML
}


def list = {
    render Project.list() as JSON
}
Groovy Server Pages (GSP)
●   Similar to JSP
     ●   Tag library like JSTL, but much more powerful
     ●   Easy custom tags
     ●   Powerful templates
●   SiteMesh is automatically configured for layout management
Groovy Server Pages (GSP)
Tags
   actionSubmit     fieldValue      layoutBody       render
   applyLayout      findAll         layoutHead       renderErrors
   checkBox         form            layoutTitle      resource
   collect          formRemote      link             select
   cookie           formatBoolean   localeSelect     set
   country          formatDate      message          sortableColumn
   countrySelect    formatNumber    meta             submitButton
   createLink       grep            pageProperty     submitToRemote
   createLinkTo     hasErrors       paginate         textArea
   currencySelect   header          passwordField    textField
   datePicker       hiddenField     radio            timeZoneSelect
   each             if              radioGroup       unless
   eachError        include         remoteField      uploadForm
   else             javascript      remoteFunction   while
   elseif           join            remoteLink
AJAX
●   Bundled with Prototype and Script.aculo.us
●   Excellent jQuery plugin
●   GSP tags for AJAX
     ●   Adapters built-in for major JavaScript frameworks
●   Plugins provide additional AJAX functionality
Configuration
Per-Environment Configuration Supports SCM
    ●    Package or run as any configured environment. Default environments and build configurations defined for
         development, test (staging) and production.
           ●    Programmatic environment detection with provided Environment class.


environments {
  development {
     dataSource {
       dbCreate = "create-drop" // one of 'create', 'create-drop','update'
       url = "jdbc:hsqldb:mem:devDB"
     }
  }
    test {
       dataSource {
          dbCreate = "update"
          url = "jdbc:hsqldb:mem:testDb"
       }
    }
    production {
      dataSource {
        dbCreate = "update"
        url = "jdbc:hsqldb:file:prodDb;shutdown=true"
      }
    }
}
Plugins
Grails extensions are provided as plugins
 ●   Created by core Grails team and community
 ●   Powerful – a plugin IS a Grails application
 ●   Plugins typically bring the idioms of convention-over-configuration and simplified APIs to
     popular libraries
 ●   Easy to create your own – provides a strong architecture for re-use across projects
 ●   Examples
      ●   Spring Security
      ●   JMS
      ●   Spring WS
      ●   LDAP
      ●   Quartz
Plugins
Plugin development is very active
The Bottom Line
●   Increases developer productivity
●   less code + less configuration = easier to maintain
●   Smaller learning curve than other Java web frameworks
●   Eases the learning curve for the underlying technologies
●   Project layout conventions and a standard technology stack promote quicker ramp-up time from one
    Grails project to another
●   Increases agility potential through rapid proto-typing and quick customer feedback
●   Guides solid technology choices by providing excellent defaults
●   Developers enjoy it, which promotes morale and retention

Weitere ähnliche Inhalte

Was ist angesagt?

AngularJS Deep Dives (NYC GDG Apr 2013)
AngularJS Deep Dives (NYC GDG Apr 2013)AngularJS Deep Dives (NYC GDG Apr 2013)
AngularJS Deep Dives (NYC GDG Apr 2013)Nitya Narasimhan
 
intoduction to Grails Framework
intoduction to Grails Frameworkintoduction to Grails Framework
intoduction to Grails FrameworkHarshdeep Kaur
 
Mobile Day - React Native
Mobile Day - React NativeMobile Day - React Native
Mobile Day - React NativeSoftware Guru
 
Using React with Grails 3
Using React with Grails 3Using React with Grails 3
Using React with Grails 3Zachary Klein
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...mfrancis
 
A Closer Look At React Native
A Closer Look At React NativeA Closer Look At React Native
A Closer Look At React NativeIan Wang
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Tugdual Grall
 
Dropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stackDropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stackJacek Furmankiewicz
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and ImprovedTimothy Fisher
 
Implement react pagination with react hooks and react paginate
Implement react pagination with react hooks and react paginateImplement react pagination with react hooks and react paginate
Implement react pagination with react hooks and react paginateKaty Slemon
 
GraphQL in Symfony
GraphQL in SymfonyGraphQL in Symfony
GraphQL in SymfonyBernd Alter
 
DevQA: make your testers happier with Groovy, Spock and Geb
DevQA: make your testers happier with Groovy, Spock and GebDevQA: make your testers happier with Groovy, Spock and Geb
DevQA: make your testers happier with Groovy, Spock and GebAlvaro Sanchez-Mariscal
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)Binary Studio
 
IndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsIndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsAdégòkè Obasá
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentationThanh Tuong
 

Was ist angesagt? (20)

AngularJS Deep Dives (NYC GDG Apr 2013)
AngularJS Deep Dives (NYC GDG Apr 2013)AngularJS Deep Dives (NYC GDG Apr 2013)
AngularJS Deep Dives (NYC GDG Apr 2013)
 
intoduction to Grails Framework
intoduction to Grails Frameworkintoduction to Grails Framework
intoduction to Grails Framework
 
G pars
G parsG pars
G pars
 
Mobile Day - React Native
Mobile Day - React NativeMobile Day - React Native
Mobile Day - React Native
 
Getting Started With ReactJS
Getting Started With ReactJSGetting Started With ReactJS
Getting Started With ReactJS
 
Using React with Grails 3
Using React with Grails 3Using React with Grails 3
Using React with Grails 3
 
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
OSGi and Spring Data for simple (Web) Application Development - Christian Bar...
 
Angular beans
Angular beansAngular beans
Angular beans
 
A Closer Look At React Native
A Closer Look At React NativeA Closer Look At React Native
A Closer Look At React Native
 
Scripting Oracle Develop 2007
Scripting Oracle Develop 2007Scripting Oracle Develop 2007
Scripting Oracle Develop 2007
 
Dropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stackDropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stack
 
HTML5 New and Improved
HTML5   New and ImprovedHTML5   New and Improved
HTML5 New and Improved
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
Implement react pagination with react hooks and react paginate
Implement react pagination with react hooks and react paginateImplement react pagination with react hooks and react paginate
Implement react pagination with react hooks and react paginate
 
GraphQL in Symfony
GraphQL in SymfonyGraphQL in Symfony
GraphQL in Symfony
 
DevQA: make your testers happier with Groovy, Spock and Geb
DevQA: make your testers happier with Groovy, Spock and GebDevQA: make your testers happier with Groovy, Spock and Geb
DevQA: make your testers happier with Groovy, Spock and Geb
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
 
React JS part 1
React JS part 1React JS part 1
React JS part 1
 
IndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web AppsIndexedDB and Push Notifications in Progressive Web Apps
IndexedDB and Push Notifications in Progressive Web Apps
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 

Andere mochten auch

Introdução a Grails: Um framework veloz e poderoso
Introdução a Grails: Um framework veloz e poderosoIntrodução a Grails: Um framework veloz e poderoso
Introdução a Grails: Um framework veloz e poderosoBruno Lopes
 
Grails, o que isso quer dizer?
Grails, o que isso quer dizer?Grails, o que isso quer dizer?
Grails, o que isso quer dizer?Gilliard Cordeiro
 
Oficina groovy grails - infoway
Oficina  groovy grails - infowayOficina  groovy grails - infoway
Oficina groovy grails - infowayLucas Aquiles
 
Grails Simple Login
Grails Simple LoginGrails Simple Login
Grails Simple Loginmoniguna
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 

Andere mochten auch (7)

Curso de Grails
Curso de GrailsCurso de Grails
Curso de Grails
 
Grails
GrailsGrails
Grails
 
Introdução a Grails: Um framework veloz e poderoso
Introdução a Grails: Um framework veloz e poderosoIntrodução a Grails: Um framework veloz e poderoso
Introdução a Grails: Um framework veloz e poderoso
 
Grails, o que isso quer dizer?
Grails, o que isso quer dizer?Grails, o que isso quer dizer?
Grails, o que isso quer dizer?
 
Oficina groovy grails - infoway
Oficina  groovy grails - infowayOficina  groovy grails - infoway
Oficina groovy grails - infoway
 
Grails Simple Login
Grails Simple LoginGrails Simple Login
Grails Simple Login
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 

Ähnlich wie Grails 101

Groovy and Grails intro
Groovy and Grails introGroovy and Grails intro
Groovy and Grails introMiguel Pastor
 
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...ddrschiw
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseSpeedment, Inc.
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSpeedment, Inc.
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Arun Gupta
 
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}Md. Sadhan Sarker
 
Dynamic Groovy Edges
Dynamic Groovy EdgesDynamic Groovy Edges
Dynamic Groovy EdgesJimmy Ray
 
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...Amazon Web Services Japan
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Waysmalltown
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB
 
GraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptxGraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptxSoham Dasgupta
 
GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011Manuel Carrasco Moñino
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)lennartkats
 
Do we need a serverless framework? With Python, I did not
Do we need a serverless framework? With Python, I did notDo we need a serverless framework? With Python, I did not
Do we need a serverless framework? With Python, I did notCristóbal García García
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest servicesIoan Eugen Stan
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...Codemotion
 
Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Matt Raible
 

Ähnlich wie Grails 101 (20)

Groovy and Grails intro
Groovy and Grails introGroovy and Grails intro
Groovy and Grails intro
 
Ad111
Ad111Ad111
Ad111
 
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
AD111 -- Harnessing the Power of Server-Side JavaScript and Other Advanced XP...
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
How to generate customized java 8 code from your database
How to generate customized java 8 code from your databaseHow to generate customized java 8 code from your database
How to generate customized java 8 code from your database
 
Silicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your databaseSilicon Valley JUG - How to generate customized java 8 code from your database
Silicon Valley JUG - How to generate customized java 8 code from your database
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
 
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
Up and Running with gRPC & Cloud Career [GDG-Cloud-Dhaka-IO/2022}
 
Dynamic Groovy Edges
Dynamic Groovy EdgesDynamic Groovy Edges
Dynamic Groovy Edges
 
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
202201 AWS Black Belt Online Seminar Apache Spark Performnace Tuning for AWS ...
 
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps WayDevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
DevOpsDays Taipei 2019 - Mastering IaC the DevOps Way
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB AtlasMongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
 
GraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptxGraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptx
 
GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011GQuery a jQuery clone for Gwt, RivieraDev 2011
GQuery a jQuery clone for Gwt, RivieraDev 2011
 
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
Domain-Specific Languages for Composable Editor Plugins (LDTA 2009)
 
Do we need a serverless framework? With Python, I did not
Do we need a serverless framework? With Python, I did notDo we need a serverless framework? With Python, I did not
Do we need a serverless framework? With Python, I did not
 
Javascript ui for rest services
Javascript ui for rest servicesJavascript ui for rest services
Javascript ui for rest services
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
 
Gradle
GradleGradle
Gradle
 
Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013
 

Kürzlich hochgeladen

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Grails 101

  • 2. About Me David Jacobs ● Web Developer since '98 ● Groovy since '06 Twitter @MetaThis ● Grails focus in '08-'09
  • 3. What is Grails? Grails is an open-source framework for high-velocity development of Spring applications ● Sensible defaults ● Convention-over-configuration ● DRY ● Dynamic metaprogramming ● End-to-end integrated stack ● Enables you to focus on the business problem
  • 4. Best-of-Breed Java Technologies ● Spring ● Spring MVC ● Hibernate ● log4j ● jUnit ● SiteMesh
  • 5. Integrated Stack ● Layers and technologies integrated and wired out-of-the-box ● Default configurations based on industry best practices ● 80/20 rule
  • 6. Directory Structure ● grails-app - top level directory for Groovy sources ● conf - Configuration sources. ● controller - Web controllers - The C in MVC. ● domain - The application domain. ● i18n - Support for internationalization (i18n). ● services - The service layer. ● taglib - Tag libraries. ● views - Groovy Server Pages. ● scripts - Gant/Gradle scripts. ● src - Supporting sources ● groovy - Other Groovy sources ● java - Other Java sources ● test - Unit and integration test
  • 7. GORM ● Object Relational Mapping (ORM) ● Data access layer ● Simplifies configuration through conventions ● Defaults to Hibernate implementation ● Provided as plugin, alternatives pluggable ● Extends and simplifies data access APIs ● Similar to ActiveRecord in Rails
  • 8. GORM Domain Modeling //this is a complete Hibernate mapping! class Employee { String firstName String lastName Date startDate }
  • 9. GORM Dynamic CRUD def employee = Employee.get(1) employee.delete() def newEmployee = new Employee(firstName: “Joe”, lastName: ”Programmer”) newEmployee.save()
  • 10. GORM Dynamic finders Employee.findByLastNameAndHireDateGreaterThan(“Jones”, someDate) findBy and findAllBy ● InList - In the list of given values ● LessThan - less than the given value ● LessThanEquals - less than or equal a give value ● GreaterThan - greater than a given value ● GreaterThanEquals - greater than or equal a given value ● Like - Equivalent to a SQL like expression ● Ilike - Similar to a Like, except case insensitive ● NotEqual - Negates equality ● Between - Between two values (requires two arguments) ● IsNotNull - Not a null value (doesn't require an argument) ● IsNull - Is a null value (doesn't require an argument)
  • 11. GORM Hibernate HQL Employee.findAll("from Employee as e where e.lastName like :lastName", [lastName:"Jon%"]) //with pagination and sorting Employee.findAll("from Employee as e where e.lastName like :lastName", [lastName:"Jon%", max:10, offset:20, sort:"hireDate", order:"asc"])
  • 12. GORM Simplified Hibernate Criteria API // Find incomplete tasks assigned to Jones where the company is Monsanto // and the project name begins with “Rubic”, order by task name def criteria = Tasks.createCriteria() def tasks = criteria.list { eq(‘completed’, false) project{ like(‘name’ ‘Rubic%’) company{ eq(‘name’, ‘Monsanto’) } assignedEmployees{ eq(‘lastName’, ‘Jones’) } } order(‘taskName’, ‘asc’) }
  • 13. Web Layer ● Controllers built on Spring MVC ● URL mapping conventions map requests to controllers ● Naming and directory conventions map actions to views ● Built-in AOP action interceptors ● Every controller provides a beforeInterceptor and afterInterceptor ● Specifiable by action, optionally with patterns and exclusions ● Servlet objects and convenience extensions injected into controller actions at runtime and provided as implicit variables ● servletContext, session, request, response, params, flash
  • 14. Spring MVC Request parameters parsed into multidimensional params map ● Easily accessed with powerful Groovy map support. <!-- HTML form --> <input type=”text” name=”userName” /> //controller code def userName = params.userName <!-- HTML form with dot-notation for complex embedded objects --> <input type=”text” name=”user.address.zipCode” /> <input type=”text” name=”user.address.state” /> //controller code def zipCode = params.user.address.zipCode def state = params.user.address.state
  • 15. Data Binding def save = { //bind params to new instance def user = new User(params) //persist user.save() } def update = { //get instance from database def user = User.get(params.id) //bind params user.properties = params user.save() }
  • 16. Request Format Transparency Grails codecs (dynamic encode/decode methods) easily automap formats like XML and JSON to the params map. <!-- XML request --> <user> <id>42</id> <address> <zipCode>63122</zipCode> </address> </user> //transparent to the controller code def zipCode = params.user.address.zipCode def user = new User(params.user) Easily create custom codecs to support specific requirements
  • 17. XML & JSON Marshalling Groovy's popular XML support + Grails builders and codecs + Convenience methods def list = { render Project.list() as XML } def list = { render Project.list() as JSON }
  • 18. Groovy Server Pages (GSP) ● Similar to JSP ● Tag library like JSTL, but much more powerful ● Easy custom tags ● Powerful templates ● SiteMesh is automatically configured for layout management
  • 19. Groovy Server Pages (GSP) Tags actionSubmit fieldValue layoutBody render applyLayout findAll layoutHead renderErrors checkBox form layoutTitle resource collect formRemote link select cookie formatBoolean localeSelect set country formatDate message sortableColumn countrySelect formatNumber meta submitButton createLink grep pageProperty submitToRemote createLinkTo hasErrors paginate textArea currencySelect header passwordField textField datePicker hiddenField radio timeZoneSelect each if radioGroup unless eachError include remoteField uploadForm else javascript remoteFunction while elseif join remoteLink
  • 20. AJAX ● Bundled with Prototype and Script.aculo.us ● Excellent jQuery plugin ● GSP tags for AJAX ● Adapters built-in for major JavaScript frameworks ● Plugins provide additional AJAX functionality
  • 21. Configuration Per-Environment Configuration Supports SCM ● Package or run as any configured environment. Default environments and build configurations defined for development, test (staging) and production. ● Programmatic environment detection with provided Environment class. environments { development { dataSource { dbCreate = "create-drop" // one of 'create', 'create-drop','update' url = "jdbc:hsqldb:mem:devDB" } } test { dataSource { dbCreate = "update" url = "jdbc:hsqldb:mem:testDb" } } production { dataSource { dbCreate = "update" url = "jdbc:hsqldb:file:prodDb;shutdown=true" } } }
  • 22. Plugins Grails extensions are provided as plugins ● Created by core Grails team and community ● Powerful – a plugin IS a Grails application ● Plugins typically bring the idioms of convention-over-configuration and simplified APIs to popular libraries ● Easy to create your own – provides a strong architecture for re-use across projects ● Examples ● Spring Security ● JMS ● Spring WS ● LDAP ● Quartz
  • 24. The Bottom Line ● Increases developer productivity ● less code + less configuration = easier to maintain ● Smaller learning curve than other Java web frameworks ● Eases the learning curve for the underlying technologies ● Project layout conventions and a standard technology stack promote quicker ramp-up time from one Grails project to another ● Increases agility potential through rapid proto-typing and quick customer feedback ● Guides solid technology choices by providing excellent defaults ● Developers enjoy it, which promotes morale and retention