SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie Groovy and Grails in Google 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
 

Ähnlich wie Groovy and Grails in Google 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
 

Mehr von 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
 

Mehr von 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...
 

Kürzlich hochgeladen

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...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
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
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
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 

Kürzlich hochgeladen (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
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...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 

Groovy and Grails in Google 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