SlideShare una empresa de Scribd logo
1 de 31
Descargar para leer sin conexión
Groovy and Grails
                                       in Google App Engine

                        Benefit from a Java-like dynamic language
                          to be more productive on App Engine

                                                     Guillaume Laforge
                                                 Head of Groovy Development


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
Guillaume Laforge

   • Groovy Project Manager
   • JSR-241 Spec Lead
   • Head of Groovy Development
     at SpringSource
   • Initiator of the Grails framework

   • Co-author of Groovy in Action

   • Speaker: JavaOne, QCon, JavaZone, Sun TechDays,
     Devoxx, The Spring Experience, JAX, Dynamic
     Language World, IJTC, and more...

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   2
nda
               Ag e                                                                                             •Groovy overview
                                                                                                                     –Features at a glance
                                                                                                                     –Groovlets
                                                                                                                     –Groovy templates


                                                                                                                • Grails overview
                                                                                                                     – The Grails stack
                                                                                                                     – The App Engine plugin


                                                                                                                • Summary

                                                                                                                • Q&A

Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                      3
A few words about Groovy

   • Groovy is a dynamic language for the JVM
           – with a Meta Object Protocol
           – compiles directly to bytecode, seamless Java interop


   • Open Source ASL 2 project hosted at Codehaus

   • Relaxed grammar derived from Java 5
           – Java 5 features out-of-the-box: annotations, generics,
             static imports, enums, varargs...
           – borrowed good ideas from Ruby, Python, Smalltalk
           – flat learning curve for Java developers


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   4
Features at a glance

   • Fully Object-Oriented
   • Joint compiler: seamless Java integration
   • Closures: reusable/assignable code blocks
   • Properties: no more getters / setters
   • Optional typing: you decide!
   • Various shortcut notations: less verbose than Java
   • Handy wrapper APIs
           – Groovlets, XML, JDBC, JMX, template engine, Swing
             UIs, collections...
   • Strong ability for authoring Domain-Specific
     Languages

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   5
A “normal” servlet

   • Writing a servlet is no different than a classical
     standard Java servlet
           – only a bit leaner: properties, semis, public keyword...

   • import javax.servlet.http.*

         class HelloServlet extends HttpServlet {
             void doGet(HttpServletRequest req,
                        HttpServletResponse resp)
                 throws IOException {
                 resp.contentType = quot;text/plainquot;
                 resp.writer.println quot;Hello World!quot;
             }
         }

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   6
Groovylets: Groovy servlets

   • General idea
           – use scripts over classes
           – use Groovy’s markup builder to easily create HTML

   • html.html {
         head {
             title quot;Helloquot;
         }
         body {
             p quot;Hello Groovy World!quot;
         }
     }



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   7
Groovylets: Groovy servlets

   • Refererence the GroovyServlet in web.xml
   • Add a URL mapping

   • <servlet>
       <servlet-name>GroovyServlet</servlet-name>
         <servlet-class>
           groovy.servlet.GroovyServlet
         </servlet-class>
     </servlet>

         <servlet-mapping>
           <servlet-name>GroovyServlet</servlet-name>
           <url-pattern>*.groovy</url-pattern>
         </servlet-mapping>


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   8
Groovy templates

   • Groovy comes built-in with templating capability

   • import groovy.text.SimpleTemplateEngine

         def text =                              '''Dear $firstname,
         So nice to                              meet you in <% print city %>.
         See you in                              ${month},
         <%= signed                              %>'''

         def binding = [firstname: quot;Guillaumequot;, month: quot;Junequot;,
                        city: quot;San Franciscoquot;, signed: quot;Dukequot;]

         def engine = new SimpleTemplateEngine()

         template = engine.createTemplate(text)
                          .make(binding)

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   9
The Servlet template

   • Similar to JSPs
           – <html>
               <body>
                 <p>${message}</p>
               </body>
             </html>


   • In your web.xml
           – <servlet>
               <servlet-name>GroovyTemplateServlet</servlet-name>
                 <servlet-class>
                   groovy.servlet.TemplateServlet
                 </servlet-class>
             </servlet>
             <servlet-mapping>
               <servlet-name>GroovyTemplateServlet</servlet-name>
               <url-pattern>*.gtpl</url-pattern>
             </servlet-mapping>

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   10
F GAELYK
   • A thin layer on top of:
           – Groovlets & servlet template
           – Google App Engine Java SDK APIs


   • What it does
           – Inject all the services in servlets and templates
           – Adds syntax sugar and dynamic methods to the SDK API




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   11
nda
               Ag e                                                                                             • Groovy overview
                                                                                                                     – Features at a glance
                                                                                                                     – Groovlets
                                                                                                                     – Groovy templates


                                                                                                                •Grails overview
                                                                                                                     –The Grails stack
                                                                                                                     –The App Engine plugin


                                                                                                                • Summary

                                                                                                                • Q&A

Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                       12
From 10,000 feet...




                                                                                       =


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   13
From 10,000 feet...




                                                                                       =


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   13
From 10,000 feet...




                                                                                       =
                                                      +

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   13
From 10,000 feet...




                                                                                       =
                                                      +

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   13
From 10,000 feet...




                                                                                       =
                                                      +                                                              +

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.       13
From 10,000 feet...




                                                                                       =
                                                      +                                                              +

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.       13
In a few bullet points...

   • Grails is a full stack web app development env.
           – built on rock-solid and proven OSS frameworks
                  •Spring, Spring MVC, Spring WebFlow
                  •Hibernate, SiteMesh, Quartz
                  •Jetty, HSQLDB
           – provides its ORM layer on top of Hibernate
           – has got its own integrated build system and CLI
   • Follows good and lean principles
           – Convention over Configuration, MVC, DRY...
   • Provides powerful time-saving capabilities
           – Scaffolding, an extensible plugin system, taglibs,
             templates, and more

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   14
The big picture



                                                                               Grails




                                                                                                                                Groovy
                                         Java
                                      Enterprise                         Spring                 Hibernate            SiteMesh
                                     Edition (JEE)


                                                                                                 The Java Development
                                             The Java Language
                                                                                                       Kit (JDK)



                                                                                 The Java Virtual Machine




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                       15
The big picture



                                                                               Grails




                                                                                                                                Groovy
                                         Java
                                      Enterprise                         Spring                 Hibernate            SiteMesh
                                     Edition (JEE)


                                                                                                 The Java Development
                                             The Java Language
                                                                                                       Kit (JDK)



                                                                                 The Java Virtual Machine




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                       15
The standard project structure




                                 M                                                                                   C

                                   V

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.       16
The App Engine plugin

   • Grails has got a very extensive and rich plugin
     system and ecosystem
           – 100+ existing and useful plugins available
                  •GWT, Flex, YUI, iUI, JMS, search, security, testing...


   • A Google App Engine plugin was developed
           – following the Grails development flow
           – abstracts the app engine commands for deployments
           – leverages the local engine




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   17
Setting up your project

   • Create your Grails application as usual
                      grails create-app myapp


   • Specify the App Engine app id
                      google.appengine.application = quot;myappquot;


   • Uninstall hibernate and install the GAE plugin
                      grails uninstall-plugin hibernate
                      grails install-plugin app-engine


   • Run the application locally
                      grails app-engine run


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   18
Deploying applications

   • Set the version number to 1, as Grails uses a
     different numbering scheme (x.y)
                      grails set-version 1


   • Get your application ready
                      grails app-engine package


   • On first deployment
                      $APPENGINE_HOME/appcfg.sh update ./target/war


   • For subsequent deployments
                      grails app-engine deploy


Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   19
DEMO
Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   20
nda
               Ag e                                                                                             • Groovy overview
                                                                                                                     – Features at a glance
                                                                                                                     – Groovlets
                                                                                                                     – Groovy templates


                                                                                                                • Grails overview
                                                                                                                     – The Grails stack
                                                                                                                     – The App Engine plugin


                                                                                                                •Summary

                                                                                                                • Q&A

Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                       21
Summary

   • Groovy
           – Groovy is a first-class citizen on Google App Engine
           – Lots of shorcut notations can streamline your code
           – Groovy servlets and templates are great for crafting
             small applications
           – Gaelyk further simplifies this pure Groovy approach


   • Grails
           – Grails is the next-generation web development stack
           – Developing Grails application on the Google cloud is
             almost as lean and simple as for the usual crop of
             application servers

Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   22
Further information

   • Groovy in Google App Engine
           – http://blog.springsource.com/2009/04/07/write-your-
             google-app-engine-applications-in-groovy/


   • Grails in Google App Engine
           – the Grails 1.1.1 release and App Engine screencast
                  •http://blog.springsource.com/2009/05/14/grails-111-
                   released-with-google-appengine-support/


           – the Google App Engine Grails plugin
                  •http://grails.org/plugin/app-engine



Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   23
nda
               Ag e                                                                                             • Groovy overview
                                                                                                                     – Features at a glance
                                                                                                                     – Groovlets
                                                                                                                     – Groovy templates


                                                                                                                • Grails overview
                                                                                                                     – The Grails stack
                                                                                                                     – The App Engine plugin


                                                                                                                • Summary

                                                                                                                •Q&A

Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.                       24
Q&A




   • Questions & perhaps...

         even answers :-)




Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.   25

Más contenido relacionado

Similar a Groovy Grails App Engine

Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009Guillaume Laforge
 
Scripting Support in GFv3 Prelude - Full Version
Scripting Support in GFv3 Prelude - Full VersionScripting Support in GFv3 Prelude - Full Version
Scripting Support in GFv3 Prelude - Full VersionEduardo Pelegri-Llopart
 
Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2360|Conferences
 
Groovy Online 100
Groovy Online 100Groovy Online 100
Groovy Online 100reynolds
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails IntroductionEric Weimer
 
Introduction To Groovy And Grails - SpringPeople
Introduction To Groovy And Grails - SpringPeopleIntroduction To Groovy And Grails - SpringPeople
Introduction To Groovy And Grails - SpringPeopleSpringPeople
 
Scripting Support in GlassFish v3 Prelude
Scripting Support in GlassFish v3 PreludeScripting Support in GlassFish v3 Prelude
Scripting Support in GlassFish v3 PreludeEduardo Pelegri-Llopart
 
Blueprint talk at Open Hackday London 2009
Blueprint talk at Open Hackday London 2009Blueprint talk at Open Hackday London 2009
Blueprint talk at Open Hackday London 2009Ricardo Varela
 
Unobtrusive Javascript - SD.rb 2007
Unobtrusive Javascript - SD.rb 2007Unobtrusive Javascript - SD.rb 2007
Unobtrusive Javascript - SD.rb 2007matta
 
Úvod do programování 7
Úvod do programování 7Úvod do programování 7
Úvod do programování 7Karel Minarik
 
Bfg Ploneconf Oct2008
Bfg Ploneconf Oct2008Bfg Ploneconf Oct2008
Bfg Ploneconf Oct2008Jeffrey Clark
 
Magic with groovy & grails
Magic with groovy & grailsMagic with groovy & grails
Magic with groovy & grailsGeorge Platon
 
Groovy Testing Sep2009
Groovy Testing Sep2009Groovy Testing Sep2009
Groovy Testing Sep2009Paul King
 
Javascript Dependency Management
Javascript Dependency ManagementJavascript Dependency Management
Javascript Dependency ManagementSean Duncan
 
Writing Domain-Specific Languages in Groovy
Writing Domain-Specific Languages in GroovyWriting Domain-Specific Languages in Groovy
Writing Domain-Specific Languages in GroovyGuillaume Laforge
 
Groovy Testing Aug2009
Groovy Testing Aug2009Groovy Testing Aug2009
Groovy Testing Aug2009guest4a266c
 

Similar a Groovy Grails App Engine (20)

Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
Introduction to Groovy and what's New in Groovy 1.6 - SpringOne Europe 2009
 
Scripting Support in GFv3 Prelude - Full Version
Scripting Support in GFv3 Prelude - Full VersionScripting Support in GFv3 Prelude - Full Version
Scripting Support in GFv3 Prelude - Full Version
 
Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2Samuel Asher Rivello - PureMVC Hands On Part 2
Samuel Asher Rivello - PureMVC Hands On Part 2
 
Whats New In Groovy 1.6?
Whats New In Groovy 1.6?Whats New In Groovy 1.6?
Whats New In Groovy 1.6?
 
Whats New In Groovy 1.6?
Whats New In Groovy 1.6?Whats New In Groovy 1.6?
Whats New In Groovy 1.6?
 
Groovy Online 100
Groovy Online 100Groovy Online 100
Groovy Online 100
 
Groovy And Grails Introduction
Groovy And Grails IntroductionGroovy And Grails Introduction
Groovy And Grails Introduction
 
Introduction To Groovy And Grails - SpringPeople
Introduction To Groovy And Grails - SpringPeopleIntroduction To Groovy And Grails - SpringPeople
Introduction To Groovy And Grails - SpringPeople
 
groovy
groovygroovy
groovy
 
Scripting Support in GlassFish v3 Prelude
Scripting Support in GlassFish v3 PreludeScripting Support in GlassFish v3 Prelude
Scripting Support in GlassFish v3 Prelude
 
Blueprint talk at Open Hackday London 2009
Blueprint talk at Open Hackday London 2009Blueprint talk at Open Hackday London 2009
Blueprint talk at Open Hackday London 2009
 
Unobtrusive Javascript - SD.rb 2007
Unobtrusive Javascript - SD.rb 2007Unobtrusive Javascript - SD.rb 2007
Unobtrusive Javascript - SD.rb 2007
 
Úvod do programování 7
Úvod do programování 7Úvod do programování 7
Úvod do programování 7
 
GlassFish v3 Prelude Aquarium Paris
GlassFish v3 Prelude Aquarium ParisGlassFish v3 Prelude Aquarium Paris
GlassFish v3 Prelude Aquarium Paris
 
Bfg Ploneconf Oct2008
Bfg Ploneconf Oct2008Bfg Ploneconf Oct2008
Bfg Ploneconf Oct2008
 
Magic with groovy & grails
Magic with groovy & grailsMagic with groovy & grails
Magic with groovy & grails
 
Groovy Testing Sep2009
Groovy Testing Sep2009Groovy Testing Sep2009
Groovy Testing Sep2009
 
Javascript Dependency Management
Javascript Dependency ManagementJavascript Dependency Management
Javascript Dependency Management
 
Writing Domain-Specific Languages in Groovy
Writing Domain-Specific Languages in GroovyWriting Domain-Specific Languages in Groovy
Writing Domain-Specific Languages in Groovy
 
Groovy Testing Aug2009
Groovy Testing Aug2009Groovy Testing Aug2009
Groovy Testing Aug2009
 

Más de Guillaume Laforge

Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Guillaume Laforge
 
Groovy workshop à Mix-IT 2013
Groovy workshop à Mix-IT 2013Groovy workshop à Mix-IT 2013
Groovy workshop à Mix-IT 2013Guillaume Laforge
 
Les nouveautés de Groovy 2 -- Mix-IT 2013
Les nouveautés de Groovy 2 -- Mix-IT 2013Les nouveautés de Groovy 2 -- Mix-IT 2013
Les nouveautés de Groovy 2 -- Mix-IT 2013Guillaume Laforge
 
Groovy 2.0 update at Devoxx 2012
Groovy 2.0 update at Devoxx 2012Groovy 2.0 update at Devoxx 2012
Groovy 2.0 update at Devoxx 2012Guillaume Laforge
 
Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012Guillaume Laforge
 
Groovy update at SpringOne2GX 2012
Groovy update at SpringOne2GX 2012Groovy update at SpringOne2GX 2012
Groovy update at SpringOne2GX 2012Guillaume Laforge
 
Groovy 1.8 et 2.0 au BreizhC@mp 2012
Groovy 1.8 et 2.0 au BreizhC@mp 2012Groovy 1.8 et 2.0 au BreizhC@mp 2012
Groovy 1.8 et 2.0 au BreizhC@mp 2012Guillaume Laforge
 
Groovy 1.8 and 2.0 at GR8Conf Europe 2012
Groovy 1.8 and 2.0 at GR8Conf Europe 2012Groovy 1.8 and 2.0 at GR8Conf Europe 2012
Groovy 1.8 and 2.0 at GR8Conf Europe 2012Guillaume Laforge
 
Groovy 2.0 update - Cloud Foundry Open Tour Moscow - Guillaume Laforge
Groovy 2.0 update - Cloud Foundry Open Tour Moscow - Guillaume LaforgeGroovy 2.0 update - Cloud Foundry Open Tour Moscow - Guillaume Laforge
Groovy 2.0 update - Cloud Foundry Open Tour Moscow - Guillaume LaforgeGuillaume Laforge
 
Going to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific LanguagesGoing to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific LanguagesGuillaume Laforge
 
Groovy 2.0 - Devoxx France 2012
Groovy 2.0 - Devoxx France 2012Groovy 2.0 - Devoxx France 2012
Groovy 2.0 - Devoxx France 2012Guillaume Laforge
 
Groovy Update, new in 1.8 and beyond - Guillaume Laforge - Devoxx 2011
Groovy Update, new in 1.8 and beyond - Guillaume Laforge - Devoxx 2011Groovy Update, new in 1.8 and beyond - Guillaume Laforge - Devoxx 2011
Groovy Update, new in 1.8 and beyond - Guillaume Laforge - Devoxx 2011Guillaume Laforge
 
GPars et PrettyTime - Paris JUG 2011 - Guillaume Laforge
GPars et PrettyTime - Paris JUG 2011 - Guillaume LaforgeGPars et PrettyTime - Paris JUG 2011 - Guillaume Laforge
GPars et PrettyTime - Paris JUG 2011 - Guillaume LaforgeGuillaume Laforge
 
Groovy Update - Guillaume Laforge - Greach 2011
Groovy Update - Guillaume Laforge - Greach 2011Groovy Update - Guillaume Laforge - Greach 2011
Groovy Update - Guillaume Laforge - Greach 2011Guillaume Laforge
 
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011Gaelyk update - Guillaume Laforge - SpringOne2GX 2011
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011Guillaume Laforge
 
Groovy Update, what's new in Groovy 1.8 and beyond - Guillaume Laforge - Spri...
Groovy Update, what's new in Groovy 1.8 and beyond - Guillaume Laforge - Spri...Groovy Update, what's new in Groovy 1.8 and beyond - Guillaume Laforge - Spri...
Groovy Update, what's new in Groovy 1.8 and beyond - Guillaume Laforge - Spri...Guillaume Laforge
 

Más de Guillaume Laforge (20)

Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013Lift off with Groovy 2 at JavaOne 2013
Lift off with Groovy 2 at JavaOne 2013
 
Groovy workshop à Mix-IT 2013
Groovy workshop à Mix-IT 2013Groovy workshop à Mix-IT 2013
Groovy workshop à Mix-IT 2013
 
Les nouveautés de Groovy 2 -- Mix-IT 2013
Les nouveautés de Groovy 2 -- Mix-IT 2013Les nouveautés de Groovy 2 -- Mix-IT 2013
Les nouveautés de Groovy 2 -- Mix-IT 2013
 
Groovy 2 and beyond
Groovy 2 and beyondGroovy 2 and beyond
Groovy 2 and beyond
 
Groovy 2.0 update at Devoxx 2012
Groovy 2.0 update at Devoxx 2012Groovy 2.0 update at Devoxx 2012
Groovy 2.0 update at Devoxx 2012
 
Groovy 2.0 webinar
Groovy 2.0 webinarGroovy 2.0 webinar
Groovy 2.0 webinar
 
Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012Groovy Domain Specific Languages - SpringOne2GX 2012
Groovy Domain Specific Languages - SpringOne2GX 2012
 
Groovy update at SpringOne2GX 2012
Groovy update at SpringOne2GX 2012Groovy update at SpringOne2GX 2012
Groovy update at SpringOne2GX 2012
 
JavaOne 2012 Groovy update
JavaOne 2012 Groovy updateJavaOne 2012 Groovy update
JavaOne 2012 Groovy update
 
Groovy 1.8 et 2.0 au BreizhC@mp 2012
Groovy 1.8 et 2.0 au BreizhC@mp 2012Groovy 1.8 et 2.0 au BreizhC@mp 2012
Groovy 1.8 et 2.0 au BreizhC@mp 2012
 
Groovy 1.8 and 2.0 at GR8Conf Europe 2012
Groovy 1.8 and 2.0 at GR8Conf Europe 2012Groovy 1.8 and 2.0 at GR8Conf Europe 2012
Groovy 1.8 and 2.0 at GR8Conf Europe 2012
 
Groovy 2.0 update - Cloud Foundry Open Tour Moscow - Guillaume Laforge
Groovy 2.0 update - Cloud Foundry Open Tour Moscow - Guillaume LaforgeGroovy 2.0 update - Cloud Foundry Open Tour Moscow - Guillaume Laforge
Groovy 2.0 update - Cloud Foundry Open Tour Moscow - Guillaume Laforge
 
Going to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific LanguagesGoing to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific Languages
 
Groovy 2.0 - Devoxx France 2012
Groovy 2.0 - Devoxx France 2012Groovy 2.0 - Devoxx France 2012
Groovy 2.0 - Devoxx France 2012
 
Whats new in Groovy 2.0?
Whats new in Groovy 2.0?Whats new in Groovy 2.0?
Whats new in Groovy 2.0?
 
Groovy Update, new in 1.8 and beyond - Guillaume Laforge - Devoxx 2011
Groovy Update, new in 1.8 and beyond - Guillaume Laforge - Devoxx 2011Groovy Update, new in 1.8 and beyond - Guillaume Laforge - Devoxx 2011
Groovy Update, new in 1.8 and beyond - Guillaume Laforge - Devoxx 2011
 
GPars et PrettyTime - Paris JUG 2011 - Guillaume Laforge
GPars et PrettyTime - Paris JUG 2011 - Guillaume LaforgeGPars et PrettyTime - Paris JUG 2011 - Guillaume Laforge
GPars et PrettyTime - Paris JUG 2011 - Guillaume Laforge
 
Groovy Update - Guillaume Laforge - Greach 2011
Groovy Update - Guillaume Laforge - Greach 2011Groovy Update - Guillaume Laforge - Greach 2011
Groovy Update - Guillaume Laforge - Greach 2011
 
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011Gaelyk update - Guillaume Laforge - SpringOne2GX 2011
Gaelyk update - Guillaume Laforge - SpringOne2GX 2011
 
Groovy Update, what's new in Groovy 1.8 and beyond - Guillaume Laforge - Spri...
Groovy Update, what's new in Groovy 1.8 and beyond - Guillaume Laforge - Spri...Groovy Update, what's new in Groovy 1.8 and beyond - Guillaume Laforge - Spri...
Groovy Update, what's new in Groovy 1.8 and beyond - Guillaume Laforge - Spri...
 

Último

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
🐬 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
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Último (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
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...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Groovy Grails App Engine

  • 1. Groovy and Grails in Google App Engine Benefit from a Java-like dynamic language to be more productive on App Engine Guillaume Laforge Head of Groovy Development Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
  • 2. Guillaume Laforge • Groovy Project Manager • JSR-241 Spec Lead • Head of Groovy Development at SpringSource • Initiator of the Grails framework • Co-author of Groovy in Action • Speaker: JavaOne, QCon, JavaZone, Sun TechDays, Devoxx, The Spring Experience, JAX, Dynamic Language World, IJTC, and more... Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 2
  • 3. nda Ag e •Groovy overview –Features at a glance –Groovlets –Groovy templates • Grails overview – The Grails stack – The App Engine plugin • Summary • Q&A Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 3
  • 4. A few words about Groovy • Groovy is a dynamic language for the JVM – with a Meta Object Protocol – compiles directly to bytecode, seamless Java interop • Open Source ASL 2 project hosted at Codehaus • Relaxed grammar derived from Java 5 – Java 5 features out-of-the-box: annotations, generics, static imports, enums, varargs... – borrowed good ideas from Ruby, Python, Smalltalk – flat learning curve for Java developers Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 4
  • 5. Features at a glance • Fully Object-Oriented • Joint compiler: seamless Java integration • Closures: reusable/assignable code blocks • Properties: no more getters / setters • Optional typing: you decide! • Various shortcut notations: less verbose than Java • Handy wrapper APIs – Groovlets, XML, JDBC, JMX, template engine, Swing UIs, collections... • Strong ability for authoring Domain-Specific Languages Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 5
  • 6. A “normal” servlet • Writing a servlet is no different than a classical standard Java servlet – only a bit leaner: properties, semis, public keyword... • import javax.servlet.http.* class HelloServlet extends HttpServlet { void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.contentType = quot;text/plainquot; resp.writer.println quot;Hello World!quot; } } Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 6
  • 7. Groovylets: Groovy servlets • General idea – use scripts over classes – use Groovy’s markup builder to easily create HTML • html.html { head { title quot;Helloquot; } body { p quot;Hello Groovy World!quot; } } Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 7
  • 8. Groovylets: Groovy servlets • Refererence the GroovyServlet in web.xml • Add a URL mapping • <servlet> <servlet-name>GroovyServlet</servlet-name> <servlet-class> groovy.servlet.GroovyServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>GroovyServlet</servlet-name> <url-pattern>*.groovy</url-pattern> </servlet-mapping> Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 8
  • 9. Groovy templates • Groovy comes built-in with templating capability • import groovy.text.SimpleTemplateEngine def text = '''Dear $firstname, So nice to meet you in <% print city %>. See you in ${month}, <%= signed %>''' def binding = [firstname: quot;Guillaumequot;, month: quot;Junequot;, city: quot;San Franciscoquot;, signed: quot;Dukequot;] def engine = new SimpleTemplateEngine() template = engine.createTemplate(text) .make(binding) Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 9
  • 10. The Servlet template • Similar to JSPs – <html> <body> <p>${message}</p> </body> </html> • In your web.xml – <servlet> <servlet-name>GroovyTemplateServlet</servlet-name> <servlet-class> groovy.servlet.TemplateServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name>GroovyTemplateServlet</servlet-name> <url-pattern>*.gtpl</url-pattern> </servlet-mapping> Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 10
  • 11. F GAELYK • A thin layer on top of: – Groovlets & servlet template – Google App Engine Java SDK APIs • What it does – Inject all the services in servlets and templates – Adds syntax sugar and dynamic methods to the SDK API Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 11
  • 12. nda Ag e • Groovy overview – Features at a glance – Groovlets – Groovy templates •Grails overview –The Grails stack –The App Engine plugin • Summary • Q&A Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 12
  • 13. From 10,000 feet... = Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
  • 14. From 10,000 feet... = Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
  • 15. From 10,000 feet... = + Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
  • 16. From 10,000 feet... = + Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
  • 17. From 10,000 feet... = + + Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
  • 18. From 10,000 feet... = + + Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
  • 19. In a few bullet points... • Grails is a full stack web app development env. – built on rock-solid and proven OSS frameworks •Spring, Spring MVC, Spring WebFlow •Hibernate, SiteMesh, Quartz •Jetty, HSQLDB – provides its ORM layer on top of Hibernate – has got its own integrated build system and CLI • Follows good and lean principles – Convention over Configuration, MVC, DRY... • Provides powerful time-saving capabilities – Scaffolding, an extensible plugin system, taglibs, templates, and more Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 14
  • 20. The big picture Grails Groovy Java Enterprise Spring Hibernate SiteMesh Edition (JEE) The Java Development The Java Language Kit (JDK) The Java Virtual Machine Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15
  • 21. The big picture Grails Groovy Java Enterprise Spring Hibernate SiteMesh Edition (JEE) The Java Development The Java Language Kit (JDK) The Java Virtual Machine Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15
  • 22. The standard project structure M C V Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 16
  • 23. The App Engine plugin • Grails has got a very extensive and rich plugin system and ecosystem – 100+ existing and useful plugins available •GWT, Flex, YUI, iUI, JMS, search, security, testing... • A Google App Engine plugin was developed – following the Grails development flow – abstracts the app engine commands for deployments – leverages the local engine Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 17
  • 24. Setting up your project • Create your Grails application as usual grails create-app myapp • Specify the App Engine app id google.appengine.application = quot;myappquot; • Uninstall hibernate and install the GAE plugin grails uninstall-plugin hibernate grails install-plugin app-engine • Run the application locally grails app-engine run Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 18
  • 25. Deploying applications • Set the version number to 1, as Grails uses a different numbering scheme (x.y) grails set-version 1 • Get your application ready grails app-engine package • On first deployment $APPENGINE_HOME/appcfg.sh update ./target/war • For subsequent deployments grails app-engine deploy Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19
  • 26. DEMO Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 20
  • 27. nda Ag e • Groovy overview – Features at a glance – Groovlets – Groovy templates • Grails overview – The Grails stack – The App Engine plugin •Summary • Q&A Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 21
  • 28. Summary • Groovy – Groovy is a first-class citizen on Google App Engine – Lots of shorcut notations can streamline your code – Groovy servlets and templates are great for crafting small applications – Gaelyk further simplifies this pure Groovy approach • Grails – Grails is the next-generation web development stack – Developing Grails application on the Google cloud is almost as lean and simple as for the usual crop of application servers Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 22
  • 29. Further information • Groovy in Google App Engine – http://blog.springsource.com/2009/04/07/write-your- google-app-engine-applications-in-groovy/ • Grails in Google App Engine – the Grails 1.1.1 release and App Engine screencast •http://blog.springsource.com/2009/05/14/grails-111- released-with-google-appengine-support/ – the Google App Engine Grails plugin •http://grails.org/plugin/app-engine Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 23
  • 30. nda Ag e • Groovy overview – Features at a glance – Groovlets – Groovy templates • Grails overview – The Grails stack – The App Engine plugin • Summary •Q&A Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 24
  • 31. Q&A • Questions & perhaps... even answers :-) Copyright 2009 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 25