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

Weitere ähnliche Inhalte

Ähnlich wie 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
 

Ähnlich wie 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)
 

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

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

Kürzlich hochgeladen

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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"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
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"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
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
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
 

Kürzlich hochgeladen (20)

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
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"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
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"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
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
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
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
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
 

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