• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
GR8Conf 2009. The Grails Plugin System by Graeme Rocher
 

GR8Conf 2009. The Grails Plugin System by Graeme Rocher

on

  • 5,688 views

Graeme Rocher, Grails project lead, presents the Grails plugin system.

Graeme Rocher, Grails project lead, presents the Grails plugin system.

Statistics

Views

Total Views
5,688
Views on SlideShare
5,644
Embed Views
44

Actions

Likes
4
Downloads
127
Comments
0

2 Embeds 44

http://www.slideshare.net 41
http://pallablahiri.posterous.com 3

Accessibility

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 2009. The Grails Plugin System by Graeme Rocher GR8Conf 2009. The Grails Plugin System by Graeme Rocher Presentation Transcript

    • Grails Plugins Modularizing your application with Plugins Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
    • Objectives • Understand the basics of the Grails plugin system • Explore how to create modular applications through plugins • Unlock the potential of Convention over Configuration Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 2
    • Agenda • Plugin basics • Creating, packaging and installing plugins • Building functional plugins • Automating configuration • Enhancing behavior Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 3
    • The Background • Grails is designed to wire together different libraries and make them easy to use • In this sense it can be seen as a "platform for runtime configuration" • De-coupling those components was hard without a well defined system Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 4
    • The Plugin Architecture Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 5
    • The Extension Points • Build System • Spring Application Context • Dynamic method registration • Auto Reloading • Container Config (web.xml) • Adding new Artefacts Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 6
    • What is a Plugin? • Just like a normal Grails project! • The only difference is the presence of a *GrailsPlugin.groovy file • Use grails create-plugin to create one! Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 7
    • Creating and Running a Plugin • A plugin is just a regular Grails project and can be developed like one: $ grails create-plugin blog $ cd ../blog $ grails run-app Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 8
    • A Plugin Project A Plugin project is the same as a regular Grails project except it has a special plugin Groovy Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 9
    • The Plugin Descriptor class LoggingGrailsPlugin { def version = 0.4 def dependsOn = [core:"1.0 > *"] ... Plug-in Dependencies The Plugin Version } Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 10
    • Packaging & Installation • Installation of Grails plugins can then be achieved with a few simple commands: $ grails package-plugin $ cd ../my-project $ grails install-plugin ../logging/grails-blog-0.4.zip // or remotely $ grails install-plugin http://myserver/ grails-blog-0.4.zip Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 11
    • Plugins & Application Modularity Messaging Security Search Plugin Plugin Plugin Grails Application Blog Wiki Maps Plugin Plugin Plugin Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 12
    • Adding Basic Artefacts • A Plugin can add new tag libraries, controllers and services simply by creating them in the plugin project • Since a plugin project is just like any project you can run and debug a plugin in its own project before distributing it • Once you're done package and distribute it! Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 13
    • Demo Building a Functional Plugin Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.
    • Automating Configuration import org.springframework.cache.ehcache.* import grails.util.* Implement ‘doWithSpring’ to modify Spring context def doWithSpring = { blogCache(EhCacheFactoryBean) { if(Environment.current == Environment.PRODUCTION) { timeToLive = 2400 } Sets the “timeToLive” of } the cache for Configures a Spring production only bean called “blogCache” Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 15
    • Automating Configuration • Plugins allow you to manipulate the underlying Spring context based on: – The Environment – The Conventions – The State of other Plugins • Simply implement the doWithSpring plugin hook • See the user guide for a description of the Spring Domain Specific Langauge (DSL) Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 16
    • Enhancing Behavior def doWithDynamicMethods = { ApplicationContext ctx -> application.domainClasses.each { domainClass -> domainClass.metaClass.constructor = {-> ctx.getBean("Bookmark") } Support auto-wiring from Spring in regular constructors! // adds a new Foo.load(21) method def template = new HibernateTemplate(ctx.getBean("sessionFactory")) domainClass.metaClass.static.load = {Long id-> template.load(delegate.getClass(), id) } } } Interact with the Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Hibernate session!17
    • Enhancing Behavior • Plugins can add new methods and APIs using metaprogramming techniques • Simply implement the doWithSpring plugin hook • See the metaprogramming guide on Groovy’s website: http://groovy.codehaus.org/ Dynamic+Groovy • Huge number of possibilities are opened up via plugins Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 18
    • What plugins enable... Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19
    • What plugins enable... • Test Grails: selenium, fitnesse, code coverage etc. Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19
    • What plugins enable... • Test Grails: selenium, fitnesse, code coverage etc. • Rich Grails: Flex, GWT, GrailsUI (YahooUI) etc. Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19
    • What plugins enable... • Test Grails: selenium, fitnesse, code coverage etc. • Rich Grails: Flex, GWT, GrailsUI (YahooUI) etc. • Secure Grails: Spring Security, JSecurity, OpenID etc. Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19
    • What plugins enable... • Test Grails: selenium, fitnesse, code coverage etc. • Rich Grails: Flex, GWT, GrailsUI (YahooUI) etc. • Secure Grails: Spring Security, JSecurity, OpenID etc. • Integrate Grails: Search, Jasper Reports, JMS etc, Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 19
    • The Plugin Portal • http://grails.org/ Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 20
    • Summary • Plugins are crucial the the Grails story • Everyone is a plugin developer, not just the gurus • Plugins help create modular applications • Plugin automate configuration through Convention over Configuration Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited. 21
    • Q&A Copyright 2008 SpringSource. Copying, publishing or distributing without express written permission is prohibited.