SlideShare una empresa de Scribd logo
1 de 39
Descargar para leer sin conexión
Grails in the Enterprise


                       Peter Ledbrook




Monday, 30 May 2011                              1
Integration Points

     • Build
     • Dependencies
     • Database
     • Deployment
     • Spring




                          2

Monday, 30 May 2011           2
Integration Points

     • Build
     • Dependencies
     • Database
     • Deployment
     • Spring




                          3

Monday, 30 May 2011           3
Build




                      4

Monday, 30 May 2011       4
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




                                                      5

Monday, 30 May 2011                                       5
6

Monday, 30 May 2011       6
Maven

     • Maven Grails Plugin:
          https://github.com/grails/grails-maven
     • Use Maven 2 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




                                                                7

Monday, 30 May 2011                                                  7
Getting Started



                               mvn archetype-generate ...


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

                                  Set MAVEN_OPTS


                      Optional: add ‘pom true’ to dependency DSL

                                                                   8

Monday, 30 May 2011                                                     8
Packaging Types

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




                                                      9

Monday, 30 May 2011                                       9
10

Monday, 30 May 2011        10
Maven & Grails Plugins




                      > grails release-plugin
                                ==
                          > mvn deploy


                                                11

Monday, 30 May 2011                                  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’

                                                              12

Monday, 30 May 2011                                                12
Maven & Grails Plugins


              Or:

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



                                                                 13

Monday, 30 May 2011                                                   13
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




                                                 14

Monday, 30 May 2011                                   14
What the future holds...

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




                                              15

Monday, 30 May 2011                                15
Integration Points

     • Build
     • Dependencies
     • Database
     • Deployment
     • Spring




                          16

Monday, 30 May 2011            16
Dependency DSL


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


                                                         17

Monday, 30 May 2011                                           17
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"
             }
             ...
           }


                                                               18

Monday, 30 May 2011                                                 18
Integration Points

     • Build
     • Dependencies
     • Database
     • Deployment
     • Spring




                          19

Monday, 30 May 2011            19
‘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




                                                                20

Monday, 30 May 2011                                                  20
Option 1: Custom ORM mapping




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


                                                 21

Monday, 30 May 2011                                   21
Option 2: JPA annotations




      <?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>


                                               22

Monday, 30 May 2011                                 22
Option 3: Hibernate XML Mappings




      <?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>


                                                         23

Monday, 30 May 2011                                           23
Constraints


        Given domain class:

                  org.example.myapp.domain.Book

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

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

                                                                             24

Monday, 30 May 2011                                                               24
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




                                                                25

Monday, 30 May 2011                                                  25
Share your model!




                         26

Monday, 30 May 2011           26
Database Management

     • Hibernate auto-DDL
          – Good for dev & test
          – Bad for production!
     • Data migration
          – http://grails.org/plugin/database-migration
     • Reverse engineer a model
          – http://grails.org/plugin/db-reverse-engineer




                                                           27

Monday, 30 May 2011                                             27
Integration Points

     • Build
     • Dependencies
     • Database
     • Deployment
     • Spring




                          28

Monday, 30 May 2011            28
grails war

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




                                      29

Monday, 30 May 2011                        29
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




                                                              30

Monday, 30 May 2011                                                30
Data Source

        JNDI:

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

        System property:

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

                                                           31

Monday, 30 May 2011                                             31
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


                                                             32

Monday, 30 May 2011                                               32
Integration Points

     • Build
     • Dependencies
     • Database
     • Deployment
     • Spring




                          33

Monday, 30 May 2011            33
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




                                           34

Monday, 30 May 2011                             34
Example

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

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



                                                                   35

Monday, 30 May 2011                                                     35
Enterprise Integration

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




                                                  36

Monday, 30 May 2011                                    36
Grails Plugins

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




                                     37

Monday, 30 May 2011                       37
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




                                                        38

Monday, 30 May 2011                                          38
Thank you!




                      Q&A



                            39

Monday, 30 May 2011              39

Más contenido relacionado

Similar a GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook

GR8Conf 2011: Tuning Grails Applications by Peter Ledbrook
GR8Conf 2011: Tuning Grails Applications by Peter LedbrookGR8Conf 2011: Tuning Grails Applications by Peter Ledbrook
GR8Conf 2011: Tuning Grails Applications by Peter LedbrookGR8Conf
 
Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
Java Tech & Tools | Grails in the Java Enterprise | Peter LedbrookJava Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
Java Tech & Tools | Grails in the Java Enterprise | Peter LedbrookJAX London
 
Implementing Quality on Java projects
Implementing Quality on Java projectsImplementing Quality on Java projects
Implementing Quality on Java projectsVincent Massol
 
5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...
5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...
5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...Atlassian
 
NodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebNodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebJakub Nesetril
 
Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Łukasz Proszek
 
Webpack essentails - feb 19, 2020
Webpack essentails - feb 19, 2020Webpack essentails - feb 19, 2020
Webpack essentails - feb 19, 2020Jesse Colligan
 
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?Dmitri Shiryaev
 
Cloudops fundamentals management, tdd, test driven design, continuous integra...
Cloudops fundamentals management, tdd, test driven design, continuous integra...Cloudops fundamentals management, tdd, test driven design, continuous integra...
Cloudops fundamentals management, tdd, test driven design, continuous integra...Bret Piatt
 
DevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesDevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesFab L
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Robert Scholte
 
CI from scratch with Jenkins (EN)
CI from scratch with Jenkins (EN)CI from scratch with Jenkins (EN)
CI from scratch with Jenkins (EN)Borislav Traykov
 
Iteratively introducing Puppet technologies in the brownfield; Jeffrey Miller
Iteratively introducing Puppet technologies in the brownfield; Jeffrey MillerIteratively introducing Puppet technologies in the brownfield; Jeffrey Miller
Iteratively introducing Puppet technologies in the brownfield; Jeffrey MillerPuppet
 
Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)Robert Scholte
 
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and KibanaPuppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibanapkill
 
Pragmatische Plone Projekte
Pragmatische Plone ProjektePragmatische Plone Projekte
Pragmatische Plone ProjekteAndreas Jung
 
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Gareth Bowles
 

Similar a GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook (20)

GR8Conf 2011: Tuning Grails Applications by Peter Ledbrook
GR8Conf 2011: Tuning Grails Applications by Peter LedbrookGR8Conf 2011: Tuning Grails Applications by Peter Ledbrook
GR8Conf 2011: Tuning Grails Applications by Peter Ledbrook
 
Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
Java Tech & Tools | Grails in the Java Enterprise | Peter LedbrookJava Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
Java Tech & Tools | Grails in the Java Enterprise | Peter Ledbrook
 
Implementing Quality on Java projects
Implementing Quality on Java projectsImplementing Quality on Java projects
Implementing Quality on Java projects
 
Simple Build Tool
Simple Build ToolSimple Build Tool
Simple Build Tool
 
5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...
5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...
5 Thing You're Not Doing, 4 Things You Should Stop Doing & 3 Things You Shoul...
 
NodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time WebNodeJS, CoffeeScript & Real-time Web
NodeJS, CoffeeScript & Real-time Web
 
Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.
 
Gallio Crafting A Toolchain
Gallio Crafting A ToolchainGallio Crafting A Toolchain
Gallio Crafting A Toolchain
 
Webpack essentails - feb 19, 2020
Webpack essentails - feb 19, 2020Webpack essentails - feb 19, 2020
Webpack essentails - feb 19, 2020
 
Automating the Quality
Automating the QualityAutomating the Quality
Automating the Quality
 
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?Hadoop:  Big Data Stacks validation w/ iTest  How to tame the elephant?
Hadoop: Big Data Stacks validation w/ iTest How to tame the elephant?
 
Cloudops fundamentals management, tdd, test driven design, continuous integra...
Cloudops fundamentals management, tdd, test driven design, continuous integra...Cloudops fundamentals management, tdd, test driven design, continuous integra...
Cloudops fundamentals management, tdd, test driven design, continuous integra...
 
DevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesDevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation Slides
 
Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)Apache Maven supports all Java (JokerConf 2018)
Apache Maven supports all Java (JokerConf 2018)
 
CI from scratch with Jenkins (EN)
CI from scratch with Jenkins (EN)CI from scratch with Jenkins (EN)
CI from scratch with Jenkins (EN)
 
Iteratively introducing Puppet technologies in the brownfield; Jeffrey Miller
Iteratively introducing Puppet technologies in the brownfield; Jeffrey MillerIteratively introducing Puppet technologies in the brownfield; Jeffrey Miller
Iteratively introducing Puppet technologies in the brownfield; Jeffrey Miller
 
Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)Apache Maven supports ALL Java (Javaland 2019)
Apache Maven supports ALL Java (Javaland 2019)
 
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and KibanaPuppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
Puppetconf 2015 - Puppet Reporting with Elasticsearch Logstash and Kibana
 
Pragmatische Plone Projekte
Pragmatische Plone ProjektePragmatische Plone Projekte
Pragmatische Plone Projekte
 
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
Managing Jenkins with Jenkins (Jenkins User Conference Palo Alto, 2013)
 

Más de GR8Conf

DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your TeamGR8Conf
 
Creating and testing REST contracts with Accurest Gradle
Creating and testing REST contracts with Accurest Gradle Creating and testing REST contracts with Accurest Gradle
Creating and testing REST contracts with Accurest Gradle GR8Conf
 
Mum, I want to be a Groovy full-stack developer
Mum, I want to be a Groovy full-stack developerMum, I want to be a Groovy full-stack developer
Mum, I want to be a Groovy full-stack developerGR8Conf
 
Metaprogramming with Groovy
Metaprogramming with GroovyMetaprogramming with Groovy
Metaprogramming with GroovyGR8Conf
 
Scraping with Geb
Scraping with GebScraping with Geb
Scraping with GebGR8Conf
 
How to create a conference android app with Groovy and Android
How to create a conference android app with Groovy and AndroidHow to create a conference android app with Groovy and Android
How to create a conference android app with Groovy and AndroidGR8Conf
 
Ratpack On the Docks
Ratpack On the DocksRatpack On the Docks
Ratpack On the DocksGR8Conf
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean CodeGR8Conf
 
Cut your Grails application to pieces - build feature plugins
Cut your Grails application to pieces - build feature pluginsCut your Grails application to pieces - build feature plugins
Cut your Grails application to pieces - build feature pluginsGR8Conf
 
Performance tuning Grails applications
 Performance tuning Grails applications Performance tuning Grails applications
Performance tuning Grails applicationsGR8Conf
 
Ratpack and Grails 3
 Ratpack and Grails 3 Ratpack and Grails 3
Ratpack and Grails 3GR8Conf
 
Grails & DevOps: continuous integration and delivery in the cloud
Grails & DevOps: continuous integration and delivery in the cloudGrails & DevOps: continuous integration and delivery in the cloud
Grails & DevOps: continuous integration and delivery in the cloudGR8Conf
 
Functional testing your Grails app with GEB
Functional testing your Grails app with GEBFunctional testing your Grails app with GEB
Functional testing your Grails app with GEBGR8Conf
 
Deploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPCDeploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPCGR8Conf
 
The Grails introduction workshop
The Grails introduction workshopThe Grails introduction workshop
The Grails introduction workshopGR8Conf
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spockGR8Conf
 
The Groovy Ecosystem Revisited
The Groovy Ecosystem RevisitedThe Groovy Ecosystem Revisited
The Groovy Ecosystem RevisitedGR8Conf
 
Groovy 3 and the new Groovy Meta Object Protocol in examples
Groovy 3 and the new Groovy Meta Object Protocol in examplesGroovy 3 and the new Groovy Meta Object Protocol in examples
Groovy 3 and the new Groovy Meta Object Protocol in examplesGR8Conf
 
Integration using Apache Camel and Groovy
Integration using Apache Camel and GroovyIntegration using Apache Camel and Groovy
Integration using Apache Camel and GroovyGR8Conf
 
CRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual MachineCRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual MachineGR8Conf
 

Más de GR8Conf (20)

DevOps Enabling Your Team
DevOps Enabling Your TeamDevOps Enabling Your Team
DevOps Enabling Your Team
 
Creating and testing REST contracts with Accurest Gradle
Creating and testing REST contracts with Accurest Gradle Creating and testing REST contracts with Accurest Gradle
Creating and testing REST contracts with Accurest Gradle
 
Mum, I want to be a Groovy full-stack developer
Mum, I want to be a Groovy full-stack developerMum, I want to be a Groovy full-stack developer
Mum, I want to be a Groovy full-stack developer
 
Metaprogramming with Groovy
Metaprogramming with GroovyMetaprogramming with Groovy
Metaprogramming with Groovy
 
Scraping with Geb
Scraping with GebScraping with Geb
Scraping with Geb
 
How to create a conference android app with Groovy and Android
How to create a conference android app with Groovy and AndroidHow to create a conference android app with Groovy and Android
How to create a conference android app with Groovy and Android
 
Ratpack On the Docks
Ratpack On the DocksRatpack On the Docks
Ratpack On the Docks
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean Code
 
Cut your Grails application to pieces - build feature plugins
Cut your Grails application to pieces - build feature pluginsCut your Grails application to pieces - build feature plugins
Cut your Grails application to pieces - build feature plugins
 
Performance tuning Grails applications
 Performance tuning Grails applications Performance tuning Grails applications
Performance tuning Grails applications
 
Ratpack and Grails 3
 Ratpack and Grails 3 Ratpack and Grails 3
Ratpack and Grails 3
 
Grails & DevOps: continuous integration and delivery in the cloud
Grails & DevOps: continuous integration and delivery in the cloudGrails & DevOps: continuous integration and delivery in the cloud
Grails & DevOps: continuous integration and delivery in the cloud
 
Functional testing your Grails app with GEB
Functional testing your Grails app with GEBFunctional testing your Grails app with GEB
Functional testing your Grails app with GEB
 
Deploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPCDeploying, Scaling, and Running Grails on AWS and VPC
Deploying, Scaling, and Running Grails on AWS and VPC
 
The Grails introduction workshop
The Grails introduction workshopThe Grails introduction workshop
The Grails introduction workshop
 
Idiomatic spock
Idiomatic spockIdiomatic spock
Idiomatic spock
 
The Groovy Ecosystem Revisited
The Groovy Ecosystem RevisitedThe Groovy Ecosystem Revisited
The Groovy Ecosystem Revisited
 
Groovy 3 and the new Groovy Meta Object Protocol in examples
Groovy 3 and the new Groovy Meta Object Protocol in examplesGroovy 3 and the new Groovy Meta Object Protocol in examples
Groovy 3 and the new Groovy Meta Object Protocol in examples
 
Integration using Apache Camel and Groovy
Integration using Apache Camel and GroovyIntegration using Apache Camel and Groovy
Integration using Apache Camel and Groovy
 
CRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual MachineCRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual Machine
 

Último

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Último (20)

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook

  • 1. Grails in the Enterprise Peter Ledbrook Monday, 30 May 2011 1
  • 2. Integration Points • Build • Dependencies • Database • Deployment • Spring 2 Monday, 30 May 2011 2
  • 3. Integration Points • Build • Dependencies • Database • Deployment • Spring 3 Monday, 30 May 2011 3
  • 4. Build 4 Monday, 30 May 2011 4
  • 5. 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 5 Monday, 30 May 2011 5
  • 7. Maven • Maven Grails Plugin: https://github.com/grails/grails-maven • Use Maven 2 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 7 Monday, 30 May 2011 7
  • 8. Getting Started mvn archetype-generate ... mvn initialize -Xmx256m e.g. -XX:MaxPermSize=256m Set MAVEN_OPTS Optional: add ‘pom true’ to dependency DSL 8 Monday, 30 May 2011 8
  • 9. Packaging Types • ‘war’ – Must configure execution section – Works with plugins that depend on ‘war’ • ‘grails-app’ – Less configuration • ‘grails-plugin’ – For plugins! 9 Monday, 30 May 2011 9
  • 10. 10 Monday, 30 May 2011 10
  • 11. Maven & Grails Plugins > grails release-plugin == > mvn deploy 11 Monday, 30 May 2011 11
  • 12. 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’ 12 Monday, 30 May 2011 12
  • 13. Maven & Grails Plugins Or: grails.project.dependency.resolution = { ... plugins { compile ":hibernate:1.3.6" } ... } 13 Monday, 30 May 2011 13
  • 14. 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 14 Monday, 30 May 2011 14
  • 15. What the future holds... • Grails 2.0 will move to Gradle – More powerful and more flexible – Standard, well documented API – Ant & Maven support 15 Monday, 30 May 2011 15
  • 16. Integration Points • Build • Dependencies • Database • Deployment • Spring 16 Monday, 30 May 2011 16
  • 17. Dependency DSL grails.project.dependency.resolution = { inherits "global" log "warn" repositories { grailsHome() mavenCentral() mavenRepo "http://localhost:8081/..." } ... } 17 Monday, 30 May 2011 17
  • 18. 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" } ... } 18 Monday, 30 May 2011 18
  • 19. Integration Points • Build • Dependencies • Database • Deployment • Spring 19 Monday, 30 May 2011 19
  • 20. ‘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 20 Monday, 30 May 2011 20
  • 21. Option 1: Custom ORM mapping class Book { ... static mapping = { table "books" title type: "books" author column: "author_ref" } } 21 Monday, 30 May 2011 21
  • 22. Option 2: JPA annotations <?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> 22 Monday, 30 May 2011 22
  • 23. Option 3: Hibernate XML Mappings <?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> 23 Monday, 30 May 2011 23
  • 24. Constraints Given domain class: org.example.myapp.domain.Book Then: src/java/org/example/myapp/domain/BookConstraints.groovy constraints = { title blank: false, unique: true ... } 24 Monday, 30 May 2011 24
  • 25. 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 25 Monday, 30 May 2011 25
  • 26. Share your model! 26 Monday, 30 May 2011 26
  • 27. Database Management • Hibernate auto-DDL – Good for dev & test – Bad for production! • Data migration – http://grails.org/plugin/database-migration • Reverse engineer a model – http://grails.org/plugin/db-reverse-engineer 27 Monday, 30 May 2011 27
  • 28. Integration Points • Build • Dependencies • Database • Deployment • Spring 28 Monday, 30 May 2011 28
  • 29. grails war • Build properties: – grails.war.copyToWebApp – grails.war.dependencies – grails.war.resources – grails.project.war.file 29 Monday, 30 May 2011 29
  • 30. 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 30 Monday, 30 May 2011 30
  • 31. Data Source JNDI: dataSource { jndiName = "java:comp/env/myDataSource" } System property: dataSource { url = System.getProperty("JDBC_STRING") } 31 Monday, 30 May 2011 31
  • 32. 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 32 Monday, 30 May 2011 32
  • 33. Integration Points • Build • Dependencies • Database • Deployment • Spring 33 Monday, 30 May 2011 33
  • 34. 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 34 Monday, 30 May 2011 34
  • 35. Example import ... beans = { credentialMatcher(Sha1CredentialsMatcher) { storedCredentialsHexEncoded = true } sessionFactory(ConfigurableLocalSessionFactoryBean) { dataSource = ref("dataSource") hibernateProperties = [ "hibernate.hbm2ddl.auto": "create-drop", "hibernate.show_sql": true ] } } 35 Monday, 30 May 2011 35
  • 36. Enterprise Integration • Spring opens up a world of possibilities – Spring Integration/Camel – Messaging (JMS/AMQP) – ESB – RMI, HttpInvoker, etc. • Web services & REST 36 Monday, 30 May 2011 36
  • 37. Grails Plugins • Routing • JMS, RabbitMQ • CXF, Spring-WS, WS-Client • REST 37 Monday, 30 May 2011 37
  • 38. 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 38 Monday, 30 May 2011 38
  • 39. Thank you! Q&A 39 Monday, 30 May 2011 39