• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook
 

GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook

on

  • 2,083 views

 

Statistics

Views

Total Views
2,083
Views on SlideShare
2,075
Embed Views
8

Actions

Likes
1
Downloads
56
Comments
0

4 Embeds 8

http://www.gennemtaenkt.dk 5
http://www.slideshare.net 1
http://universegroovygrails.blogspot.com 1
http://www.eu2011.gr8conf.org 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook GR8Conf 2011: Grails Enterprise Integration by Peter Ledbrook Presentation Transcript

    • Grails in the Enterprise Peter LedbrookMonday, 30 May 2011 1
    • Integration Points • Build • Dependencies • Database • Deployment • Spring 2Monday, 30 May 2011 2
    • Integration Points • Build • Dependencies • Database • Deployment • Spring 3Monday, 30 May 2011 3
    • Build 4Monday, 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 5Monday, 30 May 2011 5
    • 6Monday, 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 7Monday, 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 8Monday, 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! 9Monday, 30 May 2011 9
    • 10Monday, 30 May 2011 10
    • Maven & Grails Plugins > grails release-plugin == > mvn deploy 11Monday, 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’ 12Monday, 30 May 2011 12
    • Maven & Grails Plugins Or: grails.project.dependency.resolution = { ... plugins { compile ":hibernate:1.3.6" } ... } 13Monday, 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 14Monday, 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 15Monday, 30 May 2011 15
    • Integration Points • Build • Dependencies • Database • Deployment • Spring 16Monday, 30 May 2011 16
    • Dependency DSL grails.project.dependency.resolution = { inherits "global" log "warn" repositories { grailsHome() mavenCentral() mavenRepo "http://localhost:8081/..." } ... } 17Monday, 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" } ... } 18Monday, 30 May 2011 18
    • Integration Points • Build • Dependencies • Database • Deployment • Spring 19Monday, 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 20Monday, 30 May 2011 20
    • Option 1: Custom ORM mapping class Book { ... static mapping = { table "books" title type: "books" author column: "author_ref" } } 21Monday, 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> 22Monday, 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> 23Monday, 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 ... } 24Monday, 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 25Monday, 30 May 2011 25
    • Share your model! 26Monday, 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 27Monday, 30 May 2011 27
    • Integration Points • Build • Dependencies • Database • Deployment • Spring 28Monday, 30 May 2011 28
    • grails war • Build properties: – grails.war.copyToWebApp – grails.war.dependencies – grails.war.resources – grails.project.war.file 29Monday, 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 30Monday, 30 May 2011 30
    • Data Source JNDI: dataSource { jndiName = "java:comp/env/myDataSource" } System property: dataSource { url = System.getProperty("JDBC_STRING") } 31Monday, 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 32Monday, 30 May 2011 32
    • Integration Points • Build • Dependencies • Database • Deployment • Spring 33Monday, 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 34Monday, 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 ] } } 35Monday, 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 36Monday, 30 May 2011 36
    • Grails Plugins • Routing • JMS, RabbitMQ • CXF, Spring-WS, WS-Client • REST 37Monday, 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 38Monday, 30 May 2011 38
    • Thank you! Q&A 39Monday, 30 May 2011 39