Description
Enables the usage of the Spring framework as Dependency Injection provider, and much more!
Installation
The current version of griffon-spring-plugin is 0.8
To install just issue the following command
Usage
The Spring plugin will manage all relationships between artifacts by autowiring them by name. It relies on Grail's BeanBuilder to get the job done. You may place additional beans to be wired in a script named resources.groovy and place it under src/spring. This script should contain bean definitions as expected by BeanBuilder.
You can also create addons that are Spring aware. Follow these steps to create such an addon
- create a new plugin project
- change into the newly created plugin's directory and create an addon
- edit your plugin's descriptor by declaring a dependency on the spring plugin
- your addon must contain at least one of the following properties
Addons that do not define a hard dependency on the Spring plugin can still contribute beans, either by placing bean definitions inside the doWithSpring property (might require access to Spring classes like factory beans) or inside griffon-app/conf/metainf/spring/springbeans.groovy (using the same format as src/spring/resources.groovy). The latter form is preferred for bean contributions that require spring classes which are not available in the plugin's classpath at buildtime.
Exposed Beans
The following beans are automatically configured in the ApplicationContext
Name |
Type |
Notes |
|---|---|---|
application |
griffon.core.GriffonApplication |
current application instance |
appConfig |
groovy.util.ConfigObject |
the application's configuration |
artifactManager |
griffon.core.ArtifactManager |
|
addonManager |
griffon.core.AddonManager |
|
uiThreadManager |
griffon.core.UIThreadManager |
|
Addiotionally, all Model, View, Controller classes will see their respective GriffonClass exposed following a naming convention. If the model class is sample.SampleModel then it's griffonClass will be exposed as sampleModelClass.
Events
The following events will be triggered by this addon
- WithSpringStart[app, applicationContext] - triggered before bean contributions from addons are processed
- WithSpringEnd[app, applicationContext] - triggered after bean contributions from addons have been processed
- WhenSpringReadyStart[app, applicationContext] - triggered before addons tweak the applicationContext
- WhenSpringReadyEnd[app, applicationContext] - triggered after addons have had a chance to tweak the applicationContext
History
Version |
Date |
Notes |
|---|---|---|
0.8 |
10-21-11 |
Release sync with Griffon 0.9.4 |
0.7.1 |
09-22-10 |
Release sync with Griffon 0.9.3 |
0.7 |
06-27-10 |
Release sync with Griffon 0.9.3-beta-2 |
0.6 |
02-10-11 |
Refactor API to make use of AddonManager |
0.5 |
12-21-10 |
Release sync with Griffon 0.9.2 |
0.4 |
10-27-10 |
Release sync with Griffon 0.9.1 |
0.3 |
07-22-10 |
Release sync with Griffon 0.9 |
0.2 |
03-01-10 |
Upgraded to Griffon 0.3 |
0.1 |
01-07-10 |
Initial release |