SlideShare a Scribd company logo
Groovy & Grails for Java
                             developers
                        Peter Ledbrook, Developer Advocate
                       pledbrook@vmware.com / @pledbrook



© 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.

                                                                                   1
Demo




       2
3

    3
4

    4
5

    5
6

    6
7

    7
8

    8
9

    9
10

     10
11

     11
12

     12
13

     13
14

     14
15

     15
16

     16
17

     17
18

     18
19

     19
20

     20
21

     21
22

     22
23

     23
24

     24
25

     25
26

     26
27

     27
28

     28
29

     29
30

     30
31

     31
32

     32
33

     33
34

     34
35

     35
36

     36
37

     37
38

     38
39

     39
40

     40
41

     41
42

     42
43

     43
44

     44
45

     45
46

     46
47

     47
48

     48
49

     49
50

     50
51

     51
52

     52
53

     53
54

     54
55

     55
56

     56
57

     57
58

     58
59

     59
60

     60
• Grails for Swing applications
• MVC model                                     http://griffon.codehaus.org/
• SwingBuilder for views

application(title: 'DemoConsole', pack: true, locationByPlatform: true) {
  panel(border: emptyBorder(6)) {
     borderLayout()
     scrollPane(constraints: CENTER) {
       textArea(
          text: bind(target: model, targetProperty: 'scriptSource'),
          enabled: bind {model.enabled},
          columns: 40, rows: 10)
     }
  }
}



                                                                            61

                                                                                 61
Gradle

•   Build tool with built-in dependency management
•   Conventions through plugins
•   Multi-project support
•   Full access to tasks and dependency tree
•   Easy to write your own tasks
    – either in the build file
    – or via Groovy/Java classes



                      http://www.gradle.org/



                                                     62

                                                          62
• Parallel processing for Groovy
• Actors library making full use of closures

@Grab(group='org.codehaus.gpars', module='gpars', version='0.11')
import groovyx.gpars.GParsPool

GParsPool.withPool {
  def animals = ['dog', 'ant', 'cat', 'whale']
  println(animals.anyParallel {it ==~ /ant/} ?
       'Found an ant' : 'No ants found')
  println(animals.everyParallel {it.contains('a')} ?
       'All animals contain a' : 'Some animals can live without an a')
}



                       http://gpars.codehaus.org/

                                                                         63

                                                                              63
Try it out!




         http://groovyconsole.appspot.com/




                                             64

                                                  64
What is Grails?


• Rapid Web Application Development Framework
  – for the JVM
  – with first-class Java integration
• Inspired by Ruby on Rails, Django and others
  – Convention over Configuration
  – Don’t Repeat Yourself (DRY)




                                                 65

                                                      65
What is Grails?

     Grails
                                         Servlet
          Web MVC        GSP (Views)
                                        Container



            GORM
                          Database        I18n
         (Data Access)



              Build      Test Support   Doc Engine




                                                     66

                                                          66
What is Grails?


                  Grails




                           67

                                67
What is Grails?



                   Web Controllers
The Domain Model
                   i18n bundles
Business Logic
                   Custom View Tags
Views & Layouts
                   Libraries (JARs)
Build Commands
                   Additional Sources
Tests
                   Web Resources


                                        68

                                             68
Say bye-bye to the plumbing!




                               69

                                    69
Demo




       70
Enterprise requirements


                              Web App




      Messaging                                    JEE




                   Legacy
                                        Services
                  Databases



            Is this a problem for Grails apps?

                                                         71

                                                              71
Build

• Remember the Grails project structure?
  – add in build events and...

           Can’t build natively with other build tools!




                 Ant              Maven           Gradle




                            Grails Build System



                                                           72

                                                                72
Dependency DSL


 grails.project.dependency.resolution = {
   inherits "global"
   log "warn"
   repositories {
       grailsHome()
       mavenCentral()
       mavenRepo "http://localhost:8081/..."
   }
   ...
 }




                                               73

                                                    73
Dependency DSL

 grails.project.dependency.resolution = {
   inherits "global"
   log "warn"
   ...
   dependencies {
       runtime "mysql:mysql-connector-java:5.1.17"
       test "org.gmock:gmock:0.8.1"
       ...
   }
   plugins {
       compile ":spring-security-core:1.2.7"
       ...
   }
 }


                                                     74

                                                          74
‘Legacy’ Databases

• Grails can create a database from your domain model...
• ...but what if you don’t own the database?
  – DBA determines structure
  – Company conventions
  – Existing ‘legacy’ database




                                                           75

                                                                75
Option 1: Custom ORM mapping

• No existing domain model
• Schema not too far off the beaten track

 class Book {
    ...
    static mapping = {
        table "books"
        title type: "books"
        author column: "author_ref"
    }
 }




                                            76

                                                 76
Option 2: JPA annotations

• Existing Java/JPA domain model


 <?xml version='1.0' encoding='UTF-8'?>
 <!DOCTYPE ...>
 <hibernate-configuration>
   <session-factory>
      <mapping class="org.ex.Book"/>
      <mapping class="org.ex.Author"/>
      ...
   </session-factory>
 </hibernate-configuration>

                             grails-app/conf/hibernate/hibernate.cfg.xml



                                                                           77

                                                                                77
Option 3: Hibernate XML Mappings

• You have Java model + Hibernate mapping files
• Schema is way off the beaten track


 <?xml version='1.0' encoding='UTF-8'?>
 <!DOCTYPE ...>
 <hibernate-configuration>
   <session-factory>
      <mapping resource="org.ex.Book.hbm.xml"/>
      <mapping resource="org.ex.Author.hbm.xml"/>
      ...
   </session-factory>
 </hibernate-configuration>

                            grails-app/conf/hibernate/hibernate.cfg.xml

                                                                          78

                                                                               78
Constraints


Given domain class:

     org.example.myapp.domain.Book

Then:

     src/java/org/example/myapp/domain/BookConstraints.groovy


 constraints = {
   title blank: false, unique: true
   ...
 }


                                                                79

                                                                     79
Option 4: GORM JPA Plugin

• GORM layer over JPA
• Use your own JPA provider
• Useful for cloud services that only work with JPA, not
  Hibernate




                                                           80

                                                                80
Database Migration Plugin

      Pre-production, Hibernate ‘update’ or ‘create-drop’



                    dbm-generate-changelog
                      dbm-changelog-sync




                      Change domain model




                         dbm-gorm-diff
                          dbm-update



                                                            81

                                                                 81
Reverse Engineering Plugin




                        class Person {
                            String name
                            Integer age
                            ...
                        }




                                          82

                                               82
Grails is Spring

• Spring MVC under the hood
• Grails provides many useful beans
  – e.g. grailsApplication
• Define your own beans!
  – resources.xml/groovy
  – In a plugin




                                      83

                                           83
Example

import ...
beans = {
  credentialMatcher(Sha1CredentialsMatcher) {
     storedCredentialsHexEncoded = true
  }

    sessionFactory(ConfigurableLocalSessionFactoryBean) {
      dataSource = ref("dataSource")
      hibernateProperties = [
           "hibernate.hbm2ddl.auto": "create-drop",
           "hibernate.show_sql": true ]
    }
}




                                                            84

                                                                 84
Summary

• Various options for integrating Grails with:
  – Development/build
  – Deployment processes
• Works with many external systems
  – Solid support for non-Grailsy DB schemas
  – Flexible messaging & web service support




                                                 85

                                                      85
More info

• w:   http://grails.org/
• f:   http://grails.org/Mailing+Lists

• e:   pledbrook@vmware.com
• t:   pledbrook
• b:   http://blog.springsource.com/author/peter-ledbrook/




                                                             86

                                                                  86
Q&A




      87

More Related Content

What's hot

Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
Ryan Cuprak
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
Ryan Cuprak
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
Kai Koenig
 
CQCON CQ Maven Methods
CQCON CQ Maven MethodsCQCON CQ Maven Methods
CQCON CQ Maven Methods
Andrew Savory
 
Introduction to glideinWMS
Introduction to glideinWMSIntroduction to glideinWMS
Introduction to glideinWMS
Igor Sfiligoi
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Rajmahendra Hegde
 

What's hot (6)

Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
The JVM is your friend
The JVM is your friendThe JVM is your friend
The JVM is your friend
 
CQCON CQ Maven Methods
CQCON CQ Maven MethodsCQCON CQ Maven Methods
CQCON CQ Maven Methods
 
Introduction to glideinWMS
Introduction to glideinWMSIntroduction to glideinWMS
Introduction to glideinWMS
 
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012Gradle build tool that rocks with DSL JavaOne India 4th May 2012
Gradle build tool that rocks with DSL JavaOne India 4th May 2012
 

Viewers also liked

Web accessibility with Ametys CMS
Web accessibility with Ametys CMSWeb accessibility with Ametys CMS
Web accessibility with Ametys CMS
Ametys
 
Responsive Web Design - An Accessibility Tool
Responsive Web Design - An Accessibility ToolResponsive Web Design - An Accessibility Tool
Responsive Web Design - An Accessibility Tool
George Zamfir
 
Avoiding common Accessibility mistakes
Avoiding common Accessibility mistakesAvoiding common Accessibility mistakes
Avoiding common Accessibility mistakes
Dirk Ginader
 
Integrating universal design, best practices, & accessibility atia 2013 - (...
Integrating universal design, best practices, & accessibility   atia 2013 - (...Integrating universal design, best practices, & accessibility   atia 2013 - (...
Integrating universal design, best practices, & accessibility atia 2013 - (...Howard Kramer
 
Accessibility beyond the desktop - panel slides Accessibility 2.0
Accessibility beyond the desktop - panel slides Accessibility 2.0Accessibility beyond the desktop - panel slides Accessibility 2.0
Accessibility beyond the desktop - panel slides Accessibility 2.0
Henny Swan
 
Accessibility of Common Web Applications
Accessibility of Common Web ApplicationsAccessibility of Common Web Applications
Accessibility of Common Web Applications
Tomáš Muchka
 
Developing for Diversity
Developing for DiversityDeveloping for Diversity
Developing for DiversityInclusiveUX
 
Introduction to Accessibility Best Practices
Introduction to Accessibility Best PracticesIntroduction to Accessibility Best Practices
Introduction to Accessibility Best Practicesshawtrusta11y
 
503 web accessibility - best practices
503   web accessibility - best practices503   web accessibility - best practices
503 web accessibility - best practicesJoanna Wiebe
 
Best Practices for Web Accessibility
Best Practices for Web AccessibilityBest Practices for Web Accessibility
Best Practices for Web Accessibility
Carli Spina
 
Screencasting Tutorial DRN
Screencasting Tutorial DRNScreencasting Tutorial DRN
Screencasting Tutorial DRN
drnbc
 
Accessibility for Hybrid Mobile
Accessibility for Hybrid MobileAccessibility for Hybrid Mobile
Accessibility for Hybrid Mobile
Bobby Bristol
 
Agile Accessibility From a Testers Perspective
Agile Accessibility From a Testers PerspectiveAgile Accessibility From a Testers Perspective
Agile Accessibility From a Testers Perspective
Alicia Jarvis, CPACC, CSM
 
Line Height
Line HeightLine Height
Line Height
Russ Weakley
 
Principales fonctionnalités du CMS Ametys
Principales fonctionnalités du CMS AmetysPrincipales fonctionnalités du CMS Ametys
Principales fonctionnalités du CMS Ametys
Ametys
 
SSB BART Group Mobile Accessibility
SSB  BART Group Mobile AccessibilitySSB  BART Group Mobile Accessibility
SSB BART Group Mobile AccessibilityEduardo Meza-Etienne
 
Html & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshopHtml & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshop
Vero Rebagliatte
 
Mobile Accessibility Best Practices & Trends
Mobile Accessibility Best Practices & TrendsMobile Accessibility Best Practices & Trends
Mobile Accessibility Best Practices & Trends
Aidan Tierney
 
Early prevention of accessibility issues with mockup & wireframe reviews
Early prevention of accessibility issues with mockup & wireframe reviewsEarly prevention of accessibility issues with mockup & wireframe reviews
Early prevention of accessibility issues with mockup & wireframe reviews
Aidan Tierney
 
Embrology of the respiratory system
Embrology of the respiratory systemEmbrology of the respiratory system
Embrology of the respiratory system
Oriba Dan Langoya
 

Viewers also liked (20)

Web accessibility with Ametys CMS
Web accessibility with Ametys CMSWeb accessibility with Ametys CMS
Web accessibility with Ametys CMS
 
Responsive Web Design - An Accessibility Tool
Responsive Web Design - An Accessibility ToolResponsive Web Design - An Accessibility Tool
Responsive Web Design - An Accessibility Tool
 
Avoiding common Accessibility mistakes
Avoiding common Accessibility mistakesAvoiding common Accessibility mistakes
Avoiding common Accessibility mistakes
 
Integrating universal design, best practices, & accessibility atia 2013 - (...
Integrating universal design, best practices, & accessibility   atia 2013 - (...Integrating universal design, best practices, & accessibility   atia 2013 - (...
Integrating universal design, best practices, & accessibility atia 2013 - (...
 
Accessibility beyond the desktop - panel slides Accessibility 2.0
Accessibility beyond the desktop - panel slides Accessibility 2.0Accessibility beyond the desktop - panel slides Accessibility 2.0
Accessibility beyond the desktop - panel slides Accessibility 2.0
 
Accessibility of Common Web Applications
Accessibility of Common Web ApplicationsAccessibility of Common Web Applications
Accessibility of Common Web Applications
 
Developing for Diversity
Developing for DiversityDeveloping for Diversity
Developing for Diversity
 
Introduction to Accessibility Best Practices
Introduction to Accessibility Best PracticesIntroduction to Accessibility Best Practices
Introduction to Accessibility Best Practices
 
503 web accessibility - best practices
503   web accessibility - best practices503   web accessibility - best practices
503 web accessibility - best practices
 
Best Practices for Web Accessibility
Best Practices for Web AccessibilityBest Practices for Web Accessibility
Best Practices for Web Accessibility
 
Screencasting Tutorial DRN
Screencasting Tutorial DRNScreencasting Tutorial DRN
Screencasting Tutorial DRN
 
Accessibility for Hybrid Mobile
Accessibility for Hybrid MobileAccessibility for Hybrid Mobile
Accessibility for Hybrid Mobile
 
Agile Accessibility From a Testers Perspective
Agile Accessibility From a Testers PerspectiveAgile Accessibility From a Testers Perspective
Agile Accessibility From a Testers Perspective
 
Line Height
Line HeightLine Height
Line Height
 
Principales fonctionnalités du CMS Ametys
Principales fonctionnalités du CMS AmetysPrincipales fonctionnalités du CMS Ametys
Principales fonctionnalités du CMS Ametys
 
SSB BART Group Mobile Accessibility
SSB  BART Group Mobile AccessibilitySSB  BART Group Mobile Accessibility
SSB BART Group Mobile Accessibility
 
Html & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshopHtml & CSS - Best practices 2-hour-workshop
Html & CSS - Best practices 2-hour-workshop
 
Mobile Accessibility Best Practices & Trends
Mobile Accessibility Best Practices & TrendsMobile Accessibility Best Practices & Trends
Mobile Accessibility Best Practices & Trends
 
Early prevention of accessibility issues with mockup & wireframe reviews
Early prevention of accessibility issues with mockup & wireframe reviewsEarly prevention of accessibility issues with mockup & wireframe reviews
Early prevention of accessibility issues with mockup & wireframe reviews
 
Embrology of the respiratory system
Embrology of the respiratory systemEmbrology of the respiratory system
Embrology of the respiratory system
 

Similar to Groovy & Grails for Spring/Java developers

Gradle
GradleGradle
Grails 3.0 Preview
Grails 3.0 PreviewGrails 3.0 Preview
Grails 3.0 Preview
graemerocher
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easyroialdaag
 
Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013Gavin Hogan
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
Arun Gupta
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf
 
Adopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf EuropeAdopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf EuropeKlausBaumecker
 
Fast web development using groovy on grails
Fast web development using groovy on grailsFast web development using groovy on grails
Fast web development using groovy on grailsAnshuman Biswal
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact version
scalaconfjp
 
Js tacktalk team dev js testing performance
Js tacktalk team dev js testing performanceJs tacktalk team dev js testing performance
Js tacktalk team dev js testing performance
Артем Захарченко
 
GraalVM
GraalVMGraalVM
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containers
Red Hat Developers
 
Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)
Jared Burrows
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
Guillaume Laforge
 
Everything you need to know about GraalVM Native Image
Everything you need to know about GraalVM Native ImageEverything you need to know about GraalVM Native Image
Everything you need to know about GraalVM Native Image
Alina Yurenko
 
Peru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVMPeru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVM
Domingo Suarez Torres
 
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)
Ontico
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
Aleksandr Tarasov
 
Drools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentationDrools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentation
Mark Proctor
 
GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22
Jorge Hidalgo
 

Similar to Groovy & Grails for Spring/Java developers (20)

Gradle
GradleGradle
Gradle
 
Grails 3.0 Preview
Grails 3.0 PreviewGrails 3.0 Preview
Grails 3.0 Preview
 
Java Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.EasyJava Edge.2009.Grails.Web.Dev.Made.Easy
Java Edge.2009.Grails.Web.Dev.Made.Easy
 
Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
 
Adopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf EuropeAdopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf Europe
 
Fast web development using groovy on grails
Fast web development using groovy on grailsFast web development using groovy on grails
Fast web development using groovy on grails
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact version
 
Js tacktalk team dev js testing performance
Js tacktalk team dev js testing performanceJs tacktalk team dev js testing performance
Js tacktalk team dev js testing performance
 
GraalVM
GraalVMGraalVM
GraalVM
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containers
 
Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
Everything you need to know about GraalVM Native Image
Everything you need to know about GraalVM Native ImageEverything you need to know about GraalVM Native Image
Everything you need to know about GraalVM Native Image
 
Peru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVMPeru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVM
 
Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)Everything as a Code / Александр Тарасов (Одноклассники)
Everything as a Code / Александр Тарасов (Одноклассники)
 
Everything as a code
Everything as a codeEverything as a code
Everything as a code
 
Drools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentationDrools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentation
 
GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22
 

More from Peter Ledbrook

Why Gradle?
Why Gradle?Why Gradle?
Why Gradle?
Peter Ledbrook
 
Improving your Gradle builds
Improving your Gradle buildsImproving your Gradle builds
Improving your Gradle builds
Peter Ledbrook
 
Why your build matters
Why your build mattersWhy your build matters
Why your build matters
Peter Ledbrook
 
Groovy for Java Developers
Groovy for Java DevelopersGroovy for Java Developers
Groovy for Java Developers
Peter Ledbrook
 
Application Architectures in Grails
Application Architectures in GrailsApplication Architectures in Grails
Application Architectures in Grails
Peter Ledbrook
 
Open source-and-you-gr8conf-us-2013
Open source-and-you-gr8conf-us-2013Open source-and-you-gr8conf-us-2013
Open source-and-you-gr8conf-us-2013Peter Ledbrook
 
Grails & the World of Tomorrow
Grails & the World of TomorrowGrails & the World of Tomorrow
Grails & the World of Tomorrow
Peter Ledbrook
 
Migrating to Cloud Foundry
Migrating to Cloud FoundryMigrating to Cloud Foundry
Migrating to Cloud Foundry
Peter Ledbrook
 
Grails 2.0 Update
Grails 2.0 UpdateGrails 2.0 Update
Grails 2.0 Update
Peter Ledbrook
 
Grails and the World of Tomorrow
Grails and the World of TomorrowGrails and the World of Tomorrow
Grails and the World of Tomorrow
Peter Ledbrook
 
Cloud Foundry for Java devs
Cloud Foundry for Java devsCloud Foundry for Java devs
Cloud Foundry for Java devs
Peter Ledbrook
 

More from Peter Ledbrook (11)

Why Gradle?
Why Gradle?Why Gradle?
Why Gradle?
 
Improving your Gradle builds
Improving your Gradle buildsImproving your Gradle builds
Improving your Gradle builds
 
Why your build matters
Why your build mattersWhy your build matters
Why your build matters
 
Groovy for Java Developers
Groovy for Java DevelopersGroovy for Java Developers
Groovy for Java Developers
 
Application Architectures in Grails
Application Architectures in GrailsApplication Architectures in Grails
Application Architectures in Grails
 
Open source-and-you-gr8conf-us-2013
Open source-and-you-gr8conf-us-2013Open source-and-you-gr8conf-us-2013
Open source-and-you-gr8conf-us-2013
 
Grails & the World of Tomorrow
Grails & the World of TomorrowGrails & the World of Tomorrow
Grails & the World of Tomorrow
 
Migrating to Cloud Foundry
Migrating to Cloud FoundryMigrating to Cloud Foundry
Migrating to Cloud Foundry
 
Grails 2.0 Update
Grails 2.0 UpdateGrails 2.0 Update
Grails 2.0 Update
 
Grails and the World of Tomorrow
Grails and the World of TomorrowGrails and the World of Tomorrow
Grails and the World of Tomorrow
 
Cloud Foundry for Java devs
Cloud Foundry for Java devsCloud Foundry for Java devs
Cloud Foundry for Java devs
 

Recently uploaded

Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
Globus
 

Recently uploaded (20)

Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Enhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZEnhancing Performance with Globus and the Science DMZ
Enhancing Performance with Globus and the Science DMZ
 

Groovy & Grails for Spring/Java developers

  • 1. Groovy & Grails for Java developers Peter Ledbrook, Developer Advocate pledbrook@vmware.com / @pledbrook © 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission. 1
  • 2. Demo 2
  • 3. 3 3
  • 4. 4 4
  • 5. 5 5
  • 6. 6 6
  • 7. 7 7
  • 8. 8 8
  • 9. 9 9
  • 10. 10 10
  • 11. 11 11
  • 12. 12 12
  • 13. 13 13
  • 14. 14 14
  • 15. 15 15
  • 16. 16 16
  • 17. 17 17
  • 18. 18 18
  • 19. 19 19
  • 20. 20 20
  • 21. 21 21
  • 22. 22 22
  • 23. 23 23
  • 24. 24 24
  • 25. 25 25
  • 26. 26 26
  • 27. 27 27
  • 28. 28 28
  • 29. 29 29
  • 30. 30 30
  • 31. 31 31
  • 32. 32 32
  • 33. 33 33
  • 34. 34 34
  • 35. 35 35
  • 36. 36 36
  • 37. 37 37
  • 38. 38 38
  • 39. 39 39
  • 40. 40 40
  • 41. 41 41
  • 42. 42 42
  • 43. 43 43
  • 44. 44 44
  • 45. 45 45
  • 46. 46 46
  • 47. 47 47
  • 48. 48 48
  • 49. 49 49
  • 50. 50 50
  • 51. 51 51
  • 52. 52 52
  • 53. 53 53
  • 54. 54 54
  • 55. 55 55
  • 56. 56 56
  • 57. 57 57
  • 58. 58 58
  • 59. 59 59
  • 60. 60 60
  • 61. • Grails for Swing applications • MVC model http://griffon.codehaus.org/ • SwingBuilder for views application(title: 'DemoConsole', pack: true, locationByPlatform: true) { panel(border: emptyBorder(6)) { borderLayout() scrollPane(constraints: CENTER) { textArea( text: bind(target: model, targetProperty: 'scriptSource'), enabled: bind {model.enabled}, columns: 40, rows: 10) } } } 61 61
  • 62. Gradle • Build tool with built-in dependency management • Conventions through plugins • Multi-project support • Full access to tasks and dependency tree • Easy to write your own tasks – either in the build file – or via Groovy/Java classes http://www.gradle.org/ 62 62
  • 63. • Parallel processing for Groovy • Actors library making full use of closures @Grab(group='org.codehaus.gpars', module='gpars', version='0.11') import groovyx.gpars.GParsPool GParsPool.withPool { def animals = ['dog', 'ant', 'cat', 'whale'] println(animals.anyParallel {it ==~ /ant/} ? 'Found an ant' : 'No ants found') println(animals.everyParallel {it.contains('a')} ? 'All animals contain a' : 'Some animals can live without an a') } http://gpars.codehaus.org/ 63 63
  • 64. Try it out! http://groovyconsole.appspot.com/ 64 64
  • 65. What is Grails? • Rapid Web Application Development Framework – for the JVM – with first-class Java integration • Inspired by Ruby on Rails, Django and others – Convention over Configuration – Don’t Repeat Yourself (DRY) 65 65
  • 66. What is Grails? Grails Servlet Web MVC GSP (Views) Container GORM Database I18n (Data Access) Build Test Support Doc Engine 66 66
  • 67. What is Grails? Grails 67 67
  • 68. What is Grails? Web Controllers The Domain Model i18n bundles Business Logic Custom View Tags Views & Layouts Libraries (JARs) Build Commands Additional Sources Tests Web Resources 68 68
  • 69. Say bye-bye to the plumbing! 69 69
  • 70. Demo 70
  • 71. Enterprise requirements Web App Messaging JEE Legacy Services Databases Is this a problem for Grails apps? 71 71
  • 72. Build • Remember the Grails project structure? – add in build events and... Can’t build natively with other build tools! Ant Maven Gradle Grails Build System 72 72
  • 73. Dependency DSL grails.project.dependency.resolution = { inherits "global" log "warn" repositories { grailsHome() mavenCentral() mavenRepo "http://localhost:8081/..." } ... } 73 73
  • 74. Dependency DSL grails.project.dependency.resolution = { inherits "global" log "warn" ... dependencies { runtime "mysql:mysql-connector-java:5.1.17" test "org.gmock:gmock:0.8.1" ... } plugins { compile ":spring-security-core:1.2.7" ... } } 74 74
  • 75. ‘Legacy’ Databases • Grails can create a database from your domain model... • ...but what if you don’t own the database? – DBA determines structure – Company conventions – Existing ‘legacy’ database 75 75
  • 76. Option 1: Custom ORM mapping • No existing domain model • Schema not too far off the beaten track class Book { ... static mapping = { table "books" title type: "books" author column: "author_ref" } } 76 76
  • 77. Option 2: JPA annotations • Existing Java/JPA domain model <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE ...> <hibernate-configuration> <session-factory> <mapping class="org.ex.Book"/> <mapping class="org.ex.Author"/> ... </session-factory> </hibernate-configuration> grails-app/conf/hibernate/hibernate.cfg.xml 77 77
  • 78. Option 3: Hibernate XML Mappings • You have Java model + Hibernate mapping files • Schema is way off the beaten track <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE ...> <hibernate-configuration> <session-factory> <mapping resource="org.ex.Book.hbm.xml"/> <mapping resource="org.ex.Author.hbm.xml"/> ... </session-factory> </hibernate-configuration> grails-app/conf/hibernate/hibernate.cfg.xml 78 78
  • 79. Constraints Given domain class: org.example.myapp.domain.Book Then: src/java/org/example/myapp/domain/BookConstraints.groovy constraints = { title blank: false, unique: true ... } 79 79
  • 80. Option 4: GORM JPA Plugin • GORM layer over JPA • Use your own JPA provider • Useful for cloud services that only work with JPA, not Hibernate 80 80
  • 81. Database Migration Plugin Pre-production, Hibernate ‘update’ or ‘create-drop’ dbm-generate-changelog dbm-changelog-sync Change domain model dbm-gorm-diff dbm-update 81 81
  • 82. Reverse Engineering Plugin class Person { String name Integer age ... } 82 82
  • 83. Grails is Spring • Spring MVC under the hood • Grails provides many useful beans – e.g. grailsApplication • Define your own beans! – resources.xml/groovy – In a plugin 83 83
  • 84. Example import ... beans = { credentialMatcher(Sha1CredentialsMatcher) { storedCredentialsHexEncoded = true } sessionFactory(ConfigurableLocalSessionFactoryBean) { dataSource = ref("dataSource") hibernateProperties = [ "hibernate.hbm2ddl.auto": "create-drop", "hibernate.show_sql": true ] } } 84 84
  • 85. Summary • Various options for integrating Grails with: – Development/build – Deployment processes • Works with many external systems – Solid support for non-Grailsy DB schemas – Flexible messaging & web service support 85 85
  • 86. More info • w: http://grails.org/ • f: http://grails.org/Mailing+Lists • e: pledbrook@vmware.com • t: pledbrook • b: http://blog.springsource.com/author/peter-ledbrook/ 86 86
  • 87. Q&A 87