SlideShare a Scribd company logo
1 of 27
Download to read offline
Groovy and Grails

      Prabhu
prabhu@prabhu-s.com
Groovy
                         • is an agile and dynamic language for JVM
                         • Features inspired from Python, Ruby …
                         • Seamless integration with all existing
                         Java classes and libraries.


• Groovysh and GroovyConsole
• Can run on .Net 2.0 using IKVM
• Latest version 1.5
• http://groovy.codehaus.org
Features
•   Closures
•   Dynamic Methods
•   List & Maps
•   Better XML/Swing Capabilities
Closure
• Statements enclosed within curly braces
  “{}“
• Can be passed around like variables
• Return value either using return
  keyword or the value of last executed
  statement.
Closure (Contd)
square = { it * it }
square (4)
Output = 16

“it” implicit parameter representing the
   passed value.
Closure (Contd)
square {
   it * it
   return 3
}

square (4)
Output = 3 (Since there is an explicit
  return statement!)
Closure (Contd)
square = { param1 ->
   param1 * param1
}

square (3)
Output = 9
Param1 – Named parameter
Factorial using closures
fact = 1               fact = 1
for (i in 2..5) {      (2..5).each {
                         number ->
   fact *= i
                         fact *= number
}                      }
print fact             print fact

                       // (2..5) = Range
Factorial again!
fact = 1
2.upto(5) { num ->
  fact *= num
}
print fact

// Numbers are treated as object.
• upto method generates all number objects
• To each object, the closure gets passed
   around!
Generic Factorial
fact = 1
fun = { n->
       2.upto(n) { num ->
       fact *= num
  }
}

fun(5)
print fact
Dynamic methods
class webcamp {
  def haveTea() {
     println quot;Time for teaquot;
  }
}

camp = new webcamp()
camp.haveTea()
Dynamic methods (Contd)
• Add a new method “haveSamosa”
class webcamp {
   def haveTea() {
         println quot;Time for tea“
   }
}
camp = new webcamp()
camp.haveTea()

webcamp.metaClass.haveSamosa = { ->
  println quot;Have Samosa alsoquot;
}

camp = new webcamp() // Create a fresh object since the class has
   changed!
camp.haveSamosa()
Lists and Maps
• Like python
List = [2,3,4]
Map = [„a‟ : 2, „b‟ : new Date()]
Grails
• Web Framework inspired by RoR
• Latest version is 1.0.1.
   – The one in the DVD is 1.0 and doesn‟t run cleanly in
     windows!
• Grails = Spring MVC 2.5.1 + Hibernate 3 +
  SiteMesh 2.3
• Newbie‟s are unaware that Grails is full and full
  Spring!
• Provides several commands to auto generate
  code.
• Comes bundled with HSQLDB.
Create your first app
• Set environmental variables
  GRAILS_HOME and PATH
• grails create-app firstapp
Directory Structure

                      Controllers
        Domain



            Views


            Sources

            Test cases


            J2EE Web Appln.
First app Demo
• grails create-domain-class <name>
• grails create-controller <name>
• grails run-app (Starts inbuilt Jetty 6.1.4
  server)
• Visit http://localhost:8080/firstapp
• Demo
Features
• Both gsp and jsp are supported.
• Specify constraints
static constraints = {
      username (minLength : 3, maxLength: 8, blank:false)
      password(minLength : 5, maxLength:9, blank:false)
   }


• Specify Optional fields
static optionals = [“middle_name”, “addr2”]
Features (Contd)
• Dynamic finder methods
def search = {
   render(view : „list‟,
        model : [userList :
                      User.findAllByUsernameLike (
                           „%‟ + params.username + „%‟)
                 ]
        )
}

• User.findAllByUsernameLikeAndPassword
  Like
Features (Contd)
• Create Advanced Search criteria using
  Hibernate Criteria Builder.
def criteria = User.createCriteria() // Dynamic method
def results = criteria {
   and (
          like („username‟ , „%‟ + params.username + „%‟)
          le(„age‟, params.age)
          )
}
Render(view:‟list‟, model:[userList : results])
Features (Contd)
• Flash scope - Data will be stored as
  name-value pairs for current request
  and the next request.
• Create custom tags just by creating a
  new file in grails-
  app/taglib/<name>TagLib.groovy
Features (Contd)
• AJAX Support
  – Supports prototype, YUI, DOJO
  – Use render method in your groovy code to
    render text, HTML, JSON or OpenRico
    Response XMLs
• Plays nicely with flex
  – Simply add this
    static expose = [“flex-remoting”]
  – Automatic flex based CRUD generation and
    Domain class to AS3 compilation coming up!
Features (Contd)
• Plays nicely with EJB
  – http://www.infoq.com/articles/grails-ejb-
    tutorial
• Has lots of plugins already!
  – grails install-plugin <name>
  – grails create-plugin <name>
Scalability
• Thanks to Spring and Hibernate, Grails
  is highly scalable and already enterprise
  ready!
RoR Competition?
• No.
  – Instead going to compete with Java based
    frameworks like struts 2, JSF, Seam.
Should I learn?
• If you are a Java guy, then yes.
• Companies like Oracle have already
  started showing full support!
Thanks



Q&A

More Related Content

What's hot

Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJSstefanmayer13
 
Understanding the nodejs event loop
Understanding the nodejs event loopUnderstanding the nodejs event loop
Understanding the nodejs event loopSaurabh Kumar
 
Declarative Infrastructure Tools
Declarative Infrastructure Tools Declarative Infrastructure Tools
Declarative Infrastructure Tools Yulia Shcherbachova
 
Tweaking performance on high-load projects
Tweaking performance on high-load projectsTweaking performance on high-load projects
Tweaking performance on high-load projectsDmitriy Dumanskiy
 
Introduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaFlorent Pillet
 
Handling 20 billion requests a month
Handling 20 billion requests a monthHandling 20 billion requests a month
Handling 20 billion requests a monthDmitriy Dumanskiy
 
JVM performance options. How it works
JVM performance options. How it worksJVM performance options. How it works
JVM performance options. How it worksDmitriy Dumanskiy
 
Talk KVO with rac by Philippe Converset
Talk KVO with rac by Philippe ConversetTalk KVO with rac by Philippe Converset
Talk KVO with rac by Philippe ConversetCocoaHeads France
 
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)GlobalLogic Ukraine
 
Go Containers
Go ContainersGo Containers
Go Containersjgrahamc
 
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftReactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftFlorent Pillet
 
Cascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the StreamsCascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the Streamsmattpodwysocki
 
Scalable Angular 2 Application Architecture
Scalable Angular 2 Application ArchitectureScalable Angular 2 Application Architecture
Scalable Angular 2 Application ArchitectureFDConf
 
Async Microservices with Twitter's Finagle
Async Microservices with Twitter's FinagleAsync Microservices with Twitter's Finagle
Async Microservices with Twitter's FinagleVladimir Kostyukov
 
Luis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"OdessaJS Conf
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency designHyejong
 
The What, Why And How of ClojureScript
The What, Why And How of ClojureScriptThe What, Why And How of ClojureScript
The What, Why And How of ClojureScriptIvan Bokii
 

What's hot (20)

Groovyノススメ
GroovyノススメGroovyノススメ
Groovyノススメ
 
Functional Reactive Programming with RxJS
Functional Reactive Programming with RxJSFunctional Reactive Programming with RxJS
Functional Reactive Programming with RxJS
 
Understanding the nodejs event loop
Understanding the nodejs event loopUnderstanding the nodejs event loop
Understanding the nodejs event loop
 
Declarative Infrastructure Tools
Declarative Infrastructure Tools Declarative Infrastructure Tools
Declarative Infrastructure Tools
 
Tweaking performance on high-load projects
Tweaking performance on high-load projectsTweaking performance on high-load projects
Tweaking performance on high-load projects
 
Introduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoaIntroduction to reactive programming & ReactiveCocoa
Introduction to reactive programming & ReactiveCocoa
 
Handling 20 billion requests a month
Handling 20 billion requests a monthHandling 20 billion requests a month
Handling 20 billion requests a month
 
JVM performance options. How it works
JVM performance options. How it worksJVM performance options. How it works
JVM performance options. How it works
 
Talk KVO with rac by Philippe Converset
Talk KVO with rac by Philippe ConversetTalk KVO with rac by Philippe Converset
Talk KVO with rac by Philippe Converset
 
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
Silent Revolution by Max Voronoy (Senior Consultant, Engineering, Globallogic)
 
Go Containers
Go ContainersGo Containers
Go Containers
 
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwiftReactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwift
 
Graphql with Flamingo
Graphql with FlamingoGraphql with Flamingo
Graphql with Flamingo
 
Cascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the StreamsCascadia.js: Don't Cross the Streams
Cascadia.js: Don't Cross the Streams
 
Scalable Angular 2 Application Architecture
Scalable Angular 2 Application ArchitectureScalable Angular 2 Application Architecture
Scalable Angular 2 Application Architecture
 
Async Microservices with Twitter's Finagle
Async Microservices with Twitter's FinagleAsync Microservices with Twitter's Finagle
Async Microservices with Twitter's Finagle
 
Luis Atencio on RxJS
Luis Atencio on RxJSLuis Atencio on RxJS
Luis Atencio on RxJS
 
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
Timur Shemsedinov "Пишу на колбеках, а что... (Асинхронное программирование)"
 
Golang concurrency design
Golang concurrency designGolang concurrency design
Golang concurrency design
 
The What, Why And How of ClojureScript
The What, Why And How of ClojureScriptThe What, Why And How of ClojureScript
The What, Why And How of ClojureScript
 

Similar to Groovy and Grails talk

What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?Christophe Porteneuve
 
JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)jeresig
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Jonathan Felch
 
MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptCaridy Patino
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Tsuyoshi Yamamoto
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2rubyMarc Chung
 
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume LaforgeGroovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume LaforgeGuillaume Laforge
 
React Native One Day
React Native One DayReact Native One Day
React Native One DayTroy Miles
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot CampTroy Miles
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、GaelykでハンズオンTsuyoshi Yamamoto
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGLChihoon Byun
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for youSimon Willison
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for JavaCharles Anderson
 
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume LaforgeGR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume LaforgeGR8Conf
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기경주 전
 
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 Wsloffenauer
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extremeyinonavraham
 

Similar to Groovy and Grails talk (20)

What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?What's up with Prototype and script.aculo.us?
What's up with Prototype and script.aculo.us?
 
JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)JavaScript 1.5 to 2.0 (TomTom)
JavaScript 1.5 to 2.0 (TomTom)
 
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
 
MiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScriptMiamiJS - The Future of JavaScript
MiamiJS - The Future of JavaScript
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
Groovy.pptx
Groovy.pptxGroovy.pptx
Groovy.pptx
 
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume LaforgeGroovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
Groovy in the Enterprise - Case Studies - TSSJS Prague 2008 - Guillaume Laforge
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
名古屋SGGAE/J勉強会 Grails、Gaelykでハンズオン
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGL
 
How to make Ajax work for you
How to make Ajax work for youHow to make Ajax work for you
How to make Ajax work for you
 
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume Laforge
 
Groovy a Scripting Language for Java
Groovy a Scripting Language for JavaGroovy a Scripting Language for Java
Groovy a Scripting Language for Java
 
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume LaforgeGR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
GR8Conf 2009: What's New in Groovy 1.6? by Guillaume Laforge
 
.gradle 파일 정독해보기
.gradle 파일 정독해보기.gradle 파일 정독해보기
.gradle 파일 정독해보기
 
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
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extreme
 
Groovy
GroovyGroovy
Groovy
 

Recently uploaded

RATINGS OF EACH VIDEO FOR UNI PROJECT IWDSFODF
RATINGS OF EACH VIDEO FOR UNI PROJECT IWDSFODFRATINGS OF EACH VIDEO FOR UNI PROJECT IWDSFODF
RATINGS OF EACH VIDEO FOR UNI PROJECT IWDSFODFCaitlinCummins3
 
tekAura | Desktop Procedure Template (2016)
tekAura | Desktop Procedure Template (2016)tekAura | Desktop Procedure Template (2016)
tekAura | Desktop Procedure Template (2016)Norah Medlin
 
What is paper chromatography, principal, procedure,types, diagram, advantages...
What is paper chromatography, principal, procedure,types, diagram, advantages...What is paper chromatography, principal, procedure,types, diagram, advantages...
What is paper chromatography, principal, procedure,types, diagram, advantages...srcw2322l101
 
Your Work Matters to God RestorationChurch.pptx
Your Work Matters to God RestorationChurch.pptxYour Work Matters to God RestorationChurch.pptx
Your Work Matters to God RestorationChurch.pptxOs Hillman
 
TriStar Gold Corporate Presentation May 2024
TriStar Gold Corporate Presentation May 2024TriStar Gold Corporate Presentation May 2024
TriStar Gold Corporate Presentation May 2024Adnet Communications
 
8 Questions B2B Commercial Teams Can Ask To Help Product Discovery
8 Questions B2B Commercial Teams Can Ask To Help Product Discovery8 Questions B2B Commercial Teams Can Ask To Help Product Discovery
8 Questions B2B Commercial Teams Can Ask To Help Product DiscoveryDesmond Leo
 
A Brief Introduction About Jacob Badgett
A Brief Introduction About Jacob BadgettA Brief Introduction About Jacob Badgett
A Brief Introduction About Jacob BadgettJacobBadgett
 
Inside the Black Box of Venture Capital (VC)
Inside the Black Box of Venture Capital (VC)Inside the Black Box of Venture Capital (VC)
Inside the Black Box of Venture Capital (VC)Alejandro Cremades
 
wagamamaLab presentation @MIT 20240509 IRODORI
wagamamaLab presentation @MIT 20240509 IRODORIwagamamaLab presentation @MIT 20240509 IRODORI
wagamamaLab presentation @MIT 20240509 IRODORIIRODORI inc.
 
How to Maintain Healthy Life style.pptx
How to Maintain  Healthy Life style.pptxHow to Maintain  Healthy Life style.pptx
How to Maintain Healthy Life style.pptxrdishurana
 
Special Purpose Vehicle (Purpose, Formation & examples)
Special Purpose Vehicle (Purpose, Formation & examples)Special Purpose Vehicle (Purpose, Formation & examples)
Special Purpose Vehicle (Purpose, Formation & examples)linciy03
 
Toyota Kata Coaching for Agile Teams & Transformations
Toyota Kata Coaching for Agile Teams & TransformationsToyota Kata Coaching for Agile Teams & Transformations
Toyota Kata Coaching for Agile Teams & TransformationsStefan Wolpers
 
NewBase 17 May 2024 Energy News issue - 1725 by Khaled Al Awadi_compresse...
NewBase   17 May  2024  Energy News issue - 1725 by Khaled Al Awadi_compresse...NewBase   17 May  2024  Energy News issue - 1725 by Khaled Al Awadi_compresse...
NewBase 17 May 2024 Energy News issue - 1725 by Khaled Al Awadi_compresse...Khaled Al Awadi
 
Aptar Closures segment - Corporate Overview-India.pdf
Aptar Closures segment - Corporate Overview-India.pdfAptar Closures segment - Corporate Overview-India.pdf
Aptar Closures segment - Corporate Overview-India.pdfprchbhandari
 
Hyundai capital 2024 1q Earnings release
Hyundai capital 2024 1q Earnings releaseHyundai capital 2024 1q Earnings release
Hyundai capital 2024 1q Earnings releaseirhcs
 
NFS- Operations Presentation - Recurrent
NFS- Operations Presentation - RecurrentNFS- Operations Presentation - Recurrent
NFS- Operations Presentation - Recurrenttoniquemcintosh1
 
Sedex Members Ethical Trade Audit (SMETA) Measurement Criteria
Sedex Members Ethical Trade Audit (SMETA) Measurement CriteriaSedex Members Ethical Trade Audit (SMETA) Measurement Criteria
Sedex Members Ethical Trade Audit (SMETA) Measurement Criteriamilos639
 
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdf
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdfInnomantra Viewpoint - Building Moonshots : May-Jun 2024.pdf
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdfInnomantra
 
Creative Ideas for Interactive Team Presentations
Creative Ideas for Interactive Team PresentationsCreative Ideas for Interactive Team Presentations
Creative Ideas for Interactive Team PresentationsSlidesAI
 
1Q24_EN hyundai capital 1q performance
1Q24_EN   hyundai capital 1q performance1Q24_EN   hyundai capital 1q performance
1Q24_EN hyundai capital 1q performanceirhcs
 

Recently uploaded (20)

RATINGS OF EACH VIDEO FOR UNI PROJECT IWDSFODF
RATINGS OF EACH VIDEO FOR UNI PROJECT IWDSFODFRATINGS OF EACH VIDEO FOR UNI PROJECT IWDSFODF
RATINGS OF EACH VIDEO FOR UNI PROJECT IWDSFODF
 
tekAura | Desktop Procedure Template (2016)
tekAura | Desktop Procedure Template (2016)tekAura | Desktop Procedure Template (2016)
tekAura | Desktop Procedure Template (2016)
 
What is paper chromatography, principal, procedure,types, diagram, advantages...
What is paper chromatography, principal, procedure,types, diagram, advantages...What is paper chromatography, principal, procedure,types, diagram, advantages...
What is paper chromatography, principal, procedure,types, diagram, advantages...
 
Your Work Matters to God RestorationChurch.pptx
Your Work Matters to God RestorationChurch.pptxYour Work Matters to God RestorationChurch.pptx
Your Work Matters to God RestorationChurch.pptx
 
TriStar Gold Corporate Presentation May 2024
TriStar Gold Corporate Presentation May 2024TriStar Gold Corporate Presentation May 2024
TriStar Gold Corporate Presentation May 2024
 
8 Questions B2B Commercial Teams Can Ask To Help Product Discovery
8 Questions B2B Commercial Teams Can Ask To Help Product Discovery8 Questions B2B Commercial Teams Can Ask To Help Product Discovery
8 Questions B2B Commercial Teams Can Ask To Help Product Discovery
 
A Brief Introduction About Jacob Badgett
A Brief Introduction About Jacob BadgettA Brief Introduction About Jacob Badgett
A Brief Introduction About Jacob Badgett
 
Inside the Black Box of Venture Capital (VC)
Inside the Black Box of Venture Capital (VC)Inside the Black Box of Venture Capital (VC)
Inside the Black Box of Venture Capital (VC)
 
wagamamaLab presentation @MIT 20240509 IRODORI
wagamamaLab presentation @MIT 20240509 IRODORIwagamamaLab presentation @MIT 20240509 IRODORI
wagamamaLab presentation @MIT 20240509 IRODORI
 
How to Maintain Healthy Life style.pptx
How to Maintain  Healthy Life style.pptxHow to Maintain  Healthy Life style.pptx
How to Maintain Healthy Life style.pptx
 
Special Purpose Vehicle (Purpose, Formation & examples)
Special Purpose Vehicle (Purpose, Formation & examples)Special Purpose Vehicle (Purpose, Formation & examples)
Special Purpose Vehicle (Purpose, Formation & examples)
 
Toyota Kata Coaching for Agile Teams & Transformations
Toyota Kata Coaching for Agile Teams & TransformationsToyota Kata Coaching for Agile Teams & Transformations
Toyota Kata Coaching for Agile Teams & Transformations
 
NewBase 17 May 2024 Energy News issue - 1725 by Khaled Al Awadi_compresse...
NewBase   17 May  2024  Energy News issue - 1725 by Khaled Al Awadi_compresse...NewBase   17 May  2024  Energy News issue - 1725 by Khaled Al Awadi_compresse...
NewBase 17 May 2024 Energy News issue - 1725 by Khaled Al Awadi_compresse...
 
Aptar Closures segment - Corporate Overview-India.pdf
Aptar Closures segment - Corporate Overview-India.pdfAptar Closures segment - Corporate Overview-India.pdf
Aptar Closures segment - Corporate Overview-India.pdf
 
Hyundai capital 2024 1q Earnings release
Hyundai capital 2024 1q Earnings releaseHyundai capital 2024 1q Earnings release
Hyundai capital 2024 1q Earnings release
 
NFS- Operations Presentation - Recurrent
NFS- Operations Presentation - RecurrentNFS- Operations Presentation - Recurrent
NFS- Operations Presentation - Recurrent
 
Sedex Members Ethical Trade Audit (SMETA) Measurement Criteria
Sedex Members Ethical Trade Audit (SMETA) Measurement CriteriaSedex Members Ethical Trade Audit (SMETA) Measurement Criteria
Sedex Members Ethical Trade Audit (SMETA) Measurement Criteria
 
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdf
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdfInnomantra Viewpoint - Building Moonshots : May-Jun 2024.pdf
Innomantra Viewpoint - Building Moonshots : May-Jun 2024.pdf
 
Creative Ideas for Interactive Team Presentations
Creative Ideas for Interactive Team PresentationsCreative Ideas for Interactive Team Presentations
Creative Ideas for Interactive Team Presentations
 
1Q24_EN hyundai capital 1q performance
1Q24_EN   hyundai capital 1q performance1Q24_EN   hyundai capital 1q performance
1Q24_EN hyundai capital 1q performance
 

Groovy and Grails talk

  • 1. Groovy and Grails Prabhu prabhu@prabhu-s.com
  • 2. Groovy • is an agile and dynamic language for JVM • Features inspired from Python, Ruby … • Seamless integration with all existing Java classes and libraries. • Groovysh and GroovyConsole • Can run on .Net 2.0 using IKVM • Latest version 1.5 • http://groovy.codehaus.org
  • 3. Features • Closures • Dynamic Methods • List & Maps • Better XML/Swing Capabilities
  • 4. Closure • Statements enclosed within curly braces “{}“ • Can be passed around like variables • Return value either using return keyword or the value of last executed statement.
  • 5. Closure (Contd) square = { it * it } square (4) Output = 16 “it” implicit parameter representing the passed value.
  • 6. Closure (Contd) square { it * it return 3 } square (4) Output = 3 (Since there is an explicit return statement!)
  • 7. Closure (Contd) square = { param1 -> param1 * param1 } square (3) Output = 9 Param1 – Named parameter
  • 8. Factorial using closures fact = 1 fact = 1 for (i in 2..5) { (2..5).each { number -> fact *= i fact *= number } } print fact print fact // (2..5) = Range
  • 9. Factorial again! fact = 1 2.upto(5) { num -> fact *= num } print fact // Numbers are treated as object. • upto method generates all number objects • To each object, the closure gets passed around!
  • 10. Generic Factorial fact = 1 fun = { n-> 2.upto(n) { num -> fact *= num } } fun(5) print fact
  • 11. Dynamic methods class webcamp { def haveTea() { println quot;Time for teaquot; } } camp = new webcamp() camp.haveTea()
  • 12. Dynamic methods (Contd) • Add a new method “haveSamosa” class webcamp { def haveTea() { println quot;Time for tea“ } } camp = new webcamp() camp.haveTea() webcamp.metaClass.haveSamosa = { -> println quot;Have Samosa alsoquot; } camp = new webcamp() // Create a fresh object since the class has changed! camp.haveSamosa()
  • 13. Lists and Maps • Like python List = [2,3,4] Map = [„a‟ : 2, „b‟ : new Date()]
  • 14. Grails • Web Framework inspired by RoR • Latest version is 1.0.1. – The one in the DVD is 1.0 and doesn‟t run cleanly in windows! • Grails = Spring MVC 2.5.1 + Hibernate 3 + SiteMesh 2.3 • Newbie‟s are unaware that Grails is full and full Spring! • Provides several commands to auto generate code. • Comes bundled with HSQLDB.
  • 15. Create your first app • Set environmental variables GRAILS_HOME and PATH • grails create-app firstapp
  • 16. Directory Structure Controllers Domain Views Sources Test cases J2EE Web Appln.
  • 17. First app Demo • grails create-domain-class <name> • grails create-controller <name> • grails run-app (Starts inbuilt Jetty 6.1.4 server) • Visit http://localhost:8080/firstapp • Demo
  • 18. Features • Both gsp and jsp are supported. • Specify constraints static constraints = { username (minLength : 3, maxLength: 8, blank:false) password(minLength : 5, maxLength:9, blank:false) } • Specify Optional fields static optionals = [“middle_name”, “addr2”]
  • 19. Features (Contd) • Dynamic finder methods def search = { render(view : „list‟, model : [userList : User.findAllByUsernameLike ( „%‟ + params.username + „%‟) ] ) } • User.findAllByUsernameLikeAndPassword Like
  • 20. Features (Contd) • Create Advanced Search criteria using Hibernate Criteria Builder. def criteria = User.createCriteria() // Dynamic method def results = criteria { and ( like („username‟ , „%‟ + params.username + „%‟) le(„age‟, params.age) ) } Render(view:‟list‟, model:[userList : results])
  • 21. Features (Contd) • Flash scope - Data will be stored as name-value pairs for current request and the next request. • Create custom tags just by creating a new file in grails- app/taglib/<name>TagLib.groovy
  • 22. Features (Contd) • AJAX Support – Supports prototype, YUI, DOJO – Use render method in your groovy code to render text, HTML, JSON or OpenRico Response XMLs • Plays nicely with flex – Simply add this static expose = [“flex-remoting”] – Automatic flex based CRUD generation and Domain class to AS3 compilation coming up!
  • 23. Features (Contd) • Plays nicely with EJB – http://www.infoq.com/articles/grails-ejb- tutorial • Has lots of plugins already! – grails install-plugin <name> – grails create-plugin <name>
  • 24. Scalability • Thanks to Spring and Hibernate, Grails is highly scalable and already enterprise ready!
  • 25. RoR Competition? • No. – Instead going to compete with Java based frameworks like struts 2, JSF, Seam.
  • 26. Should I learn? • If you are a Java guy, then yes. • Companies like Oracle have already started showing full support!