SlideShare a Scribd company logo
Groovy & Grails
   Scripting for Modern Web Applications




Rohit Nayak
Talentica Software
Agenda

    Demo: Quick intro to Grails

    Scripting, Web Applications and Grails/Groovy

    REST service in Grails
    −   Demo
    −   Internals

    Web Client in Grails
    −   Demo
    −   Internals

    Perspective
Demo

Quick Intro to Grails
Maggi

    grails create-app Maggi

    Domain class: Noodle, Packaging

    grails generate-all Noodle, Packaging

    grails run-app
Web Frameworks with Scripting

    Ruby on Rails (2004)


    CakePHP (2005)


    Django / Python (2005)


    Groovy on Grails (2006)
Power of these frameworks

    Baked Experience


    The Language


    Agility / Productivity
Baked Experience

    Model View Controller

    Object-Relational Mapping

    Templates

    Layout

    URL rewriting

    Ajax support

    XML / JSON support
The Language

    Dynamic

    More expressive code

    Smaller code

    Native support for Lists, Hashmaps

    Lang. support for IO, Net, XML

    Idioms for common Design Patterns
Agile

    Scaffolding

    Unit tests

    No compile cycles

    Built-in webservers

    Fail faster!
http://www.zacker.org/ruby-on-rails (Nov 2nd)
http://www.zacker.org/ruby-on-rails (Nov 2nd)
HelloWorld.java
public class HelloWorld {
    String name;
    public void setName(String name)
        { this.name = name; }
    public String getName() { return name; }
    public String hello()
        { return “Hello “+ name; }
    public static void main(String args[]) {
        HelloWorld helloWorld = new HelloWorld();
        helloWorld.setName(“Java”);
        System.out.println( helloWorld. hello() );
    }
}
HelloWorld.groovy
class HelloWorld {
    String name
    def hello() { "Hello $name" }
}
def helloWorld = new HelloWorld(name:"Groovy")
println helloWorld.hello()
Key Groovy Features

    Java-like syntax

    Complements Java

    Object-oriented

    Targets Java VM (JSR-241)
    −   Invoke Java class within Groovy
    −   Invoke Groovy class within Java

    Dynamic

    Scripting (JSR-223)

    Brevity
Brevity

    Optional semicolons, package prefixes

    Automatic imports (java.util.*, java.net.*,
    java.io.*, groovy…)

    GroovyBeans (generated accessors)

    Optional typing

    Optional return
Groovy Gravy

    GStrings: ”$book.title: $book.author (${book.reviewers.length})”

    Regular expressions: assert ‘12345’ =~ /d+/

    Only objects: primitives converted to Reference Types

    Lists: def list = [1, 2, 'hello', new java.util.Date()]

    Maps: def map = ['name':‘Indic Threads', 'location':‘Pune']

    Closures [1,2,3].collect {it*2} ===> [2, 4, 6]

    String literals – single, double, triple quotes
Closures

    Block of statements

    First class objects

    Parameters including default values

    Carries local context
    def foo(n) {   // method
             return { n += it }   // returns closure
    }
    def accumulator = foo(1) //curried closure
    assert accumulator(2) == 3 //assert used for self-documenting, unit-testing
    assert accumulator(1) == 4
Dynamic Programming

    Add methods, properties to classes/objects
    at run-time

    Mixins to inject behaviour

    Can extend class field-access mechanism

    Dynamic method invocation
Poolster

    Online “football pools” application

    Entities: Game, User

    Game  Stake, Option, Ends

    To join User chooses an Option

    REST Webservice backend

    Clients: iPhone, Grails, Android, Silverlight
Demo

The Poolster Webservice
Grails – Philosophy

    Convention over Configuration
     −   Magic directories
     −   Implicit table names, column names

    Don’t Repeat Yourself
     −   Database maps to domain
     −   hasMany defines relationship & declares variable
     −   Layout, form validations

    Lightweight
     −   Modify and F5

    Strong shoulders
     −   Spring (Grails MVC, DI, Transactions)
     −   Hibernate (GORM)
     −   Ant, JUnit, SiteMesh
Grails – Key Features

    Database constraints, composition

    MySQL integration

    URL Mapping

    Authentication / Filters

    Bootstrapping

    Unit test

    Logging
Demo

Poolster Web Client
Grails Web Application

    Custom Tag libraries

    Session variables

    Sitemesh layout

    Templates

    Internationalization
Unseen Gravy

    JUnit test cases, Mocking/Stubbing

    Web testing with Canoo Webtest

    Bootstrapping

    Pagination
Cons

    Learning curve

    Performance ?!

    Early adopter issues
Scripted In Groovy

    Canoo WebTest

    Tellurium

    Ant / Maven config files

    SoapUI script step

    Spring beans

    <YOUR APP HERE> 
Invoking Groovy Scripts
import java.io.File;
import groovy.lang.Binding;
import groovy.util.GroovyScriptEngine;

public class ScriptEngineEmbedGroovy{
  public static void main(String args[]) throws Throwable{
  String[] paths = {"C:groovy"};
  GroovyScriptEngine gse = new GroovyScriptEngine(paths);
  Binding binding = new Binding();
  Object[] path = {"C:musicmp3"};
  binding.setVariable("args",path);
  gse.run("Songs.groovy", binding);
  }
}
Getting Started

    groovy.codehaus.org

    grails.org

    Free e-books
     −   Beginning Groovy and Grails (Apress)
     −   Getting started with Grails (InfoQ)

    refcardz.com cheat sheets

    ibm.com Mastering Grails, Practically Groovy
Thanks
Ad

More Related Content

What's hot (20)

Hack & Fix, Hands on ColdFusion Security Training
Hack & Fix, Hands on ColdFusion Security TrainingHack & Fix, Hands on ColdFusion Security Training
Hack & Fix, Hands on ColdFusion Security Training
ColdFusionConference
 
JavaCro'15 - Beyond the basics of SonarQube improve your Java(Script) code ev...
JavaCro'15 - Beyond the basics of SonarQube improve your Java(Script) code ev...JavaCro'15 - Beyond the basics of SonarQube improve your Java(Script) code ev...
JavaCro'15 - Beyond the basics of SonarQube improve your Java(Script) code ev...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Performance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPPerformance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHP
Max Romanovsky
 
Php psr standard 2014 01-22
Php psr standard 2014 01-22Php psr standard 2014 01-22
Php psr standard 2014 01-22
Võ Duy Tuấn
 
Docker jako prostředí pro automatizaci testů
Docker jako prostředí pro automatizaci testůDocker jako prostředí pro automatizaci testů
Docker jako prostředí pro automatizaci testů
Radim Daniel Pánek
 
Automate Yo' Self
Automate Yo' SelfAutomate Yo' Self
Automate Yo' Self
John Anderson
 
Can you contain the future - Docker, Container Technologies, The Future, and You
Can you contain the future - Docker, Container Technologies, The Future, and YouCan you contain the future - Docker, Container Technologies, The Future, and You
Can you contain the future - Docker, Container Technologies, The Future, and You
ColdFusionConference
 
Automate Thyself
Automate ThyselfAutomate Thyself
Automate Thyself
Ortus Solutions, Corp
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
juzten
 
Write php deploy everywhere tek11
Write php deploy everywhere   tek11Write php deploy everywhere   tek11
Write php deploy everywhere tek11
Michelangelo van Dam
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016
Clark Everetts
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
Jason Grimes
 
Introduction To Ant1
Introduction To  Ant1Introduction To  Ant1
Introduction To Ant1
Rajesh Kumar
 
Test stack
Test stackTest stack
Test stack
Radim Daniel Pánek
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientHow do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and Client
ColdFusionConference
 
CommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package ManagementCommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package Management
Ortus Solutions, Corp
 
Create your own composer package
Create your own composer packageCreate your own composer package
Create your own composer package
Lattapon Yodsuwan
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
Gavin Pickin
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
 
AppengineJS
AppengineJSAppengineJS
AppengineJS
Panagiotis Astithas
 
Hack & Fix, Hands on ColdFusion Security Training
Hack & Fix, Hands on ColdFusion Security TrainingHack & Fix, Hands on ColdFusion Security Training
Hack & Fix, Hands on ColdFusion Security Training
ColdFusionConference
 
Performance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHPPerformance tips for Symfony2 & PHP
Performance tips for Symfony2 & PHP
Max Romanovsky
 
Php psr standard 2014 01-22
Php psr standard 2014 01-22Php psr standard 2014 01-22
Php psr standard 2014 01-22
Võ Duy Tuấn
 
Docker jako prostředí pro automatizaci testů
Docker jako prostředí pro automatizaci testůDocker jako prostředí pro automatizaci testů
Docker jako prostředí pro automatizaci testů
Radim Daniel Pánek
 
Can you contain the future - Docker, Container Technologies, The Future, and You
Can you contain the future - Docker, Container Technologies, The Future, and YouCan you contain the future - Docker, Container Technologies, The Future, and You
Can you contain the future - Docker, Container Technologies, The Future, and You
ColdFusionConference
 
Quick flask an intro to flask
Quick flask   an intro to flaskQuick flask   an intro to flask
Quick flask an intro to flask
juzten
 
Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016Php Dependency Management with Composer ZendCon 2016
Php Dependency Management with Composer ZendCon 2016
Clark Everetts
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
Jason Grimes
 
Introduction To Ant1
Introduction To  Ant1Introduction To  Ant1
Introduction To Ant1
Rajesh Kumar
 
How do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and ClientHow do I Write Testable Javascript so I can Test my CF API on Server and Client
How do I Write Testable Javascript so I can Test my CF API on Server and Client
ColdFusionConference
 
CommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package ManagementCommandBox & ForgeBox Package Management
CommandBox & ForgeBox Package Management
Ortus Solutions, Corp
 
Create your own composer package
Create your own composer packageCreate your own composer package
Create your own composer package
Lattapon Yodsuwan
 
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
How do I write Testable Javascript - Presented at dev.Objective() June 16, 2016
Gavin Pickin
 
3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API3 WAYS TO TEST YOUR COLDFUSION API
3 WAYS TO TEST YOUR COLDFUSION API
Gavin Pickin
 

Viewers also liked (9)

Madrid GUG - Grails Plugins: Exporter
Madrid GUG - Grails Plugins: ExporterMadrid GUG - Grails Plugins: Exporter
Madrid GUG - Grails Plugins: Exporter
Iván López Martín
 
Groovy no es java sin punto y coma v3
Groovy no es java sin punto y coma v3Groovy no es java sin punto y coma v3
Groovy no es java sin punto y coma v3
Pablo Alba
 
Jedi knight
Jedi knightJedi knight
Jedi knight
Antonio Mas
 
T3chFest 2016 - De Java a Groovy: ¡Hora de Aventuras!
T3chFest 2016 - De Java a Groovy: ¡Hora de Aventuras!T3chFest 2016 - De Java a Groovy: ¡Hora de Aventuras!
T3chFest 2016 - De Java a Groovy: ¡Hora de Aventuras!
Iván López Martín
 
Geb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosperGeb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosper
Esther Lozano
 
De Java a Swift pasando por Groovy
De Java a Swift pasando por GroovyDe Java a Swift pasando por Groovy
De Java a Swift pasando por Groovy
Alberto De Ávila Hernández
 
GriffDnie (Griffon Demo)
GriffDnie (Griffon Demo)GriffDnie (Griffon Demo)
GriffDnie (Griffon Demo)
Jorge Aguilera
 
Macro macro, burrito burrit
Macro macro, burrito burritMacro macro, burrito burrit
Macro macro, burrito burrit
Mario García
 
Gorm for cassandra
Gorm for cassandraGorm for cassandra
Gorm for cassandra
Rafael Bermúdez Míguez
 
Madrid GUG - Grails Plugins: Exporter
Madrid GUG - Grails Plugins: ExporterMadrid GUG - Grails Plugins: Exporter
Madrid GUG - Grails Plugins: Exporter
Iván López Martín
 
Groovy no es java sin punto y coma v3
Groovy no es java sin punto y coma v3Groovy no es java sin punto y coma v3
Groovy no es java sin punto y coma v3
Pablo Alba
 
T3chFest 2016 - De Java a Groovy: ¡Hora de Aventuras!
T3chFest 2016 - De Java a Groovy: ¡Hora de Aventuras!T3chFest 2016 - De Java a Groovy: ¡Hora de Aventuras!
T3chFest 2016 - De Java a Groovy: ¡Hora de Aventuras!
Iván López Martín
 
Geb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosperGeb+spock: let your functional tests live long and prosper
Geb+spock: let your functional tests live long and prosper
Esther Lozano
 
GriffDnie (Griffon Demo)
GriffDnie (Griffon Demo)GriffDnie (Griffon Demo)
GriffDnie (Griffon Demo)
Jorge Aguilera
 
Macro macro, burrito burrit
Macro macro, burrito burritMacro macro, burrito burrit
Macro macro, burrito burrit
Mario García
 
Ad

Similar to Groovy - Grails as a modern scripting language for Web applications (20)

Groovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web ApplicationsGroovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web Applications
rohitnayak
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
Guillaume Laforge
 
Groovy and Grails
Groovy and GrailsGroovy and Grails
Groovy and Grails
GiltTech
 
Jet presentation
Jet presentationJet presentation
Jet presentation
Peter Sellars
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
Andres Almiray
 
What's New in Groovy 1.6?
What's New in Groovy 1.6?What's New in Groovy 1.6?
What's New in Groovy 1.6?
Guillaume Laforge
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Guillaume Laforge
 
Groovy and Grails intro
Groovy and Grails introGroovy and Grails intro
Groovy and Grails intro
Miguel Pastor
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
Jonathan Felch
 
Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010
Andres Almiray
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
Guillaume Laforge
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Paul King
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
loffenauer
 
Java, Ruby & Rails
Java, Ruby & RailsJava, Ruby & Rails
Java, Ruby & Rails
Peter Lind
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus Presentation
Ajax Experience 2009
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
mzgubin
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
mzgubin
 
Groovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web ApplicationsGroovy & Grails: Scripting for Modern Web Applications
Groovy & Grails: Scripting for Modern Web Applications
rohitnayak
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
Guillaume Laforge
 
Groovy and Grails
Groovy and GrailsGroovy and Grails
Groovy and Grails
GiltTech
 
Oscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast LaneOscon Java Testing on the Fast Lane
Oscon Java Testing on the Fast Lane
Andres Almiray
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume LaforgeGroovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Groovy and Grails in Action - Devoxx 2008 - University - Guillaume Laforge
Guillaume Laforge
 
Groovy and Grails intro
Groovy and Grails introGroovy and Grails intro
Groovy and Grails intro
Miguel Pastor
 
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
JRuby + Rails = Awesome Java Web Framework at Jfokus 2011
Nick Sieger
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
Jonathan Felch
 
Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010Polyglot Programming @ Jax.de 2010
Polyglot Programming @ Jax.de 2010
Andres Almiray
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
Guillaume Laforge
 
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Paul King
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
loffenauer
 
Java, Ruby & Rails
Java, Ruby & RailsJava, Ruby & Rails
Java, Ruby & Rails
Peter Lind
 
Laurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus PresentationLaurens Van Den Oever Xopus Presentation
Laurens Van Den Oever Xopus Presentation
Ajax Experience 2009
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
mzgubin
 
Groovy Finesse
Groovy FinesseGroovy Finesse
Groovy Finesse
mzgubin
 
Ad

More from IndicThreads (20)

Http2 is here! And why the web needs it
Http2 is here! And why the web needs itHttp2 is here! And why the web needs it
Http2 is here! And why the web needs it
IndicThreads
 
Understanding Bitcoin (Blockchain) and its Potential for Disruptive Applications
Understanding Bitcoin (Blockchain) and its Potential for Disruptive ApplicationsUnderstanding Bitcoin (Blockchain) and its Potential for Disruptive Applications
Understanding Bitcoin (Blockchain) and its Potential for Disruptive Applications
IndicThreads
 
Go Programming Language - Learning The Go Lang way
Go Programming Language - Learning The Go Lang wayGo Programming Language - Learning The Go Lang way
Go Programming Language - Learning The Go Lang way
IndicThreads
 
Building Resilient Microservices
Building Resilient Microservices Building Resilient Microservices
Building Resilient Microservices
IndicThreads
 
App using golang indicthreads
App using golang  indicthreadsApp using golang  indicthreads
App using golang indicthreads
IndicThreads
 
Building on quicksand microservices indicthreads
Building on quicksand microservices  indicthreadsBuilding on quicksand microservices  indicthreads
Building on quicksand microservices indicthreads
IndicThreads
 
How to Think in RxJava Before Reacting
How to Think in RxJava Before ReactingHow to Think in RxJava Before Reacting
How to Think in RxJava Before Reacting
IndicThreads
 
Iot secure connected devices indicthreads
Iot secure connected devices indicthreadsIot secure connected devices indicthreads
Iot secure connected devices indicthreads
IndicThreads
 
Real world IoT for enterprises
Real world IoT for enterprisesReal world IoT for enterprises
Real world IoT for enterprises
IndicThreads
 
IoT testing and quality assurance indicthreads
IoT testing and quality assurance indicthreadsIoT testing and quality assurance indicthreads
IoT testing and quality assurance indicthreads
IndicThreads
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
IndicThreads
 
Harnessing the Power of Java 8 Streams
Harnessing the Power of Java 8 Streams Harnessing the Power of Java 8 Streams
Harnessing the Power of Java 8 Streams
IndicThreads
 
Building & scaling a live streaming mobile platform - Gr8 road to fame
Building & scaling a live streaming mobile platform - Gr8 road to fameBuilding & scaling a live streaming mobile platform - Gr8 road to fame
Building & scaling a live streaming mobile platform - Gr8 road to fame
IndicThreads
 
Internet of things architecture perspective - IndicThreads Conference
Internet of things architecture perspective - IndicThreads ConferenceInternet of things architecture perspective - IndicThreads Conference
Internet of things architecture perspective - IndicThreads Conference
IndicThreads
 
Cars and Computers: Building a Java Carputer
 Cars and Computers: Building a Java Carputer Cars and Computers: Building a Java Carputer
Cars and Computers: Building a Java Carputer
IndicThreads
 
Scrap Your MapReduce - Apache Spark
 Scrap Your MapReduce - Apache Spark Scrap Your MapReduce - Apache Spark
Scrap Your MapReduce - Apache Spark
IndicThreads
 
Continuous Integration (CI) and Continuous Delivery (CD) using Jenkins & Docker
 Continuous Integration (CI) and Continuous Delivery (CD) using Jenkins & Docker Continuous Integration (CI) and Continuous Delivery (CD) using Jenkins & Docker
Continuous Integration (CI) and Continuous Delivery (CD) using Jenkins & Docker
IndicThreads
 
Speed up your build pipeline for faster feedback
Speed up your build pipeline for faster feedbackSpeed up your build pipeline for faster feedback
Speed up your build pipeline for faster feedback
IndicThreads
 
Unraveling OpenStack Clouds
 Unraveling OpenStack Clouds Unraveling OpenStack Clouds
Unraveling OpenStack Clouds
IndicThreads
 
Digital Transformation of the Enterprise. What IT leaders need to know!
Digital Transformation of the Enterprise. What IT  leaders need to know!Digital Transformation of the Enterprise. What IT  leaders need to know!
Digital Transformation of the Enterprise. What IT leaders need to know!
IndicThreads
 
Http2 is here! And why the web needs it
Http2 is here! And why the web needs itHttp2 is here! And why the web needs it
Http2 is here! And why the web needs it
IndicThreads
 
Understanding Bitcoin (Blockchain) and its Potential for Disruptive Applications
Understanding Bitcoin (Blockchain) and its Potential for Disruptive ApplicationsUnderstanding Bitcoin (Blockchain) and its Potential for Disruptive Applications
Understanding Bitcoin (Blockchain) and its Potential for Disruptive Applications
IndicThreads
 
Go Programming Language - Learning The Go Lang way
Go Programming Language - Learning The Go Lang wayGo Programming Language - Learning The Go Lang way
Go Programming Language - Learning The Go Lang way
IndicThreads
 
Building Resilient Microservices
Building Resilient Microservices Building Resilient Microservices
Building Resilient Microservices
IndicThreads
 
App using golang indicthreads
App using golang  indicthreadsApp using golang  indicthreads
App using golang indicthreads
IndicThreads
 
Building on quicksand microservices indicthreads
Building on quicksand microservices  indicthreadsBuilding on quicksand microservices  indicthreads
Building on quicksand microservices indicthreads
IndicThreads
 
How to Think in RxJava Before Reacting
How to Think in RxJava Before ReactingHow to Think in RxJava Before Reacting
How to Think in RxJava Before Reacting
IndicThreads
 
Iot secure connected devices indicthreads
Iot secure connected devices indicthreadsIot secure connected devices indicthreads
Iot secure connected devices indicthreads
IndicThreads
 
Real world IoT for enterprises
Real world IoT for enterprisesReal world IoT for enterprises
Real world IoT for enterprises
IndicThreads
 
IoT testing and quality assurance indicthreads
IoT testing and quality assurance indicthreadsIoT testing and quality assurance indicthreads
IoT testing and quality assurance indicthreads
IndicThreads
 
Functional Programming Past Present Future
Functional Programming Past Present FutureFunctional Programming Past Present Future
Functional Programming Past Present Future
IndicThreads
 
Harnessing the Power of Java 8 Streams
Harnessing the Power of Java 8 Streams Harnessing the Power of Java 8 Streams
Harnessing the Power of Java 8 Streams
IndicThreads
 
Building & scaling a live streaming mobile platform - Gr8 road to fame
Building & scaling a live streaming mobile platform - Gr8 road to fameBuilding & scaling a live streaming mobile platform - Gr8 road to fame
Building & scaling a live streaming mobile platform - Gr8 road to fame
IndicThreads
 
Internet of things architecture perspective - IndicThreads Conference
Internet of things architecture perspective - IndicThreads ConferenceInternet of things architecture perspective - IndicThreads Conference
Internet of things architecture perspective - IndicThreads Conference
IndicThreads
 
Cars and Computers: Building a Java Carputer
 Cars and Computers: Building a Java Carputer Cars and Computers: Building a Java Carputer
Cars and Computers: Building a Java Carputer
IndicThreads
 
Scrap Your MapReduce - Apache Spark
 Scrap Your MapReduce - Apache Spark Scrap Your MapReduce - Apache Spark
Scrap Your MapReduce - Apache Spark
IndicThreads
 
Continuous Integration (CI) and Continuous Delivery (CD) using Jenkins & Docker
 Continuous Integration (CI) and Continuous Delivery (CD) using Jenkins & Docker Continuous Integration (CI) and Continuous Delivery (CD) using Jenkins & Docker
Continuous Integration (CI) and Continuous Delivery (CD) using Jenkins & Docker
IndicThreads
 
Speed up your build pipeline for faster feedback
Speed up your build pipeline for faster feedbackSpeed up your build pipeline for faster feedback
Speed up your build pipeline for faster feedback
IndicThreads
 
Unraveling OpenStack Clouds
 Unraveling OpenStack Clouds Unraveling OpenStack Clouds
Unraveling OpenStack Clouds
IndicThreads
 
Digital Transformation of the Enterprise. What IT leaders need to know!
Digital Transformation of the Enterprise. What IT  leaders need to know!Digital Transformation of the Enterprise. What IT  leaders need to know!
Digital Transformation of the Enterprise. What IT leaders need to know!
IndicThreads
 

Recently uploaded (20)

Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Social Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTechSocial Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTech
Steve Jonas
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
Electronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploitElectronic_Mail_Attacks-1-35.pdf by xploit
Electronic_Mail_Attacks-1-35.pdf by xploit
niftliyevhuseyn
 
Build 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHSBuild 3D Animated Safety Induction - Tech EHS
Build 3D Animated Safety Induction - Tech EHS
TECH EHS Solution
 
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes Partner Innovation Updates for May 2025
ThousandEyes
 
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdfAre Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Are Cloud PBX Providers in India Reliable for Small Businesses (1).pdf
Telecoms Supermarket
 
Web and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in RajpuraWeb and Graphics Designing Training in Rajpura
Web and Graphics Designing Training in Rajpura
Erginous Technology
 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
 
Generative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in BusinessGenerative Artificial Intelligence (GenAI) in Business
Generative Artificial Intelligence (GenAI) in Business
Dr. Tathagat Varma
 
Social Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTechSocial Media App Development Company-EmizenTech
Social Media App Development Company-EmizenTech
Steve Jonas
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.Greenhouse_Monitoring_Presentation.pptx.
Greenhouse_Monitoring_Presentation.pptx.
hpbmnnxrvb
 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
 
Vaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without HallucinationsVaibhav Gupta BAML: AI work flows without Hallucinations
Vaibhav Gupta BAML: AI work flows without Hallucinations
john409870
 
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven InsightsAndrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell: Transforming Business Strategy Through Data-Driven Insights
Andrew Marnell
 
Mastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdfMastering Advance Window Functions in SQL.pdf
Mastering Advance Window Functions in SQL.pdf
Spiral Mantra
 
Procurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptxProcurement Insights Cost To Value Guide.pptx
Procurement Insights Cost To Value Guide.pptx
Jon Hansen
 
tecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdftecnologias de las primeras civilizaciones.pdf
tecnologias de las primeras civilizaciones.pdf
fjgm517
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 

Groovy - Grails as a modern scripting language for Web applications

  • 1. Groovy & Grails Scripting for Modern Web Applications Rohit Nayak Talentica Software
  • 2. Agenda  Demo: Quick intro to Grails  Scripting, Web Applications and Grails/Groovy  REST service in Grails − Demo − Internals  Web Client in Grails − Demo − Internals  Perspective
  • 4. Maggi  grails create-app Maggi  Domain class: Noodle, Packaging  grails generate-all Noodle, Packaging  grails run-app
  • 5. Web Frameworks with Scripting  Ruby on Rails (2004)  CakePHP (2005)  Django / Python (2005)  Groovy on Grails (2006)
  • 6. Power of these frameworks  Baked Experience  The Language  Agility / Productivity
  • 7. Baked Experience  Model View Controller  Object-Relational Mapping  Templates  Layout  URL rewriting  Ajax support  XML / JSON support
  • 8. The Language  Dynamic  More expressive code  Smaller code  Native support for Lists, Hashmaps  Lang. support for IO, Net, XML  Idioms for common Design Patterns
  • 9. Agile  Scaffolding  Unit tests  No compile cycles  Built-in webservers  Fail faster!
  • 12. HelloWorld.java public class HelloWorld { String name; public void setName(String name) { this.name = name; } public String getName() { return name; } public String hello() { return “Hello “+ name; } public static void main(String args[]) { HelloWorld helloWorld = new HelloWorld(); helloWorld.setName(“Java”); System.out.println( helloWorld. hello() ); } }
  • 13. HelloWorld.groovy class HelloWorld { String name def hello() { "Hello $name" } } def helloWorld = new HelloWorld(name:"Groovy") println helloWorld.hello()
  • 14. Key Groovy Features  Java-like syntax  Complements Java  Object-oriented  Targets Java VM (JSR-241) − Invoke Java class within Groovy − Invoke Groovy class within Java  Dynamic  Scripting (JSR-223)  Brevity
  • 15. Brevity  Optional semicolons, package prefixes  Automatic imports (java.util.*, java.net.*, java.io.*, groovy…)  GroovyBeans (generated accessors)  Optional typing  Optional return
  • 16. Groovy Gravy  GStrings: ”$book.title: $book.author (${book.reviewers.length})”  Regular expressions: assert ‘12345’ =~ /d+/  Only objects: primitives converted to Reference Types  Lists: def list = [1, 2, 'hello', new java.util.Date()]  Maps: def map = ['name':‘Indic Threads', 'location':‘Pune']  Closures [1,2,3].collect {it*2} ===> [2, 4, 6]  String literals – single, double, triple quotes
  • 17. Closures  Block of statements  First class objects  Parameters including default values  Carries local context def foo(n) { // method return { n += it } // returns closure } def accumulator = foo(1) //curried closure assert accumulator(2) == 3 //assert used for self-documenting, unit-testing assert accumulator(1) == 4
  • 18. Dynamic Programming  Add methods, properties to classes/objects at run-time  Mixins to inject behaviour  Can extend class field-access mechanism  Dynamic method invocation
  • 19. Poolster  Online “football pools” application  Entities: Game, User  Game  Stake, Option, Ends  To join User chooses an Option  REST Webservice backend  Clients: iPhone, Grails, Android, Silverlight
  • 21. Grails – Philosophy  Convention over Configuration − Magic directories − Implicit table names, column names  Don’t Repeat Yourself − Database maps to domain − hasMany defines relationship & declares variable − Layout, form validations  Lightweight − Modify and F5  Strong shoulders − Spring (Grails MVC, DI, Transactions) − Hibernate (GORM) − Ant, JUnit, SiteMesh
  • 22. Grails – Key Features  Database constraints, composition  MySQL integration  URL Mapping  Authentication / Filters  Bootstrapping  Unit test  Logging
  • 24. Grails Web Application  Custom Tag libraries  Session variables  Sitemesh layout  Templates  Internationalization
  • 25. Unseen Gravy  JUnit test cases, Mocking/Stubbing  Web testing with Canoo Webtest  Bootstrapping  Pagination
  • 26. Cons  Learning curve  Performance ?!  Early adopter issues
  • 27. Scripted In Groovy  Canoo WebTest  Tellurium  Ant / Maven config files  SoapUI script step  Spring beans  <YOUR APP HERE> 
  • 28. Invoking Groovy Scripts import java.io.File; import groovy.lang.Binding; import groovy.util.GroovyScriptEngine; public class ScriptEngineEmbedGroovy{ public static void main(String args[]) throws Throwable{ String[] paths = {"C:groovy"}; GroovyScriptEngine gse = new GroovyScriptEngine(paths); Binding binding = new Binding(); Object[] path = {"C:musicmp3"}; binding.setVariable("args",path); gse.run("Songs.groovy", binding); } }
  • 29. Getting Started  groovy.codehaus.org  grails.org  Free e-books − Beginning Groovy and Grails (Apress) − Getting started with Grails (InfoQ)  refcardz.com cheat sheets  ibm.com Mastering Grails, Practically Groovy