-
-
Notifications
You must be signed in to change notification settings - Fork 957
Artifact Namespaces
Up through Grails 2.1.x we have no good way of managing artifact conflicts. Artifact conflicts include things like controllers or services with the same name in separate packages. For example an application may not contain both com.demo.UserController
and com.demo.admin.UserController
. Within an application this can be managed by simply naming them differently. The bigger problem comes from using multiple plugins that provide artifacts with the same name.
When referring to a controller from a tag like g:link
, specifying a plugin name may disambiguate the reference:
<g:link controller="user" plugin="spring-security">Manage Users</g:link>
Instances of Service artifacts are automatically added to the spring application context. The bean name is derived from the class name so an instance of com.demo.admin.UserService
is added to the application context with the bean name userService
. For services provided by a plugin then bean name may be prefixed with a camel case version of the plugin name. For example, if the spring-security
plugin provides com.demo.admin.UserService
then the bean name would be springSecurityUserService
. It may be beneficial to alias the bean to userService
if and only if there is no other UserService
service anywhere in the application.