Groovy & Grails Introductory Presentation
Upcoming SlideShare
Loading in...5
×
 

Groovy & Grails Introductory Presentation

on

  • 1,180 views

This is a presentation I gave at the Netherlands Bio Informatics Consortium's BioAssist meetings about the Grails MVC Web Framework. It's a Rapid Prototyping MVC Framework based on Groovy / Java, ...

This is a presentation I gave at the Netherlands Bio Informatics Consortium's BioAssist meetings about the Grails MVC Web Framework. It's a Rapid Prototyping MVC Framework based on Groovy / Java, based on to the RAILS paradigm. As it is built upon proven technology (Spring, Hibernate, etcetera) and can mix Groovy with Java code, the projects developed by the Java world are all usable in the Grails framework which makes it very powerful and easy to extend.

Statistics

Views

Total Views
1,180
Views on SlideShare
1,179
Embed Views
1

Actions

Likes
5
Downloads
62
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

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.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Groovy & Grails Introductory Presentation Groovy & Grails Introductory Presentation Presentation Transcript

  • A Rapid Prototyping MVC Framework based on Groovy / Java by Jeroen Wesbeek <work@osx.eu>
  • What is Grails?A Groovy / Java Web Framework that is
  • What is Grails?A Groovy / Java Web Framework that is• Rapid View slide
  • What is Grails?A Groovy / Java Web Framework that is• Rapid• Dynamic View slide
  • What is Grails?A Groovy / Java Web Framework that is• Rapid• Dynamic• Robust
  • Grails is Rapid?Yes! You will have a functional application in about eight seconds!
  • That’s nice, what else?Grails aims to improve productivity overconventional Java Frameworks by:
  • That’s nice, what else?Grails aims to improve productivity overconventional Java Frameworks by: • eliminating XML configuration - Convention over Configuration. For example, a class name which ends with Controller (e.g. BookController) is considered a web controller
  • That’s nice, what else?Grails aims to improve productivity overconventional Java Frameworks by: • eliminating XML configuration - Convention over Configuration. For example, a class name which ends with Controller (e.g. BookController) is considered a web controller • ready to use development environment - Grails comes with a complete development environment which includes a webserver and a database
  • That’s nice, what else?Grails aims to improve productivity overconventional Java Frameworks by: • eliminating XML configuration - Convention over Configuration. For example, a class name which ends with Controller (e.g. BookController) is considered a web controller • ready to use development environment - Grails comes with a complete development environment which includes a webserver and a database • default functionality through mixins - methods which are added to a class dynamically as if the functionality was compiled in the program, like getters and setters and dynamic finders
  • Rapid Development As Grails is inspired by the RAILS principle, itprovides 52 commands to make your life easier:• grails create-app• grails create-domain-class• grails create-controller• grails install-plugin• grails war
  • “If we had built our prototype inJava, we would have only beenable to deliver a quarter to athird of the functionality weproduced in Groovy and Grails” Paul Fisher, Tech Mgr Wired.com
  • “Now using Groovy and Grails, we release every week to production, compared with every six weeks previously” Jon Mullen, ScrumMaster Sky.com
  • “I cannot count how many times we have exclaimed“WOW!” realizing how Grailsmakes things easy. Grails turned out to be definitely the right choice.” Vincenzo Foderà Vodafone Music Store
  • Why is it dynamic?• Changes made in Controllers and Views are instantly visible - Domain Classes, Bootstrap and Configuration require a recompile• Default functionality through mixins
  • Grails is RobustGrails builds upon proven technology:
  • Grails is RobustGrails builds upon proven technology: • Groovy - open source dynamic language for the Java Virtual Machine that offers a flexible Java-like syntax that most Java developers can learn in matter of hours and compiles to bytecode
  • Grails is RobustGrails builds upon proven technology: • Groovy - open source dynamic language for the Java Virtual Machine that offers a flexible Java-like syntax that most Java developers can learn in matter of hours and compiles to bytecode • Spring - an open source Java Application Framework
  • Grails is RobustGrails builds upon proven technology: • Groovy - open source dynamic language for the Java Virtual Machine that offers a flexible Java-like syntax that most Java developers can learn in matter of hours and compiles to bytecode • Spring - an open source Java Application Framework • Hibernate - an Object Relational Mapping (ORM) Framework
  • Grails is RobustGrails builds upon proven technology: • Groovy - open source dynamic language for the Java Virtual Machine that offers a flexible Java-like syntax that most Java developers can learn in matter of hours and compiles to bytecode • Spring - an open source Java Application Framework • Hibernate - an Object Relational Mapping (ORM) FrameworkGrails is backed by SpringSource / VMwareContinued development and support guaranteed
  • Model View Controller?MVC is a software architectural pattern which dates back to1979 and is widely adopted. It separates:
  • Model View Controller?MVC is a software architectural pattern which dates back to1979 and is widely adopted. It separates:• Data - The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).
  • Model View Controller?MVC is a software architectural pattern which dates back to1979 and is widely adopted. It separates:• Data - The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).• User Interface - The view renders the model into a form suitable for interaction, typically a user interface element.
  • Model View Controller?MVC is a software architectural pattern which dates back to1979 and is widely adopted. It separates:• Data - The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller).• User Interface - The view renders the model into a form suitable for interaction, typically a user interface element.• Application Logic - The controller receives user input and initiates a response by making calls on model objects.
  • How is a grailsapplication built-up?
  • How is a grails application built-up?Application Code
  • How is a grails application built-up?Libraries
  • How is a grails application built-up?Tests
  • How is a grails application built-up?JS / CSS / Images
  • How is a grails application built-up?Controllers
  • How is a grails application built-up?Domain Classes
  • How is a grails application built-up?Views
  • How is a grails application built-up?Configuration
  • How is a grails application built-up?Internationalization
  • How is a grails application built-up?Services
  • How is a grails application built-up?Tag Libraries
  • The Library AplicationWe will set up a simple library application which will contain Authors and Books
  • The Library AplicationWe will set up a simple library application which will contain Authors and Books • create domain classes
  • The Library AplicationWe will set up a simple library application which will contain Authors and Books • create domain classes • let Grails generate a CRUD (CReate Update Delete) interface
  • Domain Classes
  • Domain Classes
  • Domain Classes
  • Domain Classes This will generate Domain Classes and Unit Tests
  • Author Domain Class
  • Author Domain ClassAuthor name
  • Author Domain ClassBook Relationship
  • Book Domain Class
  • Book Domain ClassBook Title
  • Book Domain ClassRelationship
  • Book Domain ClassRelationship “Book” belongs to “Author” Updates made to Author will be cascaded down to Book by GORM!
  • Book Domain Class Grails ObjectRelationship Relational Mapping “Book” belongs to “Author” Updates made to Author will be cascaded down to Book by GORM!
  • MVC: The ModelTo Summarize, we created:
  • MVC: The ModelTo Summarize, we created:• an Author Domain Class which has many Books
  • MVC: The ModelTo Summarize, we created:• an Author Domain Class which has many Books• a Book Domain Class which belongs to Author and is cascadedly updated or deleted
  • MVC: The ModelTo Summarize, we created:• an Author Domain Class which has many Books• a Book Domain Class which belongs to Author and is cascadedly updated or deleted Author 1:n Book
  • The Controllers
  • The Controllers
  • The Controllers
  • The ControllersEnable ScaffoldingEnable Scaffolding
  • The ControllersDisable default indexDisable default index
  • The Controllers Note this is a closure, not a method!Disable default indexDisable default index
  • The Controllers Note this is a closure, not a method!Disable default index def myMethod() { ... }Disable default index
  • The Controllers Note this is a closure, not a method!Disable default index def myMethod() { ... } def myClosure { ... }Disable default index
  • The ControllersScaffolding dynamically creates a CRUD user interface for your controllers
  • Running The Application
  • Running The Application
  • We would like to show Dan Brown instead
  • Author Domain Class
  • Author Domain ClassOverload toString
  • Author Domain ClassOverload toString ‘return’ is not required
  • Author name is now shown as expected
  • To summarize
  • To summarize• in a short period of time you can have a basic functional application with a CRUD interface to your Domain model
  • To summarize• in a short period of time you can have a basic functional application with a CRUD interface to your Domain model• you don’t need to set up a relational database yourself as you define your datamodel in code and GORM / Hibernate takes care of the rest
  • To summarize• in a short period of time you can have a basic functional application with a CRUD interface to your Domain model• you don’t need to set up a relational database yourself as you define your datamodel in code and GORM / Hibernate takes care of the rest• no XML configuration has to be done
  • Cascading
  • CascadingRelationship
  • CascadingRelationship If an author is deleted, his books are cascadingly deleted as well
  • Why is it dynamic?• Changes made in Controllers and Views are instantly visible - Domain Classes, Bootstrap and Configuration require a recompile• Default functionality through mixins
  • How to continue?
  • How to continue?Replace the default CRUD interface with your own interface
  • How to continue?Replace the default CRUD interface with your own interface
  • How to continue? Replace the default CRUD interface with your own interfacedisable scaffolding
  • How to continue? Replace the default CRUD interface with your own interfacedisable scaffolding ...and re-enable the index closure
  • How to continue? Replace the default CRUD interface with your own interfacedisable scaffolding ...and re-enable the index closure Grails will now use the view: grails-app/views/author/index.gsp
  • Author index view
  • Author index view
  • Author index view
  • Author index view
  • Author index viewGrails leverages Sitemesh, a decorator engine, to support view layouts.
  • Author index viewGrails leverages Sitemesh, a decorator engine, to support view layouts.
  • Author index viewGrails leverages Sitemesh, a decorator engine, to support view layouts. we tell Sitemesh to use the main layout for decorating the index page
  • Author index viewGrails leverages Sitemesh, a decorator engine, to support view layouts. we tell Sitemesh to use the main layout for decorating the index page layouts are stored in the views/layouts folder
  • Author index view
  • Author Index View
  • Author Index View ‘form’ tag
  • Author Index View ‘form’ tag ‘select’ tag
  • Author Index View ‘form’ tag ‘select’ tag ‘each’ tag
  • Author Index View ‘form’ tag ‘select’ tag ‘each’ tagYou can create your own tags by creating new tag libaries
  • Author Index View the form will submit to the ‘author’ controller’s ‘index’ action
  • Author Controller
  • Author Controller if we get an author’s name from the view, fetch an instance of that Author
  • Author Controller Return a if we get an author’s name from theLinkedHashMap view, fetch an instance of that Author to the view
  • Author Controller Return a if we get an author’s name from theLinkedHashMap view, fetch an instance of that Author to the view containing the Author instance
  • Author Controller Return a if we get an author’s name from theLinkedHashMap view, fetch an instance of that Author to the view containing the Author instance an ArrayList of Authors
  • Author Controller Return a if we get an author’s name from theLinkedHashMap view, fetch an instance of that Author to the view containing the Author instance an ArrayList of Authors an ArrayList of all books for a given Author
  • Author View
  • Plugins
  • Plugins GWT GORM Support for Hadoop HBase Grails Webflows Google Visualisation jQuery Vaadin Spring Security 579 OAuth ShoppingCartCloudFoundry OpenID Spring WS MongoDB Google AppEngine Quartz
  • Plugins We Developed
  • Plugins We Developed AjaxFlowGDT (Grails Domain Temlates) Grom Uploadr GDT Importer
  • Plugins We Developed In Grails Central AjaxFlow Plugin RepositoryGDT (Grails Domain Temlates) Grom Uploadr GDT Importer
  • Plugins We Developed In Grails Central AjaxFlow Plugin Repository GDT (Grails Domain Temlates) Grom Uploadrin Maven repository GDT Importer
  • Plugins We Developed In Grails Central AjaxFlow Plugin Repository GDT (Grails Domain Temlates) Grom Uploadrin Maven repository GDT Importerhttp://nexus.nmcdsp.org Source on GitHubhttps://github.com/PhenotypeFoundation https://github.com/4np/grails-ajaxflowhttps://github.com/NetherlandsMetabolomicsCentre https://github.com/4np/grails-grom https://github.com/4np/grails-uploadr
  • Release Management
  • Release Management• With a single command you can build a test or production package (e.g. grails prod war)
  • Release Management• With a single command you can build a test or production package (e.g. grails prod war)• Configuring PostgreSQL / MySQL / MongoDB etc for different environments is a blast
  • Release Management• With a single command you can build a test or production package (e.g. grails prod war)• Configuring PostgreSQL / MySQL / MongoDB etc for different environments is a blast• Testing / Continuous integration is easy due to Hudson’s Grails Support (plugin)
  • To SummariseGrails is
  • To SummariseGrails is• Rapid
  • To SummariseGrails is• Rapid you can focus on what matters!
  • To SummariseGrails is• Rapid you can focus on what matters!• Dynamic
  • To SummariseGrails is• Rapid you can focus on what matters!• Dynamic no boilerplate code & free functionality
  • To SummariseGrails is• Rapid you can focus on what matters!• Dynamic no boilerplate code & free functionality• Robust
  • To SummariseGrails is• Rapid you can focus on what matters!• Dynamic no boilerplate code & free functionality• Robust backed by a large community
  • Any Questions? :) by Jeroen Wesbeek <work@osx.eu>Presentation also available on http://grails.nmcdsp.org/