Coldspring
ColdSpring is a framework for CFCs (ColdFusion Components).
ColdSpring's core focus is to make the configuration and dependencies of your CFCs easier to manage. ColdSpring uses the "inversion-of-control" pattern to "wire" your CFCs together. Inversion-of-control provides many advantages over traditional approaches to assembling your application's model. Also part of ColdSpring is the first Aspect-Oriented-Programming (AOP) framework for CFCs.
ColdSpring is a inversion-of-control framework/container for CFCs (ColdFusion Components). Inversion of Control, or IoC, is synonymous with Dependency Injection, or DI. Dependency Injection is an easier term to understand because it's a more accurate description of what ColdSpring does. ColdSpring borrows its XML syntax from the java-based Spring Framework, but ColdSpring is not necessarily a "port" of Spring.
Setting Up Fusebox for ColdSpring
To get CS setup you need to initilise the CS factory, you do this using the initialize verb mentioned above. The best place to do this is in the appinit section of fusebox.xml.cfm as this is called as you start your app (it's like the onApplicationStart function in application.cfm). Within this function you will call a fuseaction in the model circuit:
<fuseaction action="m.coldSpringSetup" />
</appinit>
Then inside the model circuit you will have the following fuseaction:
<circuit access="public" xmlns:cs="coldspring/">
<fuseaction name="coldSpringSetup">
<cs:initialize coldspringfactory="servicefactory" defaultproperties="#application.defaultProperties#">
<cs:bean beanDefinitionFile="#expandPath('/config/coldspring.xml.cfm')#" />
</cs:initialize>
</fuseaction>
...
What we have done here:
- <circuit access="public" xmlns:cs="coldspring/"> - we're declaring the namespace for the coldspring lexicons
- cs:initialize - this calls the initialize verb from the coldspring lexicon folder.
- coldspringfactory="servicefactory" - this is giving the coldspring factory it's name.
- cs:bean - this calls the bean verb from the coldspring lexicon folder.
- beanDefinitionFile="#expandPath('/config/coldspring.xml.cfm')#" - this passes my config file to coldspring
Next you'll want to call a ColdSpring method within the CS namespace of your circuit.xml as follows:
<cs:get bean="categoryService"
returnvariable="variables.categoryService"
coldspringfactory="servicefactory" />
...
What we have done here:
- cs:get - this invokes the get verb from the coldspring lexicon folder.
- bean="categoryService" - this tells CS which bean (function or method) in needs to get from the CS factory
- coldspringfactory="servicefactory" - this tells CS which coldspring factory to use.
You can then call your objects as normal:
methodcall="productCategorySelect(attributes.catalogueID)"
returnVariable="qProductCategoryList" />
Coldspring Code Generator
For more information on Coldspring Code Generation for Fusebox 5, click here
External Links
-
ColdSpring Framework
-
Setting up Coldspring within fusebox By Nick Tong
-
Coldspring Lexicons By Nathan Strutz -
Included with Fusebox Essentials