SlideShare a Scribd company logo
Modularizing Your
                    Grails Application
                   with Private Plugins
                                  Ken Liu
                                   IEEE
                            SpringOne 2GX 2012
                                17 Oct 2012

Wednesday, October 17, 12
About Me
                  • Web development with Java since
                            JDK 1.0.2 (applets, anyone?)

                  • Groovy/Grails since 2009
                  • Lead developer for IEEE Spectrum
                  • Always been a closet fan of dynamic
                            languages (starting with Perl)



Wednesday, October 17, 12
About IEEE
                  • Institute of Electrical and Electronics
                            Engineers
                  • Widely known for standards - 802.11
                  • World’s largest technology
                            professional association - 400,000
                            engineers in 160 countries
                  • Publishes nearly a third of the world’s
                            technical literature in EE/CS

Wednesday, October 17, 12
About IEEE Spectrum
               • Flagship publication of IEEE
               • General interest technology magazine
                      with focus on EE topics

               • 2012 National Magazine Award winner




Wednesday, October 17, 12
IEEE Spectrum website

                  • http://spectrum.ieee.org
                  • ~1.5M PV/mo
                  • Frequent referrals from HN, Reddit, /.
                  • 100% Groovy/Grails since 2009 -
                            both front-end and CMS
                  • Akamai/Weblogic/Oracle stack
                  • Award-winning coverage of ROBOTS!

Wednesday, October 17, 12
Agenda

                  • Grails plugins overview
                  • Grails plugin development basics
                  • Application architecture with private
                            plugins
                  • Lessons learned


Wednesday, October 17, 12
To fork or not to fork?

                  • “We need a new website...”
                  • “You must use the standard corporate
                            Enterprise CMS system.”

                  • “Can’t you guys just make a copy of
                            the existing code and tweak it?”

                  • DANGER!


Wednesday, October 17, 12
From “big ball of mud” to
                plugin architecture
                                  Where do we go from here?

                             Front End              Domain classes       CMS
                        Controllers/Views/           (e.g Article,    Controllers/
                              Services                BlogPost)      Views/Services
                     (e.g. article, blog pages)

                                                                     Utility classes
                            UrlMappings           Spectrum Taglib       (src/**)

                            Quartz Jobs           Front End & CMS
                            (e.g. sitemap                             Test classes
                                                   images, CSS, JS
                             generation)




Wednesday, October 17, 12
Agenda

                  • Grails plugins overview
                  • Grails plugin development basics
                  • Application architecture with private
                            plugins
                  • Lessons learned


Wednesday, October 17, 12
Plugin systems and
                             component models
                  • Plugin systems are now commonplace
                  • Firefox, Eclipse, Jenkins, JEdit
                  • Package managers, OSGi, Ruby on
                            Rails Engines

                  • Component-oriented software?
                  • Coarse-grained high-level reuse,
                            separation of concerns

Wednesday, October 17, 12
Grails plugins in a
                                   nutshell
                  • Tightly integrated into Grails system
                  • Can implement common functionality
                            in plugins that is overridden by
                            application

                  • Can create new Artifact types
                  • Interact with Spring context
                  • Integrated with build system

Wednesday, October 17, 12
Grails plugins in a
                                 nutshell


                  • Central public plugin repository
                  • Version management
                  • Dependency management



Wednesday, October 17, 12
Grails - plugins inside
        • Many parts of Grails
               itself are built as plugins
        • Some default plugins can
               even be swapped out
               • Tomcat -> Jetty
               • GORM/Hibernate ->
                      Redis GORM


Wednesday, October 17, 12
Public Grails plugins
                  • 850 public plugins in the central
                            plugins repository

                  • Search on plugin portal
                            http://grails.org/plugins/

                  • Quickly bootstrap new applications
                  • Spend some time now
                            save some time later
                  • Follow @grailsplugins for updates

Wednesday, October 17, 12
Selected Grails plugins
                    Spring Security - user authentication
                    Cache - caching using annotations
                    Quartz - job scheduling (like cron)
                    DB Migration - controlled schema changes
                    Mail - send email with JavaMail
                    Resources - web performance optimization
                    Console - in-app interactive console
                    CodeNarc - static code analysis
                    Spock - enable Spock unit testing framework


Wednesday, October 17, 12
What can go into a
                                  plugin?
                  • Really, anything
                  • Standard Grails artifacts: GSPs,
                            Controllers, Services, i18n, TagLibs -
                            just like in app

                  • Define custom Grails artifact types:
                            see Quartz plugin “Jobs”

                  • Plugins can depend on other plugins

Wednesday, October 17, 12
Agenda

                  • Grails plugins overview
                  • Grails plugin development basics
                  • Application architecture with private
                            plugins
                  • Lessons learned


Wednesday, October 17, 12
Creating a new plugin



                    grails create-plugin myplugin




Wednesday, October 17, 12
Creating a new plugin

                   Same structure
                   as a Grails
                   application, but
                   with an extra
                   plugin
                   descriptor file



Wednesday, October 17, 12
Plugin Descriptor
             class MypluginGrailsPlugin {
               // the plugin version
               def version = "0.1"

                 // the version or versions of Grails the plugin is designed for
                 def grailsVersion = "2.1 > *"

                 // the other plugins this plugin depends on
                 def dependsOn = [:]

                 def doWithDynamicMethods = { ctx ->
                   // TODO Implement registering dynamic methods to classes (optional)
                 }

                 def doWithApplicationContext = { applicationContext ->
                   // TODO Implement post initialization spring config (optional)
                 }


Wednesday, October 17, 12
Excluded plugin files
                                     /grails-app/conf/BootStrap.groovy
                                     /grails-app/conf/BuildConfig.groovy
                                     /grails-app/conf/Config.groovy
             Grails excludes         /grails-app/conf/DataSource.groovy
             certain files            (and any other *DataSource.groovy)
                                     /grails-app/conf/UrlMappings.groovy
             from packaging          /grails-app/conf/spring/resources.groovy
                                     /web-app/WEB-INF/**
                                     /web-app/plugins/**
                                     /test/**




Wednesday, October 17, 12
Running a plugin
                  • A plugin is a Grails app!
                  • grails run-app from plugin dir
                  • excluded files loaded during run-app
                  • useful for testing
                            (test-app works too)




Wednesday, October 17, 12
Packaging a plugin


                  • grails package-plugin
                  • creates a zip file that can be installed
                            & distributed




Wednesday, October 17, 12
Installing a plugin

        from local directory:
        grails install-plugin /path/to/grails-example-0.1.zip


        from URL:
        grails install-plugin http://myserver.com/plugins/grails-
        example-0.1.zip


        in BuildConfig.groovy (“in-place” plugin):
        // Uncomment this only for local development - do not check in!
        grails.plugin.location.'spectrum-core' = '../spectrum-core'




Wednesday, October 17, 12
Plugin Development

                  • Easy: create Controllers, Services,
                            Views, Taglibs, etc.

                  • Specify resource paths <g:resource>
                  • Can alter Spring context
                  • Hook into build system, reload events


Wednesday, October 17, 12
Agenda

                  • Grails plugins overview
                  • Grails plugin development basics
                  • Application architecture with private
                            plugins
                  • Lessons learned


Wednesday, October 17, 12
Public vs. Private plugins
                              Public plugins
             • Highly cohesive
             • Maximize reuse
             • Sometimes provide “horizontal slices” -
                    e.g. Spring security core
             • Most don’t depend on other plugins


Wednesday, October 17, 12
Public vs. Private plugins
                              Private Plugins
              • Proprietary code
              • Application or domain-specific
              • Code reuse within an organization
              • Can be coarse-grained, heavyweight
              • Private forks of public plugins
              • Enable interesting options for
                      application architecture

Wednesday, October 17, 12
From “big ball of mud” to
                plugin architecture
                  • Grails applications tend to become
                            unmanageable over time
                  • Convention-based directory trees
                            (e.g. /grails-app/views )

                  • Rapid development/scaffolding
                  • Need “separation of concerns”


Wednesday, October 17, 12
From “big ball of mud” to
                plugin architecture
                    Spectrum application before refactoring

                             Front End              Domain classes       CMS
                        Controllers/Views/           (e.g Article,    Controllers/
                              Services                BlogPost)      Views/Services
                     (e.g. article, blog pages)

                                                                     Utility classes
                            UrlMappings           Spectrum Taglib       (src/**)

                            Quartz Jobs           Front End & CMS
                            (e.g. sitemap                             Test classes
                                                   images, CSS, JS
                             generation)




Wednesday, October 17, 12
Reusable domain model
                                                         DB
        • Reuse a set of
               Domain classes
               between applications
        • Different applications,
               same DB instance
                                        Domain Model                  Domain Model

        • Hibernate not
                                           plugin                        plugin

               included in plugins by   API endpoint                  Primary web
                                         application                   application
               default
        • Consider Hibernate                           Domain Model
                                                          plugin
               caching issues
                                                       Reporting
                                                       application


Wednesday, October 17, 12
Refactored with plugin
              Spectrum Application                 Spectrum Core Plugin


                    Front End             Core Domain             Utility classes
                 Controllers/Views          classes                  (src/**)


                       Front End                                     CMS
                                         Common Front
                      UrlMappings                                 Controllers/
                                         End Controllers
                                                                 Views/Services

                  Front End Taglib
                                          Core Services         CMS test classes

                       Test classes      CoreUrlMappings           CMS Taglib

                     Front End                 CMS
                                                                   Quartz Jobs
                   images, CSS, JS        images, CSS, JS

                                      Depends on other plugins: spring-security-core,
                                         quartz, searchable, ckeditor, and others

Wednesday, October 17, 12
Different web sites,
                     common backend code
                                   spectrum-core
                                       Plugin



                            Spectrum         The Institute
                             website           website
                              10.4+               3.0




Wednesday, October 17, 12
Same Controller,
                               different Views
                            FrontendArticleController#show()

                        Spectrum application      The Institute application
                             show.gsp                    show.gsp




Wednesday, October 17, 12
Same Controller,
                                different Views
                  • Define common Controller in plugin
                  • View resolution: application first, then
                            plugin
                  • Can specify plugin using
                            <g:render plugin=”myplugin”>

                  • The promise of MVC fulfilled!


Wednesday, October 17, 12
Plugin UrlMappings
                  • UrlMappings.groovy excluded from plugin
                            build

                  • *UrlMappings.groovy merged into
                            application mappings

                  • Application can override plugin mappings
                  • Enables “mini application” in plugin
                  • Can’t remove unwanted mappings, only
                            override


Wednesday, October 17, 12
Config.groovy
                  • Config.groovy is excluded from plugin
                  • Might want to fix certain config
                            properties - won’t need them in
                            application Config
                  • Manually merge config in
                            doWithSpring
                  •         application.config.merge(new
                            ConfigSlurper().parse(application.classLoader.loadClass('MyPluginConfig
                            ')))




Wednesday, October 17, 12
Extending plugin
                                 domain model
                               Content class
                            Domain model plugin   Domain classes in
                                                   plugins can be
                                                    extended in
                                                    application
                     Webinar extends Content
                           Application




Wednesday, October 17, 12
Publishing private plugins
                  • Publish to internal corporate Maven
                            repo - e.g. Artifactory or Nexus
                  • Release plugin - installed by default
                  • Old-style svn-based repos supported,
                            but not recommended for Grails 2
                  • Customize plugin metadata with
                            internal Maven groupId
                  • Publish from Jenkins

Wednesday, October 17, 12
Declaring private plugin
                     dependencies
                                 BuildConfig.groovy
                               (Maven/Ivy dependencies)
         repositories {
             grailsPlugins()
             /* other default repos here */
                 /* point to internal corporate Maven repo */
                 mavenRepo 'http://mvn.ieee.org/nexus/content/repositories/spectrum/'
         }
         plugins {
             /* other plugin dependencies here */
             compile 'org.ieee.spectrum.plugins:spectrum-core:2.0-SNAPSHOT'
         }




Wednesday, October 17, 12
Day-to-day development
                  • Use “in-place” plugin (exploded plugin) in
                            your local dev workspace
                            (BuildConfig.groovy)

                  • Private plugins tend to be updated along
                            with application features

                  • Beware of potential breaking changes
                            (in other applications)

                  • Define deprecation strategy and use
                            @deprecated javadoc


Wednesday, October 17, 12
Refactoring to plugin

                  • Determine candidates for refactoring
                  • Create new empty plugin & plugin descriptor
                  • Move Grails artifacts (e.g. Controllers,
                            Services, Views, etc.) into new plugin
                  •         Move dependent files from /src
                  •         Move related test files into new plugin
                  •         Remove hard coded paths to resources
                  •         Run your functional test suite


Wednesday, October 17, 12
Refactoring to plugin


                  • Start small - don’t create a whole
                            bunch of plugins from the outset

                  • Consider migrating version history




Wednesday, October 17, 12
Super-project with plugins
            One application with several in-place plugins
                            /myapplication
                               /grails-app
                               ...
                               /pluginA
                                   /grails-app
                               /pluginB
                               /pluginC

             In BuildConfig.groovy:
               grails.plugin.location.pluginA = 'pluginA' // path to plugin
               grails.plugin.location.pluginB = 'pluginB'
               grails.plugin.location.pluginC = 'pluginC'


Wednesday, October 17, 12
Public website,
                                  private back end
                        Public                  Private
                       Internet                intranet
                                                              Deploy public
                                                   Core
                               Core
                            application
                                                application
                                                  plugin
                                                              and private
                              plugin
                                                Business-
                                                              versions of
                       Public-facing
                        application              facing       application with
                                               application
                                                              shared code


                                          DB


Wednesday, October 17, 12
Vertical slices / mini
                             Grails applications
                  • Plugins can be self contained
                  • UrlMappings + Controllers + Domains +
                            Views + Services = Grails application

                  • Remove views -> “white label” application
                  • Embed a small application within another
                            application

                  • Vertically slice your application into plugins


Wednesday, October 17, 12
Plugins as a platform
                   Data Capture       Data Cleaning      Data Validation
                      plugin             plugin              plugin



                                                                   Super-plugin to
                                                                   combine plugin
                                  Clinical Data Management        dependencies into
                                        Platform plugin             a platform or
                                                                   domain-specific
                                                                     framework

                         Clinical data
                                                Clinical data review
                      management server
                                                     application
                         application



Wednesday, October 17, 12
Sensitive code protection
                                  DB
                                                          Split application
                                                          into separate
               Data Ingestion          Data Analysis      parts to isolate
                                           plugin
                  plugin
                                       “secret sauce”     key algorithms
                                                          from external
                                                          vendor

              Shell application        Full application
              (external team)




Wednesday, October 17, 12
Agenda

                  • Grails plugins overview
                  • Grails plugin development basics
                  • Application architecture with private
                            plugins
                  • Lessons learned


Wednesday, October 17, 12
Domain/Schema
                                management
                  • Changes to domain model need to be
                            carefully managed
                  • Avoid dbCreate=update
                  • Adopt DDL file naming convention:
                            spectrum-core-2.1.sql
                            spectrum-core-2.2.sql

                  • Bootstrap-triggered migrations
                  • DB Migrations plugin (Liquibase)

Wednesday, October 17, 12
Config.groovy changes
                          over time
                  • Easy to add a new entry to
                            Config.groovy and then forget about it

                  • Group together plugin config
                            properties into a closure

                  • Don’t forget about external config files
                            and differences in various
                            environments


Wednesday, October 17, 12
Maven/Ivy/build issues

                  • Maven/Ivy hell > JAR hell
                  • SNAPSHOT resolution error-prone
                  • See JIRA for bugs related to plugins
                  • Avoid creating many small plugins
                  • Strange problems? Look at your build.


Wednesday, October 17, 12
Plugin versioning and
                             branching

                  • Define version numbering strategy
                  • Be prepared to branch/merge
                  • Be sure to update plugin versions and
                            tag your code consistently
                  • Just use Git - merging & cherry-
                            picking are sweet



Wednesday, October 17, 12
Code Rigidity

                  • Inflexibility to change/afferent
                            coupling
                  • Avoid breaking changes (duh)
                  • Solution: automate your tests, catch
                            breaking changes early



Wednesday, October 17, 12
Continuous Integration

                  • Use Jenkins to trigger builds of
                            applications that depend on your
                            private plugin

                  • Run Plugin test suite with plugin build
                  • Publish snapshots to Maven repo from
                            Jenkins



Wednesday, October 17, 12
Plugin namespace
                                   conflicts

                  • Plugin artifacts all share same
                            namespace with each other
                  • Potential for class name collisions,
                            especially with “conventions”
                  • Planned enhancement for Grails 2.2


Wednesday, October 17, 12
Plugin resources

                  • Plugin static resources (images, CSS, JS,
                            etc.) packaged in a path corresponding to
                            plugin name & version - /plugins/
                            myplugin-1.0/*
                  • path changes between dev mode and WAR -
                            <g:resource> handles correctly
                  • May need to redeploy with each plugin
                            version bump
                  • Don’t accidentally share sensitive files!


Wednesday, October 17, 12
Component interfaces


                  • Grails plugins don’t have any kind of
                            external “interface” or contract
                            besides Plugin Metadata

                  • Up to you to make the rules
                            (not a bad thing)




Wednesday, October 17, 12
Success!
               Release strategy for 2013 website redesign

                                     spectrum-core Plugin
                                         2.0, 2.1, 2.2



                                          The Institute
                            Spectrum                      Spectrum
                                            website
                             website                       website
                                               3.x
                            10.8, 10.9,                   4.0 - 2013
                              10.10                        release


Wednesday, October 17, 12
Takeaway

                  • Plugins are easy to create and use
                  • Private plugins are a safe, robust way
                            to modularize Grails applications
                  • Private plugins enable coarse-grained
                            reuse of application components
                  • Configuration management and OO
                            principles are important (as always)


Wednesday, October 17, 12
Additional resources

                  • @grailsplugins - Grails plugin updates - https://twitter.com/
                            grailsplugins

                  • Grails reference docs chapter on plugins - http://grails.org/doc/
                            latest/guide/plugins.html

                  • Inside Grails: The Build System and Plugin Management - http://
                            www.slideshare.net/skillsmatter/grails-internals-ggug-dec-2009

                  • GGUG: Grails Plugins - Lessons to Learn http://skillsmatter.com/
                            podcast/java-jee/grails-plugins




Wednesday, October 17, 12
Questions?




Wednesday, October 17, 12
Thanks!


                    feedback is appreciated.
                    @kenliu
                    k.a.liu@ieee.org




Wednesday, October 17, 12

More Related Content

What's hot

GR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug in
GR8Conf
 
Developing Mobile HTML5 Apps with Grails
Developing Mobile HTML5 Apps with GrailsDeveloping Mobile HTML5 Apps with Grails
Developing Mobile HTML5 Apps with Grails
GR8Conf
 
A Tour of the Modern Java Platform
A Tour of the Modern Java PlatformA Tour of the Modern Java Platform
A Tour of the Modern Java Platform
VMware Tanzu
 
Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)
Ryan Cuprak
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
GR8Conf
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
Joe Kutner
 
Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013
Matt Raible
 
A year in the life of a Grails startup
A year in the life of a Grails startupA year in the life of a Grails startup
A year in the life of a Grails startup
tomaslin
 
Operator SDK for K8s using Go
Operator SDK for K8s using GoOperator SDK for K8s using Go
Operator SDK for K8s using Go
CloudOps2005
 
Reactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring BootReactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring Boot
VMware Tanzu
 
Migrating from Grails 2 to Grails 3
Migrating from Grails 2 to Grails 3Migrating from Grails 2 to Grails 3
Migrating from Grails 2 to Grails 3
Michael Plöd
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web Framework
Daniel Woods
 
Dropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stackDropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stack
Jacek Furmankiewicz
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
Antoine Sabot-Durand
 
Spring Boot on Amazon Web Services with Spring Cloud AWS
Spring Boot on Amazon Web Services with Spring Cloud AWSSpring Boot on Amazon Web Services with Spring Cloud AWS
Spring Boot on Amazon Web Services with Spring Cloud AWS
VMware Tanzu
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
Bhagwat Kumar
 
High Performance Microservices with Ratpack and Spring Boot
High Performance Microservices with Ratpack and Spring BootHigh Performance Microservices with Ratpack and Spring Boot
High Performance Microservices with Ratpack and Spring Boot
Daniel Woods
 
Apache Lucene for Java EE Developers
Apache Lucene for Java EE DevelopersApache Lucene for Java EE Developers
Apache Lucene for Java EE Developers
Virtual JBoss User Group
 
An intro to Kubernetes operators
An intro to Kubernetes operatorsAn intro to Kubernetes operators
An intro to Kubernetes operators
J On The Beach
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and Friends
Yun Zhi Lin
 

What's hot (20)

GR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug in
 
Developing Mobile HTML5 Apps with Grails
Developing Mobile HTML5 Apps with GrailsDeveloping Mobile HTML5 Apps with Grails
Developing Mobile HTML5 Apps with Grails
 
A Tour of the Modern Java Platform
A Tour of the Modern Java PlatformA Tour of the Modern Java Platform
A Tour of the Modern Java Platform
 
Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)Why jakarta ee matters (ConFoo 2021)
Why jakarta ee matters (ConFoo 2021)
 
GR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting GrailsGR8Conf 2011: Adopting Grails
GR8Conf 2011: Adopting Grails
 
4 JVM Web Frameworks
4 JVM Web Frameworks4 JVM Web Frameworks
4 JVM Web Frameworks
 
Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013Play vs Grails Smackdown - Devoxx France 2013
Play vs Grails Smackdown - Devoxx France 2013
 
A year in the life of a Grails startup
A year in the life of a Grails startupA year in the life of a Grails startup
A year in the life of a Grails startup
 
Operator SDK for K8s using Go
Operator SDK for K8s using GoOperator SDK for K8s using Go
Operator SDK for K8s using Go
 
Reactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring BootReactive Applications with Apache Pulsar and Spring Boot
Reactive Applications with Apache Pulsar and Spring Boot
 
Migrating from Grails 2 to Grails 3
Migrating from Grails 2 to Grails 3Migrating from Grails 2 to Grails 3
Migrating from Grails 2 to Grails 3
 
Ratpack Web Framework
Ratpack Web FrameworkRatpack Web Framework
Ratpack Web Framework
 
Dropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stackDropwizard Spring - the perfect Java REST server stack
Dropwizard Spring - the perfect Java REST server stack
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
 
Spring Boot on Amazon Web Services with Spring Cloud AWS
Spring Boot on Amazon Web Services with Spring Cloud AWSSpring Boot on Amazon Web Services with Spring Cloud AWS
Spring Boot on Amazon Web Services with Spring Cloud AWS
 
Gradle - Build system evolved
Gradle - Build system evolvedGradle - Build system evolved
Gradle - Build system evolved
 
High Performance Microservices with Ratpack and Spring Boot
High Performance Microservices with Ratpack and Spring BootHigh Performance Microservices with Ratpack and Spring Boot
High Performance Microservices with Ratpack and Spring Boot
 
Apache Lucene for Java EE Developers
Apache Lucene for Java EE DevelopersApache Lucene for Java EE Developers
Apache Lucene for Java EE Developers
 
An intro to Kubernetes operators
An intro to Kubernetes operatorsAn intro to Kubernetes operators
An intro to Kubernetes operators
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and Friends
 

Similar to Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012

Cloud foundry and openstackcloud
Cloud foundry and openstackcloudCloud foundry and openstackcloud
Cloud foundry and openstackcloud
Francisco Gonçalves
 
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Patrick Chanezon
 
Cloud4all Architecture Overview
Cloud4all Architecture OverviewCloud4all Architecture Overview
Cloud4all Architecture Overview
icchp2012
 
Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gates
Strannik_2013
 
Building businesspost.ie using Node.js
Building businesspost.ie using Node.jsBuilding businesspost.ie using Node.js
Building businesspost.ie using Node.js
Richard Rodger
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
Roberto Pérez Alcolea
 
Platform Engineering for the Modern Oracle World
Platform Engineering for the Modern Oracle WorldPlatform Engineering for the Modern Oracle World
Platform Engineering for the Modern Oracle World
Simon Haslam
 
Adopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf EuropeAdopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf Europe
KlausBaumecker
 
CloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heavenCloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heaven
Patrick Chanezon
 
Use Cases of #Grails in #WebApplications
Use Cases of #Grails in #WebApplicationsUse Cases of #Grails in #WebApplications
Use Cases of #Grails in #WebApplications
Xebia IT Architects
 
Enhancing Spring MVC Web Applications Progressively with Spring JavaScript
Enhancing Spring MVC Web Applications Progressively with Spring JavaScriptEnhancing Spring MVC Web Applications Progressively with Spring JavaScript
Enhancing Spring MVC Web Applications Progressively with Spring JavaScript
Jeremy Grelle
 
Starting from scratch in 2017
Starting from scratch in 2017Starting from scratch in 2017
Starting from scratch in 2017
Stefano Bonetta
 
Scala at Treasure Data
Scala at Treasure DataScala at Treasure Data
Scala at Treasure Data
Taro L. Saito
 
From Renamer Plugin to Polyglot IDE
From Renamer Plugin to Polyglot IDEFrom Renamer Plugin to Polyglot IDE
From Renamer Plugin to Polyglot IDE
intelliyole
 
Shipping NodeJS with Docker and CoreOS
Shipping NodeJS with Docker and CoreOSShipping NodeJS with Docker and CoreOS
Shipping NodeJS with Docker and CoreOS
Ross Kukulinski
 
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Codemotion
 
Microcontainers and Tools for Hardcore Container Debugging
Microcontainers and Tools for Hardcore Container DebuggingMicrocontainers and Tools for Hardcore Container Debugging
Microcontainers and Tools for Hardcore Container Debugging
Oracle Developers
 
Naked Objects and Groovy Grails
Naked Objects and Groovy GrailsNaked Objects and Groovy Grails
Naked Objects and Groovy Grails
David Parsons
 
Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013
Gavin Hogan
 
ICONUK 2015 - Gradle Up!
ICONUK 2015 - Gradle Up!ICONUK 2015 - Gradle Up!
ICONUK 2015 - Gradle Up!
René Winkelmeyer
 

Similar to Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012 (20)

Cloud foundry and openstackcloud
Cloud foundry and openstackcloudCloud foundry and openstackcloud
Cloud foundry and openstackcloud
 
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
 
Cloud4all Architecture Overview
Cloud4all Architecture OverviewCloud4all Architecture Overview
Cloud4all Architecture Overview
 
Gradle.Enemy at the gates
Gradle.Enemy at the gatesGradle.Enemy at the gates
Gradle.Enemy at the gates
 
Building businesspost.ie using Node.js
Building businesspost.ie using Node.jsBuilding businesspost.ie using Node.js
Building businesspost.ie using Node.js
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Platform Engineering for the Modern Oracle World
Platform Engineering for the Modern Oracle WorldPlatform Engineering for the Modern Oracle World
Platform Engineering for the Modern Oracle World
 
Adopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf EuropeAdopting Grails - GR8Conf Europe
Adopting Grails - GR8Conf Europe
 
CloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heavenCloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heaven
 
Use Cases of #Grails in #WebApplications
Use Cases of #Grails in #WebApplicationsUse Cases of #Grails in #WebApplications
Use Cases of #Grails in #WebApplications
 
Enhancing Spring MVC Web Applications Progressively with Spring JavaScript
Enhancing Spring MVC Web Applications Progressively with Spring JavaScriptEnhancing Spring MVC Web Applications Progressively with Spring JavaScript
Enhancing Spring MVC Web Applications Progressively with Spring JavaScript
 
Starting from scratch in 2017
Starting from scratch in 2017Starting from scratch in 2017
Starting from scratch in 2017
 
Scala at Treasure Data
Scala at Treasure DataScala at Treasure Data
Scala at Treasure Data
 
From Renamer Plugin to Polyglot IDE
From Renamer Plugin to Polyglot IDEFrom Renamer Plugin to Polyglot IDE
From Renamer Plugin to Polyglot IDE
 
Shipping NodeJS with Docker and CoreOS
Shipping NodeJS with Docker and CoreOSShipping NodeJS with Docker and CoreOS
Shipping NodeJS with Docker and CoreOS
 
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
Mobile Library Development - stuck between a pod and a jar file - Zan Markan ...
 
Microcontainers and Tools for Hardcore Container Debugging
Microcontainers and Tools for Hardcore Container DebuggingMicrocontainers and Tools for Hardcore Container Debugging
Microcontainers and Tools for Hardcore Container Debugging
 
Naked Objects and Groovy Grails
Naked Objects and Groovy GrailsNaked Objects and Groovy Grails
Naked Objects and Groovy Grails
 
Introduction to Grails 2013
Introduction to Grails 2013Introduction to Grails 2013
Introduction to Grails 2013
 
ICONUK 2015 - Gradle Up!
ICONUK 2015 - Gradle Up!ICONUK 2015 - Gradle Up!
ICONUK 2015 - Gradle Up!
 

Recently uploaded

Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
BookNet Canada
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
Stephanie Beckett
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
ArgaBisma
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
Awais Yaseen
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
Enterprise Wired
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
Kief Morris
 
What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024
Stephanie Beckett
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
KAMAL CHOUDHARY
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
Lidia A.
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
ScyllaDB
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
Mark Billinghurst
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Bert Blevins
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
Toru Tamaki
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
Eric D. Schabell
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Chris Swan
 
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALLBLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
Liveplex
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
UiPathCommunity
 

Recently uploaded (20)

Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...Transcript: Details of description part II: Describing images in practice - T...
Transcript: Details of description part II: Describing images in practice - T...
 
What's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptxWhat's New in Copilot for Microsoft365 May 2024.pptx
What's New in Copilot for Microsoft365 May 2024.pptx
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdfWhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
WhatsApp Image 2024-03-27 at 08.19.52_bfd93109.pdf
 
Best Programming Language for Civil Engineers
Best Programming Language for Civil EngineersBest Programming Language for Civil Engineers
Best Programming Language for Civil Engineers
 
7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf7 Most Powerful Solar Storms in the History of Earth.pdf
7 Most Powerful Solar Storms in the History of Earth.pdf
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
 
What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024What’s New in Teams Calling, Meetings and Devices May 2024
What’s New in Teams Calling, Meetings and Devices May 2024
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 
Recent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS InfrastructureRecent Advancements in the NIST-JARVIS Infrastructure
Recent Advancements in the NIST-JARVIS Infrastructure
 
WPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide DeckWPRiders Company Presentation Slide Deck
WPRiders Company Presentation Slide Deck
 
Mitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing SystemsMitigating the Impact of State Management in Cloud Stream Processing Systems
Mitigating the Impact of State Management in Cloud Stream Processing Systems
 
Research Directions for Cross Reality Interfaces
Research Directions for Cross Reality InterfacesResearch Directions for Cross Reality Interfaces
Research Directions for Cross Reality Interfaces
 
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
Understanding Insider Security Threats: Types, Examples, Effects, and Mitigat...
 
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
論文紹介:A Systematic Survey of Prompt Engineering on Vision-Language Foundation ...
 
Observability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetryObservability For You and Me with OpenTelemetry
Observability For You and Me with OpenTelemetry
 
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
Fluttercon 2024: Showing that you care about security - OpenSSF Scorecards fo...
 
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALLBLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
BLOCKCHAIN FOR DUMMIES: GUIDEBOOK FOR ALL
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
UiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs ConferenceUiPath Community Day Kraków: Devs4Devs Conference
UiPath Community Day Kraków: Devs4Devs Conference
 

Modularizing your Grails Application with Private Plugins - SpringOne 2GX 2012

  • 1. Modularizing Your Grails Application with Private Plugins Ken Liu IEEE SpringOne 2GX 2012 17 Oct 2012 Wednesday, October 17, 12
  • 2. About Me • Web development with Java since JDK 1.0.2 (applets, anyone?) • Groovy/Grails since 2009 • Lead developer for IEEE Spectrum • Always been a closet fan of dynamic languages (starting with Perl) Wednesday, October 17, 12
  • 3. About IEEE • Institute of Electrical and Electronics Engineers • Widely known for standards - 802.11 • World’s largest technology professional association - 400,000 engineers in 160 countries • Publishes nearly a third of the world’s technical literature in EE/CS Wednesday, October 17, 12
  • 4. About IEEE Spectrum • Flagship publication of IEEE • General interest technology magazine with focus on EE topics • 2012 National Magazine Award winner Wednesday, October 17, 12
  • 5. IEEE Spectrum website • http://spectrum.ieee.org • ~1.5M PV/mo • Frequent referrals from HN, Reddit, /. • 100% Groovy/Grails since 2009 - both front-end and CMS • Akamai/Weblogic/Oracle stack • Award-winning coverage of ROBOTS! Wednesday, October 17, 12
  • 6. Agenda • Grails plugins overview • Grails plugin development basics • Application architecture with private plugins • Lessons learned Wednesday, October 17, 12
  • 7. To fork or not to fork? • “We need a new website...” • “You must use the standard corporate Enterprise CMS system.” • “Can’t you guys just make a copy of the existing code and tweak it?” • DANGER! Wednesday, October 17, 12
  • 8. From “big ball of mud” to plugin architecture Where do we go from here? Front End Domain classes CMS Controllers/Views/ (e.g Article, Controllers/ Services BlogPost) Views/Services (e.g. article, blog pages) Utility classes UrlMappings Spectrum Taglib (src/**) Quartz Jobs Front End & CMS (e.g. sitemap Test classes images, CSS, JS generation) Wednesday, October 17, 12
  • 9. Agenda • Grails plugins overview • Grails plugin development basics • Application architecture with private plugins • Lessons learned Wednesday, October 17, 12
  • 10. Plugin systems and component models • Plugin systems are now commonplace • Firefox, Eclipse, Jenkins, JEdit • Package managers, OSGi, Ruby on Rails Engines • Component-oriented software? • Coarse-grained high-level reuse, separation of concerns Wednesday, October 17, 12
  • 11. Grails plugins in a nutshell • Tightly integrated into Grails system • Can implement common functionality in plugins that is overridden by application • Can create new Artifact types • Interact with Spring context • Integrated with build system Wednesday, October 17, 12
  • 12. Grails plugins in a nutshell • Central public plugin repository • Version management • Dependency management Wednesday, October 17, 12
  • 13. Grails - plugins inside • Many parts of Grails itself are built as plugins • Some default plugins can even be swapped out • Tomcat -> Jetty • GORM/Hibernate -> Redis GORM Wednesday, October 17, 12
  • 14. Public Grails plugins • 850 public plugins in the central plugins repository • Search on plugin portal http://grails.org/plugins/ • Quickly bootstrap new applications • Spend some time now save some time later • Follow @grailsplugins for updates Wednesday, October 17, 12
  • 15. Selected Grails plugins Spring Security - user authentication Cache - caching using annotations Quartz - job scheduling (like cron) DB Migration - controlled schema changes Mail - send email with JavaMail Resources - web performance optimization Console - in-app interactive console CodeNarc - static code analysis Spock - enable Spock unit testing framework Wednesday, October 17, 12
  • 16. What can go into a plugin? • Really, anything • Standard Grails artifacts: GSPs, Controllers, Services, i18n, TagLibs - just like in app • Define custom Grails artifact types: see Quartz plugin “Jobs” • Plugins can depend on other plugins Wednesday, October 17, 12
  • 17. Agenda • Grails plugins overview • Grails plugin development basics • Application architecture with private plugins • Lessons learned Wednesday, October 17, 12
  • 18. Creating a new plugin grails create-plugin myplugin Wednesday, October 17, 12
  • 19. Creating a new plugin Same structure as a Grails application, but with an extra plugin descriptor file Wednesday, October 17, 12
  • 20. Plugin Descriptor class MypluginGrailsPlugin { // the plugin version def version = "0.1" // the version or versions of Grails the plugin is designed for def grailsVersion = "2.1 > *" // the other plugins this plugin depends on def dependsOn = [:] def doWithDynamicMethods = { ctx -> // TODO Implement registering dynamic methods to classes (optional) } def doWithApplicationContext = { applicationContext -> // TODO Implement post initialization spring config (optional) } Wednesday, October 17, 12
  • 21. Excluded plugin files /grails-app/conf/BootStrap.groovy /grails-app/conf/BuildConfig.groovy /grails-app/conf/Config.groovy Grails excludes /grails-app/conf/DataSource.groovy certain files (and any other *DataSource.groovy) /grails-app/conf/UrlMappings.groovy from packaging /grails-app/conf/spring/resources.groovy /web-app/WEB-INF/** /web-app/plugins/** /test/** Wednesday, October 17, 12
  • 22. Running a plugin • A plugin is a Grails app! • grails run-app from plugin dir • excluded files loaded during run-app • useful for testing (test-app works too) Wednesday, October 17, 12
  • 23. Packaging a plugin • grails package-plugin • creates a zip file that can be installed & distributed Wednesday, October 17, 12
  • 24. Installing a plugin from local directory: grails install-plugin /path/to/grails-example-0.1.zip from URL: grails install-plugin http://myserver.com/plugins/grails- example-0.1.zip in BuildConfig.groovy (“in-place” plugin): // Uncomment this only for local development - do not check in! grails.plugin.location.'spectrum-core' = '../spectrum-core' Wednesday, October 17, 12
  • 25. Plugin Development • Easy: create Controllers, Services, Views, Taglibs, etc. • Specify resource paths <g:resource> • Can alter Spring context • Hook into build system, reload events Wednesday, October 17, 12
  • 26. Agenda • Grails plugins overview • Grails plugin development basics • Application architecture with private plugins • Lessons learned Wednesday, October 17, 12
  • 27. Public vs. Private plugins Public plugins • Highly cohesive • Maximize reuse • Sometimes provide “horizontal slices” - e.g. Spring security core • Most don’t depend on other plugins Wednesday, October 17, 12
  • 28. Public vs. Private plugins Private Plugins • Proprietary code • Application or domain-specific • Code reuse within an organization • Can be coarse-grained, heavyweight • Private forks of public plugins • Enable interesting options for application architecture Wednesday, October 17, 12
  • 29. From “big ball of mud” to plugin architecture • Grails applications tend to become unmanageable over time • Convention-based directory trees (e.g. /grails-app/views ) • Rapid development/scaffolding • Need “separation of concerns” Wednesday, October 17, 12
  • 30. From “big ball of mud” to plugin architecture Spectrum application before refactoring Front End Domain classes CMS Controllers/Views/ (e.g Article, Controllers/ Services BlogPost) Views/Services (e.g. article, blog pages) Utility classes UrlMappings Spectrum Taglib (src/**) Quartz Jobs Front End & CMS (e.g. sitemap Test classes images, CSS, JS generation) Wednesday, October 17, 12
  • 31. Reusable domain model DB • Reuse a set of Domain classes between applications • Different applications, same DB instance Domain Model Domain Model • Hibernate not plugin plugin included in plugins by API endpoint Primary web application application default • Consider Hibernate Domain Model plugin caching issues Reporting application Wednesday, October 17, 12
  • 32. Refactored with plugin Spectrum Application Spectrum Core Plugin Front End Core Domain Utility classes Controllers/Views classes (src/**) Front End CMS Common Front UrlMappings Controllers/ End Controllers Views/Services Front End Taglib Core Services CMS test classes Test classes CoreUrlMappings CMS Taglib Front End CMS Quartz Jobs images, CSS, JS images, CSS, JS Depends on other plugins: spring-security-core, quartz, searchable, ckeditor, and others Wednesday, October 17, 12
  • 33. Different web sites, common backend code spectrum-core Plugin Spectrum The Institute website website 10.4+ 3.0 Wednesday, October 17, 12
  • 34. Same Controller, different Views FrontendArticleController#show() Spectrum application The Institute application show.gsp show.gsp Wednesday, October 17, 12
  • 35. Same Controller, different Views • Define common Controller in plugin • View resolution: application first, then plugin • Can specify plugin using <g:render plugin=”myplugin”> • The promise of MVC fulfilled! Wednesday, October 17, 12
  • 36. Plugin UrlMappings • UrlMappings.groovy excluded from plugin build • *UrlMappings.groovy merged into application mappings • Application can override plugin mappings • Enables “mini application” in plugin • Can’t remove unwanted mappings, only override Wednesday, October 17, 12
  • 37. Config.groovy • Config.groovy is excluded from plugin • Might want to fix certain config properties - won’t need them in application Config • Manually merge config in doWithSpring • application.config.merge(new ConfigSlurper().parse(application.classLoader.loadClass('MyPluginConfig '))) Wednesday, October 17, 12
  • 38. Extending plugin domain model Content class Domain model plugin Domain classes in plugins can be extended in application Webinar extends Content Application Wednesday, October 17, 12
  • 39. Publishing private plugins • Publish to internal corporate Maven repo - e.g. Artifactory or Nexus • Release plugin - installed by default • Old-style svn-based repos supported, but not recommended for Grails 2 • Customize plugin metadata with internal Maven groupId • Publish from Jenkins Wednesday, October 17, 12
  • 40. Declaring private plugin dependencies BuildConfig.groovy (Maven/Ivy dependencies) repositories { grailsPlugins() /* other default repos here */ /* point to internal corporate Maven repo */ mavenRepo 'http://mvn.ieee.org/nexus/content/repositories/spectrum/' } plugins { /* other plugin dependencies here */ compile 'org.ieee.spectrum.plugins:spectrum-core:2.0-SNAPSHOT' } Wednesday, October 17, 12
  • 41. Day-to-day development • Use “in-place” plugin (exploded plugin) in your local dev workspace (BuildConfig.groovy) • Private plugins tend to be updated along with application features • Beware of potential breaking changes (in other applications) • Define deprecation strategy and use @deprecated javadoc Wednesday, October 17, 12
  • 42. Refactoring to plugin • Determine candidates for refactoring • Create new empty plugin & plugin descriptor • Move Grails artifacts (e.g. Controllers, Services, Views, etc.) into new plugin • Move dependent files from /src • Move related test files into new plugin • Remove hard coded paths to resources • Run your functional test suite Wednesday, October 17, 12
  • 43. Refactoring to plugin • Start small - don’t create a whole bunch of plugins from the outset • Consider migrating version history Wednesday, October 17, 12
  • 44. Super-project with plugins One application with several in-place plugins /myapplication /grails-app ... /pluginA /grails-app /pluginB /pluginC In BuildConfig.groovy: grails.plugin.location.pluginA = 'pluginA' // path to plugin grails.plugin.location.pluginB = 'pluginB' grails.plugin.location.pluginC = 'pluginC' Wednesday, October 17, 12
  • 45. Public website, private back end Public Private Internet intranet Deploy public Core Core application application plugin and private plugin Business- versions of Public-facing application facing application with application shared code DB Wednesday, October 17, 12
  • 46. Vertical slices / mini Grails applications • Plugins can be self contained • UrlMappings + Controllers + Domains + Views + Services = Grails application • Remove views -> “white label” application • Embed a small application within another application • Vertically slice your application into plugins Wednesday, October 17, 12
  • 47. Plugins as a platform Data Capture Data Cleaning Data Validation plugin plugin plugin Super-plugin to combine plugin Clinical Data Management dependencies into Platform plugin a platform or domain-specific framework Clinical data Clinical data review management server application application Wednesday, October 17, 12
  • 48. Sensitive code protection DB Split application into separate Data Ingestion Data Analysis parts to isolate plugin plugin “secret sauce” key algorithms from external vendor Shell application Full application (external team) Wednesday, October 17, 12
  • 49. Agenda • Grails plugins overview • Grails plugin development basics • Application architecture with private plugins • Lessons learned Wednesday, October 17, 12
  • 50. Domain/Schema management • Changes to domain model need to be carefully managed • Avoid dbCreate=update • Adopt DDL file naming convention: spectrum-core-2.1.sql spectrum-core-2.2.sql • Bootstrap-triggered migrations • DB Migrations plugin (Liquibase) Wednesday, October 17, 12
  • 51. Config.groovy changes over time • Easy to add a new entry to Config.groovy and then forget about it • Group together plugin config properties into a closure • Don’t forget about external config files and differences in various environments Wednesday, October 17, 12
  • 52. Maven/Ivy/build issues • Maven/Ivy hell > JAR hell • SNAPSHOT resolution error-prone • See JIRA for bugs related to plugins • Avoid creating many small plugins • Strange problems? Look at your build. Wednesday, October 17, 12
  • 53. Plugin versioning and branching • Define version numbering strategy • Be prepared to branch/merge • Be sure to update plugin versions and tag your code consistently • Just use Git - merging & cherry- picking are sweet Wednesday, October 17, 12
  • 54. Code Rigidity • Inflexibility to change/afferent coupling • Avoid breaking changes (duh) • Solution: automate your tests, catch breaking changes early Wednesday, October 17, 12
  • 55. Continuous Integration • Use Jenkins to trigger builds of applications that depend on your private plugin • Run Plugin test suite with plugin build • Publish snapshots to Maven repo from Jenkins Wednesday, October 17, 12
  • 56. Plugin namespace conflicts • Plugin artifacts all share same namespace with each other • Potential for class name collisions, especially with “conventions” • Planned enhancement for Grails 2.2 Wednesday, October 17, 12
  • 57. Plugin resources • Plugin static resources (images, CSS, JS, etc.) packaged in a path corresponding to plugin name & version - /plugins/ myplugin-1.0/* • path changes between dev mode and WAR - <g:resource> handles correctly • May need to redeploy with each plugin version bump • Don’t accidentally share sensitive files! Wednesday, October 17, 12
  • 58. Component interfaces • Grails plugins don’t have any kind of external “interface” or contract besides Plugin Metadata • Up to you to make the rules (not a bad thing) Wednesday, October 17, 12
  • 59. Success! Release strategy for 2013 website redesign spectrum-core Plugin 2.0, 2.1, 2.2 The Institute Spectrum Spectrum website website website 3.x 10.8, 10.9, 4.0 - 2013 10.10 release Wednesday, October 17, 12
  • 60. Takeaway • Plugins are easy to create and use • Private plugins are a safe, robust way to modularize Grails applications • Private plugins enable coarse-grained reuse of application components • Configuration management and OO principles are important (as always) Wednesday, October 17, 12
  • 61. Additional resources • @grailsplugins - Grails plugin updates - https://twitter.com/ grailsplugins • Grails reference docs chapter on plugins - http://grails.org/doc/ latest/guide/plugins.html • Inside Grails: The Build System and Plugin Management - http:// www.slideshare.net/skillsmatter/grails-internals-ggug-dec-2009 • GGUG: Grails Plugins - Lessons to Learn http://skillsmatter.com/ podcast/java-jee/grails-plugins Wednesday, October 17, 12
  • 63. Thanks! feedback is appreciated. @kenliu k.a.liu@ieee.org Wednesday, October 17, 12