1.2 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.3.8
1.2 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 namedcom.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' } }
<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
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 perimiter, (width * height) as area', ['perimeter', 'area'], [INTEGER, INTEGER] } }