SlideShare a Scribd company logo
Peter Ledbrook / VMware


       Grails in the Java Enterprise



Tuesday, 1 November 11
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)




                                                   2

Tuesday, 1 November 11
What is Grails?

                 Grails
                                                         Servlet
                          Web MVC        GSP (Views)
                                                        Container


                            GORM
                                          Database        I18n
                         (Data Access)



                            Build        Test Support   Doc Engine




                                                                     3

Tuesday, 1 November 11
What is Grails?

                         Grails




                                  4

Tuesday, 1 November 11
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
                                        5

Tuesday, 1 November 11
Say bye-bye to the plumbing!




                                   6

Tuesday, 1 November 11
Demo

    Demo




                         7


Tuesday, 1 November 11
Enterprise requirements
                                            Web App




                    Messaging                                    JEE



                                 Legacy
                                                      Services
                                Databases



                          Is this a problem for Grails apps?

                                                                       8

Tuesday, 1 November 11
Integration Points

    Build
    Dependencies
    Database
    Deployment
    Spring



                         9

Tuesday, 1 November 11
Integration Points

    Build
    Dependencies
    Database
    Deployment
    Spring



                         10

Tuesday, 1 November 11
Build




                         11

Tuesday, 1 November 11
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
                                                                   12

Tuesday, 1 November 11
Ant Integration

    An Ant task built in (grails.ant.GrailsTask)
    Template Ant build:
         grails integrate-with --ant
          • Uses Ivy for dependency management
          • Not compatible with Ant 1.8
    ...or use ‘java’ task to call Grails command
          • Grails manages dependencies
          • Use ‘grails’ for build

                                                   13

Tuesday, 1 November 11
Maven

    Maven Grails Plugin:
         https://github.com/grails/grails-maven
    Use Maven 2 or 3 to build Grails projects
    Declare dependencies in POM
    Works for both applications and plugins!
    Integration test framework:
       https://github.com/grails/
       grails_maven_plugin_testing_tests


                                                  14

Tuesday, 1 November 11
Getting Started

                         mvn archetype-generate ...

                                              e.g. -Xmx256m
                                 mvn initialize
                                              -XX:MaxPermSize=256m



                             Set MAVEN_OPTS



              Optional: add ‘pom true’ to dependency DSL


                                                            15

Tuesday, 1 November 11
Packaging Types

    ‘war’
          • Must configure execution section
          • Works with plugins that depend on ‘war’
    ‘grails-app’
          • Less configuration
    ‘grails-plugin’
          • For plugins!




                                                      16

Tuesday, 1 November 11
Maven & Grails Plugins


                         > grails release-plugin
                                   ==
                             > mvn deploy


                                                   17

Tuesday, 1 November 11
Maven & Grails Plugins
       Either:

              <dependency>
               <groupId>org.grails.plugins<groupId>
               <artifactId>hibernate</artifactId>
               <type>grails-plugin</type>
              </dependency>


              Use ‘mvn deploy’ or Release plugin!
              And ‘pom: false’


                                                      18

Tuesday, 1 November 11
Maven & Grails Plugins
         Or:

               grails.project.dependency.resolution = {
                 ...
                 plugins {
                     compile ":hibernate:1.3.6"
                 }
                 ...
               }




                                                          19

Tuesday, 1 November 11
Customise the Build

    Create new commands in <proj>/scripts
    Package the commands in a plugin!
    Create <proj>/scripts/_Events.groovy
          • Interact with standard build steps
          • Add test types
          • Configure embedded Tomcat




                                                 20

Tuesday, 1 November 11
What the future holds...

    Grails 3.0 will probably move to Gradle
          • More powerful and more flexible
          • Standard, well documented API
          • Ant & Maven support




                                              21

Tuesday, 1 November 11
Integration Points

    Build
    Dependencies
    Database
    Deployment
    Spring



                         22

Tuesday, 1 November 11
Dependencies are JARs

    Use any Java library you like!
    Full support for Maven-compatible repositories
    Declarative dependencies
    Plugins can be declared the same way




                                                     23

Tuesday, 1 November 11
Dependency DSL
        grails.project.dependency.resolution = {
          inherits "global"
          log "warn"
          repositories {
              grailsHome()
              mavenCentral()
              mavenRepo "http://localhost:8081/..."
          }
          ...
        }




                                                      24

Tuesday, 1 November 11
Dependency DSL
        grails.project.dependency.resolution = {
          inherits "global"
          log "warn"
          ...
          dependencies {
              compile "org.tmatesoft.svnkit:svnkit:1.3.3"
              test "org.gmock:gmock:0.8.1"
          }
          ...
        }




                                                            25

Tuesday, 1 November 11
Integration Points

    Build
    Dependencies
    Database
    Deployment
    Spring



                         26

Tuesday, 1 November 11
‘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




                                                      27

Tuesday, 1 November 11
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"
         }
      }




                                               28

Tuesday, 1 November 11
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


                                                                  29

Tuesday, 1 November 11
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

                                                                 30

Tuesday, 1 November 11
Constraints
     Given domain class:

             org.example.myapp.domain.Book

     Then:

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

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


                                                                        31

Tuesday, 1 November 11
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




                                                         32

Tuesday, 1 November 11
Option 5: Remote service back-end
    Don’t have to use GORM
    Use only controllers and services
          • Grails services back onto remote services


                                      Web App



            SOAP, RMI, HTTP Invoker, etc.



                           Invoice          Log Service
                                                          ...


                                                                33

Tuesday, 1 November 11
Share your model!




                         34

Tuesday, 1 November 11
Database Management
                         Hibernate ‘update’
                                 +
                          Production data
                                 =

                                 ?


                                              35

Tuesday, 1 November 11
Database Migration Plugin
                   Pre-production, Hibernate ‘update’ or ‘create-drop’



                                 dbm-generate-changelog
                                   dbm-changelog-sync




                                  Change domain model




                                      dbm-gorm-diff
                                       dbm-update


                                                                         36

Tuesday, 1 November 11
Reverse Engineering Plugin



                         class Person {
                             String name
                             Integer age
                             ...
                         }




                                    37

Tuesday, 1 November 11
Database Management

           Database Migration

               http://grails.org/plugin/database-migration



           Reverse Engineering

               http://grails.org/plugin/database-migration




                                                             38

Tuesday, 1 November 11
Integration Points

    Build
    Dependencies
    Database
    Deployment
    Spring



                         39

Tuesday, 1 November 11
grails war

    Build properties:
          • grails.war.copyToWebApp
          • grails.war.dependencies
          • grails.war.resources
          • grails.project.war.file




                                      40

Tuesday, 1 November 11
Control of JARs
        grails.project.dependency.resolution = {
          defaultDependenciesProvided true
          inherits "global"
          log "warn"
          ...
        }
              grails war --nojars => WEB-INF/lib/<empty>
                     => No Grails JARs in WEB-INF/lib




                                                           41

Tuesday, 1 November 11
Data Source
      JNDI:

          dataSource {
            jndiName = "java:comp/env/myDataSource"
          }


     System property:

         dataSource {
           url = System.getProperty("JDBC_STRING")
         }


                                                      42

Tuesday, 1 November 11
Data Source
    Config.groovy:

          grails.config.locations = [
            "file:./${appName}-config.groovy",
            "classpath:${appName}-config.groovy" ]


    For run-app:         ./<app>-config.groovy


    For Tomcat:          tomcat/lib/<app>-config.groovy



                                                          43

Tuesday, 1 November 11
Integration Points

    Build
    Dependencies
    Database
    Deployment
    Spring



                         44

Tuesday, 1 November 11
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




                                        45

Tuesday, 1 November 11
Example
    import ...
    beans = {
      credentialMatcher(Sha1CredentialsMatcher) {
         storedCredentialsHexEncoded = true
      }

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




                                                                46

Tuesday, 1 November 11
Enterprise Integration

    Spring opens up a world of possibilities
          • Spring Integration/Camel
          • Messaging (JMS/AMQP)
          • ESB
          • RMI, HttpInvoker, etc.
    Web services & REST




                                               47

Tuesday, 1 November 11
Grails Plugins

    Routing
    JMS, RabbitMQ
    CXF, Spring-WS, WS-Client
    REST




                                48

Tuesday, 1 November 11
JMS Plugin Example
   Add any required dependencies (BuildConfig.groovy)
    dependencies {
      compile 'org.apache.activemq:activemq-core:5.3.0'
    }



   Configure JMS factory (resources.groovy)
    jmsConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) {
      brokerURL = 'vm://localhost'
    }




                                                                    49

Tuesday, 1 November 11
JMS Plugin Example
     Send messages
      import javax.jms.Message

      class SomeController {
         def jmsService

          def someAction = {
            jmsService.send(service: 'initial', 1) { Message msg ->
               msg.JMSReplyTo = createDestination(service: 'reply')
               msg
            }
          }
      }




                                                                      50

Tuesday, 1 November 11
JMS Plugin Example
     Listen for messages
      class ListeningService {
         static expose = ['jms']

          def onMessage(message) {
            assert message == 1
          }
      }




                                     51

Tuesday, 1 November 11
Demo

    Demo




                         52


Tuesday, 1 November 11
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




                                                       53

Tuesday, 1 November 11
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/




                                                        54

Tuesday, 1 November 11
Q&A

    Q&A




                         55


Tuesday, 1 November 11
Ad

Recommended

Big Data & Cloud | Cloud Storage Simplified | Adrian Cole
Big Data & Cloud | Cloud Storage Simplified | Adrian Cole
JAX London
 
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
Java Tech & Tools | Big Blobs: Moving Big Data In and Out of the Cloud | Adri...
JAX London
 
Puppet and Telefonica R&D
Puppet and Telefonica R&D
Puppet
 
Java EE 7 Soup to Nuts at JavaOne 2014
Java EE 7 Soup to Nuts at JavaOne 2014
Arun Gupta
 
Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous Integration
Giacomo Vacca
 
Scaling Django
Scaling Django
Mike Malone
 
Optimizing WordPress Performance on Shared Web Hosting
Optimizing WordPress Performance on Shared Web Hosting
Jon Brown
 
A year in the life of a Grails startup
A year in the life of a Grails startup
tomaslin
 
Cloudstack at Spotify
Cloudstack at Spotify
Noa Resare
 
Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1
billdigman
 
Performance of Microservice frameworks on different JVMs
Performance of Microservice frameworks on different JVMs
Maarten Smeets
 
Docker
Docker
Chen Chun
 
Optimizing Docker Images
Optimizing Docker Images
Brian DeHamer
 
Australian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStack
Matt Ray
 
Threads Needles Stacks Heaps - Java edition
Threads Needles Stacks Heaps - Java edition
Ovidiu Dimulescu
 
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet
 
Using Puppet - Real World Configuration Management
Using Puppet - Real World Configuration Management
James Turnbull
 
Performance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMs
Maarten Smeets
 
iPaas with Fuse Fabric Technology
iPaas with Fuse Fabric Technology
Charles Moulliard
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
Arun Gupta
 
Java & containers: What I wish I knew before I used it | DevNation Tech Talk
Java & containers: What I wish I knew before I used it | DevNation Tech Talk
Red Hat Developers
 
Node.js, toy or power tool?
Node.js, toy or power tool?
Ovidiu Dimulescu
 
Integrated Cache on Netscaler
Integrated Cache on Netscaler
Mark Hillick
 
제4회 한국IBM과 함께하는 난공불락 오픈소스 인프라 세미나-Ranchers
제4회 한국IBM과 함께하는 난공불락 오픈소스 인프라 세미나-Ranchers
Tommy Lee
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
Arun Gupta
 
Cannibalising The Google App Engine
Cannibalising The Google App Engine
catherinewall
 
Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)
Johan Mynhardt
 
London devops logging
London devops logging
Tomas Doran
 
аветов презентация 3.0
аветов презентация 3.0
Андрей Криминенко
 
Hum2220 sp2015 syllabus
Hum2220 sp2015 syllabus
ProfWillAdams
 

More Related Content

What's hot (20)

Cloudstack at Spotify
Cloudstack at Spotify
Noa Resare
 
Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1
billdigman
 
Performance of Microservice frameworks on different JVMs
Performance of Microservice frameworks on different JVMs
Maarten Smeets
 
Docker
Docker
Chen Chun
 
Optimizing Docker Images
Optimizing Docker Images
Brian DeHamer
 
Australian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStack
Matt Ray
 
Threads Needles Stacks Heaps - Java edition
Threads Needles Stacks Heaps - Java edition
Ovidiu Dimulescu
 
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet
 
Using Puppet - Real World Configuration Management
Using Puppet - Real World Configuration Management
James Turnbull
 
Performance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMs
Maarten Smeets
 
iPaas with Fuse Fabric Technology
iPaas with Fuse Fabric Technology
Charles Moulliard
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
Arun Gupta
 
Java & containers: What I wish I knew before I used it | DevNation Tech Talk
Java & containers: What I wish I knew before I used it | DevNation Tech Talk
Red Hat Developers
 
Node.js, toy or power tool?
Node.js, toy or power tool?
Ovidiu Dimulescu
 
Integrated Cache on Netscaler
Integrated Cache on Netscaler
Mark Hillick
 
제4회 한국IBM과 함께하는 난공불락 오픈소스 인프라 세미나-Ranchers
제4회 한국IBM과 함께하는 난공불락 오픈소스 인프라 세미나-Ranchers
Tommy Lee
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
Arun Gupta
 
Cannibalising The Google App Engine
Cannibalising The Google App Engine
catherinewall
 
Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)
Johan Mynhardt
 
London devops logging
London devops logging
Tomas Doran
 
Cloudstack at Spotify
Cloudstack at Spotify
Noa Resare
 
Java EE Servlet JSP Tutorial- Cookbook 1
Java EE Servlet JSP Tutorial- Cookbook 1
billdigman
 
Performance of Microservice frameworks on different JVMs
Performance of Microservice frameworks on different JVMs
Maarten Smeets
 
Optimizing Docker Images
Optimizing Docker Images
Brian DeHamer
 
Australian OpenStack User Group August 2012: Chef for OpenStack
Australian OpenStack User Group August 2012: Chef for OpenStack
Matt Ray
 
Threads Needles Stacks Heaps - Java edition
Threads Needles Stacks Heaps - Java edition
Ovidiu Dimulescu
 
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet at DemonWare - Ruaidhri Power - Puppetcamp Dublin '12
Puppet
 
Using Puppet - Real World Configuration Management
Using Puppet - Real World Configuration Management
James Turnbull
 
Performance of Microservice Frameworks on different JVMs
Performance of Microservice Frameworks on different JVMs
Maarten Smeets
 
iPaas with Fuse Fabric Technology
iPaas with Fuse Fabric Technology
Charles Moulliard
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
Arun Gupta
 
Java & containers: What I wish I knew before I used it | DevNation Tech Talk
Java & containers: What I wish I knew before I used it | DevNation Tech Talk
Red Hat Developers
 
Node.js, toy or power tool?
Node.js, toy or power tool?
Ovidiu Dimulescu
 
Integrated Cache on Netscaler
Integrated Cache on Netscaler
Mark Hillick
 
제4회 한국IBM과 함께하는 난공불락 오픈소스 인프라 세미나-Ranchers
제4회 한국IBM과 함께하는 난공불락 오픈소스 인프라 세미나-Ranchers
Tommy Lee
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
Arun Gupta
 
Cannibalising The Google App Engine
Cannibalising The Google App Engine
catherinewall
 
Maven: from Scratch to Production (.pdf)
Maven: from Scratch to Production (.pdf)
Johan Mynhardt
 
London devops logging
London devops logging
Tomas Doran
 

Viewers also liked (20)

аветов презентация 3.0
аветов презентация 3.0
Андрей Криминенко
 
Hum2220 sp2015 syllabus
Hum2220 sp2015 syllabus
ProfWillAdams
 
Redis the better NoSQL
Redis the better NoSQL
OpenFest team
 
Hum2220 1330 art of the stone age
Hum2220 1330 art of the stone age
ProfWillAdams
 
Aperitive festive
Aperitive festive
Ralu Toia
 
Hum2220 1030 pompeii roman time capsule
Hum2220 1030 pompeii roman time capsule
ProfWillAdams
 
Hum2220 1330 egyptian mummification
Hum2220 1330 egyptian mummification
ProfWillAdams
 
National FORUM of Multicultural Issues Journal, 8(2) 2011
National FORUM of Multicultural Issues Journal, 8(2) 2011
drcollins1
 
Kemungkinan
Kemungkinan
Jeneng Omega
 
Hum2220 0915 syllabus
Hum2220 0915 syllabus
ProfWillAdams
 
2011 Pmo Symposium Enhancing The Pmo Partership Final
2011 Pmo Symposium Enhancing The Pmo Partership Final
sremingt
 
Mob home
Mob home
needtoshare
 
Finl syll tec 2032 fall_2011
Finl syll tec 2032 fall_2011
pkirk63
 
Електронни пари: Пътят до BitCoin и поглед напред
Електронни пари: Пътят до BitCoin и поглед напред
OpenFest team
 
Artikel Wirausaha
Artikel Wirausaha
21 Memento
 
2011 State of the Safety Net Report
2011 State of the Safety Net Report
Direct Relief
 
гарчиггүй 1
гарчиггүй 1
mongoo_8301
 
Arh2050 sp2015 syllabus
Arh2050 sp2015 syllabus
ProfWillAdams
 
MorenoMassip_Avi
MorenoMassip_Avi
alanmorenomassip
 
Tsunami response six months later
Tsunami response six months later
Direct Relief
 
Hum2220 sp2015 syllabus
Hum2220 sp2015 syllabus
ProfWillAdams
 
Redis the better NoSQL
Redis the better NoSQL
OpenFest team
 
Hum2220 1330 art of the stone age
Hum2220 1330 art of the stone age
ProfWillAdams
 
Aperitive festive
Aperitive festive
Ralu Toia
 
Hum2220 1030 pompeii roman time capsule
Hum2220 1030 pompeii roman time capsule
ProfWillAdams
 
Hum2220 1330 egyptian mummification
Hum2220 1330 egyptian mummification
ProfWillAdams
 
National FORUM of Multicultural Issues Journal, 8(2) 2011
National FORUM of Multicultural Issues Journal, 8(2) 2011
drcollins1
 
Hum2220 0915 syllabus
Hum2220 0915 syllabus
ProfWillAdams
 
2011 Pmo Symposium Enhancing The Pmo Partership Final
2011 Pmo Symposium Enhancing The Pmo Partership Final
sremingt
 
Finl syll tec 2032 fall_2011
Finl syll tec 2032 fall_2011
pkirk63
 
Електронни пари: Пътят до BitCoin и поглед напред
Електронни пари: Пътят до BitCoin и поглед напред
OpenFest team
 
Artikel Wirausaha
Artikel Wirausaha
21 Memento
 
2011 State of the Safety Net Report
2011 State of the Safety Net Report
Direct Relief
 
гарчиггүй 1
гарчиггүй 1
mongoo_8301
 
Arh2050 sp2015 syllabus
Arh2050 sp2015 syllabus
ProfWillAdams
 
Tsunami response six months later
Tsunami response six months later
Direct Relief
 
Ad

Similar to Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook (20)

Adopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf Europe
KlausBaumecker
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
GR8Conf
 
GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook
GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook
GR8Conf
 
CloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heaven
Patrick Chanezon
 
Running your Java EE applications in the Cloud
Running your Java EE applications in the Cloud
Arun Gupta
 
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
kennethaliu
 
Get Ready for JIRA 5 - AtlasCamp 2011
Get Ready for JIRA 5 - AtlasCamp 2011
Atlassian
 
Cloudfoundry Overview
Cloudfoundry Overview
rajdeep
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
Ryan Cuprak
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
Ryan Cuprak
 
Adobe Illustrator 2025 Crack Download free
Adobe Illustrator 2025 Crack Download free
cariaelif911
 
USING GRAALVM IN PRODUCTION - JAVAONE.pdf
USING GRAALVM IN PRODUCTION - JAVAONE.pdf
Alina Yurenko
 
Traktor pro Crack 2025 Free Download Advance Form
Traktor pro Crack 2025 Free Download Advance Form
doctorveterinary589
 
PDF Reader Pro Crack FREE Download Latest Version
PDF Reader Pro Crack FREE Download Latest Version
waqarcracker5
 
Groovy & Grails for Spring/Java developers
Groovy & Grails for Spring/Java developers
Peter Ledbrook
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]
Ryan Cuprak
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Bring the Action: Using GraalVM in Production
Bring the Action: Using GraalVM in Production
Alina Yurenko
 
HTML5 and Sencha Touch
HTML5 and Sencha Touch
Patrick Sheridan
 
Cloud foundry and openstackcloud
Cloud foundry and openstackcloud
Francisco Gonçalves
 
Adopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf Europe
KlausBaumecker
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
GR8Conf
 
GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook
GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook
GR8Conf
 
CloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heaven
Patrick Chanezon
 
Running your Java EE applications in the Cloud
Running your Java EE applications in the Cloud
Arun Gupta
 
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012
kennethaliu
 
Get Ready for JIRA 5 - AtlasCamp 2011
Get Ready for JIRA 5 - AtlasCamp 2011
Atlassian
 
Cloudfoundry Overview
Cloudfoundry Overview
rajdeep
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
Ryan Cuprak
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
Ryan Cuprak
 
Adobe Illustrator 2025 Crack Download free
Adobe Illustrator 2025 Crack Download free
cariaelif911
 
USING GRAALVM IN PRODUCTION - JAVAONE.pdf
USING GRAALVM IN PRODUCTION - JAVAONE.pdf
Alina Yurenko
 
Traktor pro Crack 2025 Free Download Advance Form
Traktor pro Crack 2025 Free Download Advance Form
doctorveterinary589
 
PDF Reader Pro Crack FREE Download Latest Version
PDF Reader Pro Crack FREE Download Latest Version
waqarcracker5
 
Groovy & Grails for Spring/Java developers
Groovy & Grails for Spring/Java developers
Peter Ledbrook
 
Faster java ee builds with gradle [con4921]
Faster java ee builds with gradle [con4921]
Ryan Cuprak
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Bring the Action: Using GraalVM in Production
Bring the Action: Using GraalVM in Production
Alina Yurenko
 
Ad

More from JAX London (20)

Java Tech & Tools | Continuous Delivery - the Writing is on the Wall | John S...
Java Tech & Tools | Continuous Delivery - the Writing is on the Wall | John S...
JAX London
 
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
JAX London
 
Keynote | Middleware Everywhere - Ready for Mobile and Cloud | Dr. Mark Little
Keynote | Middleware Everywhere - Ready for Mobile and Cloud | Dr. Mark Little
JAX London
 
Spring Day | WaveMaker - Spring Roo - SpringSource Tool Suite: Choosing the R...
Spring Day | WaveMaker - Spring Roo - SpringSource Tool Suite: Choosing the R...
JAX London
 
Spring Day | Behind the Scenes at Spring Batch | Dave Syer
Spring Day | Behind the Scenes at Spring Batch | Dave Syer
JAX London
 
Spring Day | Spring 3.1 in a Nutshell | Sam Brannen
Spring Day | Spring 3.1 in a Nutshell | Sam Brannen
JAX London
 
Spring Day | Identity Management with Spring Security | Dave Syer
Spring Day | Identity Management with Spring Security | Dave Syer
JAX London
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
JAX London
 
Spring Day | Data Access 2.0? Please Welcome Spring Data! | Oliver Gierke
Spring Day | Data Access 2.0? Please Welcome Spring Data! | Oliver Gierke
JAX London
 
Keynote | The Rise and Fall and Rise of Java | James Governor
Keynote | The Rise and Fall and Rise of Java | James Governor
JAX London
 
Java Tech & Tools | OSGi Best Practices | Emily Jiang
Java Tech & Tools | OSGi Best Practices | Emily Jiang
JAX London
 
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
JAX London
 
Java Tech & Tools | Social Media in Programming in Java | Khanderao Kand
Java Tech & Tools | Social Media in Programming in Java | Khanderao Kand
JAX London
 
Java Tech & Tools | Just Keep Passing the Message | Russel Winder
Java Tech & Tools | Just Keep Passing the Message | Russel Winder
JAX London
 
Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sande...
Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sande...
JAX London
 
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
JAX London
 
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
JAX London
 
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
JAX London
 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
JAX London
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
JAX London
 
Java Tech & Tools | Continuous Delivery - the Writing is on the Wall | John S...
Java Tech & Tools | Continuous Delivery - the Writing is on the Wall | John S...
JAX London
 
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
Java Tech & Tools | Mapping, GIS and Geolocating Data in Java | Joachim Van d...
JAX London
 
Keynote | Middleware Everywhere - Ready for Mobile and Cloud | Dr. Mark Little
Keynote | Middleware Everywhere - Ready for Mobile and Cloud | Dr. Mark Little
JAX London
 
Spring Day | WaveMaker - Spring Roo - SpringSource Tool Suite: Choosing the R...
Spring Day | WaveMaker - Spring Roo - SpringSource Tool Suite: Choosing the R...
JAX London
 
Spring Day | Behind the Scenes at Spring Batch | Dave Syer
Spring Day | Behind the Scenes at Spring Batch | Dave Syer
JAX London
 
Spring Day | Spring 3.1 in a Nutshell | Sam Brannen
Spring Day | Spring 3.1 in a Nutshell | Sam Brannen
JAX London
 
Spring Day | Identity Management with Spring Security | Dave Syer
Spring Day | Identity Management with Spring Security | Dave Syer
JAX London
 
Spring Day | Spring and Scala | Eberhard Wolff
Spring Day | Spring and Scala | Eberhard Wolff
JAX London
 
Spring Day | Data Access 2.0? Please Welcome Spring Data! | Oliver Gierke
Spring Day | Data Access 2.0? Please Welcome Spring Data! | Oliver Gierke
JAX London
 
Keynote | The Rise and Fall and Rise of Java | James Governor
Keynote | The Rise and Fall and Rise of Java | James Governor
JAX London
 
Java Tech & Tools | OSGi Best Practices | Emily Jiang
Java Tech & Tools | OSGi Best Practices | Emily Jiang
JAX London
 
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
Java Tech & Tools | Beyond the Data Grid: Coherence, Normalisation, Joins and...
JAX London
 
Java Tech & Tools | Social Media in Programming in Java | Khanderao Kand
Java Tech & Tools | Social Media in Programming in Java | Khanderao Kand
JAX London
 
Java Tech & Tools | Just Keep Passing the Message | Russel Winder
Java Tech & Tools | Just Keep Passing the Message | Russel Winder
JAX London
 
Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sande...
Java Tech & Tools | Deploying Java & Play Framework Apps to the Cloud | Sande...
JAX London
 
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
Java EE | Modular EJBs for Enterprise OSGi | Tim Ward
JAX London
 
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
JAX London
 
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
JAX London
 
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
JAX London
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
JAX London
 

Recently uploaded (20)

Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Seminar: New Data: Passkey Adoption in the Workforce.pptx
FIDO Alliance
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
The Future of Technology: 2025-2125 by Saikat Basu.pdf
The Future of Technology: 2025-2125 by Saikat Basu.pdf
Saikat Basu
 
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
 

Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook

  • 1. Peter Ledbrook / VMware Grails in the Java Enterprise Tuesday, 1 November 11
  • 2. 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) 2 Tuesday, 1 November 11
  • 3. What is Grails? Grails Servlet Web MVC GSP (Views) Container GORM Database I18n (Data Access) Build Test Support Doc Engine 3 Tuesday, 1 November 11
  • 4. What is Grails? Grails 4 Tuesday, 1 November 11
  • 5. 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 5 Tuesday, 1 November 11
  • 6. Say bye-bye to the plumbing! 6 Tuesday, 1 November 11
  • 7. Demo Demo 7 Tuesday, 1 November 11
  • 8. Enterprise requirements Web App Messaging JEE Legacy Services Databases Is this a problem for Grails apps? 8 Tuesday, 1 November 11
  • 9. Integration Points Build Dependencies Database Deployment Spring 9 Tuesday, 1 November 11
  • 10. Integration Points Build Dependencies Database Deployment Spring 10 Tuesday, 1 November 11
  • 11. Build 11 Tuesday, 1 November 11
  • 12. 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 12 Tuesday, 1 November 11
  • 13. Ant Integration An Ant task built in (grails.ant.GrailsTask) Template Ant build: grails integrate-with --ant • Uses Ivy for dependency management • Not compatible with Ant 1.8 ...or use ‘java’ task to call Grails command • Grails manages dependencies • Use ‘grails’ for build 13 Tuesday, 1 November 11
  • 14. Maven Maven Grails Plugin: https://github.com/grails/grails-maven Use Maven 2 or 3 to build Grails projects Declare dependencies in POM Works for both applications and plugins! Integration test framework: https://github.com/grails/ grails_maven_plugin_testing_tests 14 Tuesday, 1 November 11
  • 15. Getting Started mvn archetype-generate ... e.g. -Xmx256m mvn initialize -XX:MaxPermSize=256m Set MAVEN_OPTS Optional: add ‘pom true’ to dependency DSL 15 Tuesday, 1 November 11
  • 16. Packaging Types ‘war’ • Must configure execution section • Works with plugins that depend on ‘war’ ‘grails-app’ • Less configuration ‘grails-plugin’ • For plugins! 16 Tuesday, 1 November 11
  • 17. Maven & Grails Plugins > grails release-plugin == > mvn deploy 17 Tuesday, 1 November 11
  • 18. Maven & Grails Plugins Either: <dependency> <groupId>org.grails.plugins<groupId> <artifactId>hibernate</artifactId> <type>grails-plugin</type> </dependency> Use ‘mvn deploy’ or Release plugin! And ‘pom: false’ 18 Tuesday, 1 November 11
  • 19. Maven & Grails Plugins Or: grails.project.dependency.resolution = { ... plugins { compile ":hibernate:1.3.6" } ... } 19 Tuesday, 1 November 11
  • 20. Customise the Build Create new commands in <proj>/scripts Package the commands in a plugin! Create <proj>/scripts/_Events.groovy • Interact with standard build steps • Add test types • Configure embedded Tomcat 20 Tuesday, 1 November 11
  • 21. What the future holds... Grails 3.0 will probably move to Gradle • More powerful and more flexible • Standard, well documented API • Ant & Maven support 21 Tuesday, 1 November 11
  • 22. Integration Points Build Dependencies Database Deployment Spring 22 Tuesday, 1 November 11
  • 23. Dependencies are JARs Use any Java library you like! Full support for Maven-compatible repositories Declarative dependencies Plugins can be declared the same way 23 Tuesday, 1 November 11
  • 24. Dependency DSL grails.project.dependency.resolution = { inherits "global" log "warn" repositories { grailsHome() mavenCentral() mavenRepo "http://localhost:8081/..." } ... } 24 Tuesday, 1 November 11
  • 25. Dependency DSL grails.project.dependency.resolution = { inherits "global" log "warn" ... dependencies { compile "org.tmatesoft.svnkit:svnkit:1.3.3" test "org.gmock:gmock:0.8.1" } ... } 25 Tuesday, 1 November 11
  • 26. Integration Points Build Dependencies Database Deployment Spring 26 Tuesday, 1 November 11
  • 27. ‘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 27 Tuesday, 1 November 11
  • 28. 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" } } 28 Tuesday, 1 November 11
  • 29. 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 29 Tuesday, 1 November 11
  • 30. 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 30 Tuesday, 1 November 11
  • 31. Constraints Given domain class: org.example.myapp.domain.Book Then: src/java/org/example/myapp/domain/BookConstraints.groovy constraints = { title blank: false, unique: true ... } 31 Tuesday, 1 November 11
  • 32. 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 32 Tuesday, 1 November 11
  • 33. Option 5: Remote service back-end Don’t have to use GORM Use only controllers and services • Grails services back onto remote services Web App SOAP, RMI, HTTP Invoker, etc. Invoice Log Service ... 33 Tuesday, 1 November 11
  • 34. Share your model! 34 Tuesday, 1 November 11
  • 35. Database Management Hibernate ‘update’ + Production data = ? 35 Tuesday, 1 November 11
  • 36. Database Migration Plugin Pre-production, Hibernate ‘update’ or ‘create-drop’ dbm-generate-changelog dbm-changelog-sync Change domain model dbm-gorm-diff dbm-update 36 Tuesday, 1 November 11
  • 37. Reverse Engineering Plugin class Person { String name Integer age ... } 37 Tuesday, 1 November 11
  • 38. Database Management Database Migration http://grails.org/plugin/database-migration Reverse Engineering http://grails.org/plugin/database-migration 38 Tuesday, 1 November 11
  • 39. Integration Points Build Dependencies Database Deployment Spring 39 Tuesday, 1 November 11
  • 40. grails war Build properties: • grails.war.copyToWebApp • grails.war.dependencies • grails.war.resources • grails.project.war.file 40 Tuesday, 1 November 11
  • 41. Control of JARs grails.project.dependency.resolution = { defaultDependenciesProvided true inherits "global" log "warn" ... } grails war --nojars => WEB-INF/lib/<empty> => No Grails JARs in WEB-INF/lib 41 Tuesday, 1 November 11
  • 42. Data Source JNDI: dataSource { jndiName = "java:comp/env/myDataSource" } System property: dataSource { url = System.getProperty("JDBC_STRING") } 42 Tuesday, 1 November 11
  • 43. Data Source Config.groovy: grails.config.locations = [ "file:./${appName}-config.groovy", "classpath:${appName}-config.groovy" ] For run-app: ./<app>-config.groovy For Tomcat: tomcat/lib/<app>-config.groovy 43 Tuesday, 1 November 11
  • 44. Integration Points Build Dependencies Database Deployment Spring 44 Tuesday, 1 November 11
  • 45. 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 45 Tuesday, 1 November 11
  • 46. Example import ... beans = { credentialMatcher(Sha1CredentialsMatcher) { storedCredentialsHexEncoded = true } sessionFactory(ConfigurableLocalSessionFactoryBean) { dataSource = ref("dataSource") hibernateProperties = [ "hibernate.hbm2ddl.auto": "create-drop", "hibernate.show_sql": true ] } } 46 Tuesday, 1 November 11
  • 47. Enterprise Integration Spring opens up a world of possibilities • Spring Integration/Camel • Messaging (JMS/AMQP) • ESB • RMI, HttpInvoker, etc. Web services & REST 47 Tuesday, 1 November 11
  • 48. Grails Plugins Routing JMS, RabbitMQ CXF, Spring-WS, WS-Client REST 48 Tuesday, 1 November 11
  • 49. JMS Plugin Example Add any required dependencies (BuildConfig.groovy) dependencies { compile 'org.apache.activemq:activemq-core:5.3.0' } Configure JMS factory (resources.groovy) jmsConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) { brokerURL = 'vm://localhost' } 49 Tuesday, 1 November 11
  • 50. JMS Plugin Example Send messages import javax.jms.Message class SomeController { def jmsService def someAction = { jmsService.send(service: 'initial', 1) { Message msg -> msg.JMSReplyTo = createDestination(service: 'reply') msg } } } 50 Tuesday, 1 November 11
  • 51. JMS Plugin Example Listen for messages class ListeningService { static expose = ['jms'] def onMessage(message) { assert message == 1 } } 51 Tuesday, 1 November 11
  • 52. Demo Demo 52 Tuesday, 1 November 11
  • 53. 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 53 Tuesday, 1 November 11
  • 54. More info w: http://grails.org/ f: http://grails.org/Mailing+Lists e: [email protected] t: pledbrook b: http://blog.springsource.com/author/peter-ledbrook/ 54 Tuesday, 1 November 11
  • 55. Q&A Q&A 55 Tuesday, 1 November 11