1.3 What's new in Grails 2.2? 2.4.4

See the light - agile, industrial strength, rapid web application development made easy

(Quick Reference) # 1.3 What's new in Grails 2.2? - Reference Documentation Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari Version: 2.4.4 ## 1.3 What's new in Grails 2.2? #### Namespace Support Grails 2.2 includes improved support for managing naming conflicts between artifacts provided by an application and its plugins. Bean names for Service artifacts provided by a plugin are now prefixed with the plugin name. For example, if a Service named `com.publishing.AuthorService` is provided by a plugin named `PublishingUtilities` and another Service named `com.bookutils.AuthorService` is provided by a plugin named `BookUtilities`, the bean names for those services will be `publishingUtilitiesAuthorService` and `bookUtilitiesAuthorService` respectively. If a plugin provides a Service that does not have a name which conflicts with any other Service, then a bean alias will automatically be created that does not contain the prefix and the alias will refer to the bean referenced by the prefixed name. Service artifacts provided directly by the application will have no prefix added to the relevant bean name. See the dependency injection and services docs. Domain classes provided by a plugin will have their default database table name prefixed with the plugin name if the `grails.gorm.table.prefix.enabled` config property is set to `true`. For example, if the `PublishingUtilities` plugin provides a domain class named `Book`, the default table name for that domain class will be `PUBLISHING_UTILITIES_BOOK` if the `grails.gorm.table.prefix.enabled` config property is set to `true`. URL Mappings may now include a `plugin` attribute to indicate that the controller referenced in the mapping is provided by a particular plugin.

    static mappings = {    // requests to /bookAuthors will be handled by the
        // AuthorController provided by the BookUtilities plugin
        "/bookAuthors" {
            controller = 'author'
            plugin = 'bookUtilities'
        }    // requests to /publishingAuthors will be handled by the
        // AuthorController provided by the Publishing plugin
        "/publishingAuthors" {
            controller = 'author'
            plugin = 'publishing'
        }
    }
See the namespaced controllers docs for more information. Controller methods and GSP Tags which accept a controller name as a parameter now support an optional parameter indicating that the controller is provided by a specific plugin.
    <g:link controller="user" plugin="springSecurity">Manage Users</g:link>
    class DemoController {
        def index() {
            redirect controller: 'user', action: 'list', plugin: 'springSecurity'
        }
    }
#### Forked Tomcat Execution Grails 2.2 supports forked JVM execution of the Tomcat container in development mode. This has several benefits including: Reduced memory consumption, since the Grails build system can exit Isolation of the build classpath from the runtime classpath The ability to deploy other Grails/Spring applications in parallel without conflicting dependencies See the documentation on using forked mode for more information. #### SQL Projections In Criteria Queries Grails 2.2 adds new functionality to criteria queries to provide access to Hibernate's SQL projection API.

    // Use SQL projections to retrieve the perimeter and area of all of the Box instances…
    def c = Box.createCriteria()def results = c.list {
        projections {
          sqlProjection '(2 * (width + height)) as perimeter, (width * height) as area', ['perimeter', 'area'], [INTEGER, INTEGER]
        }
    }
See the Criteria section for more information. #### Groovy 2 Grails 2.2 ships with Groovy 2.0, which has a bunch of new features itself. | Quick Reference (hide)