Mark Drew (Redux)- cf_etc...

a compendium of railo, cfml, cfeclipse and technology topics

Mark Drew (Redux)- cf_etc...

Model Glue Tips: Splitting out ColdSpring

October 28, 2007 ·

A comment posted in my entry about Model Glue Tips Part 1: Separate out your Model-Glue file reminded me that I should continue with some of those postings. One of the things that happens when you start building larger applications is that you get a lot of objects that you are managing with ColdSpring. This means that the file can get rather large, and again that is a bad thing right (I keep going on about this to lots of people that write CF, the same goes for your XML files). There are other reasons to split out the ColdSpring file, apart from a neatness. One of our applications actually creates other ModelGlue applications. And each one of these has separate configurations and in fact available objects (they are automatically written out) as well as maybe some custom configurations. The problem would be that if you update the core code, that is, objects that are core to the system, you dont want to be messing about with merging these files together, so I tend to split things out something like:
  • ColdSpring.xml   <- Main (Core) ColdSpring File
  • ColdSpring_Config.xml  <- Automatically written file that has our DSN, reactor and other site specific settings
  • ColdSpring_Custom.xml <- Custom settings and mappings for the application
All these files are complete ColdSpring files in themselves (that is, they start with <beans>) and are imported into the main ColdSpring file as imports: <beans>
    <import requires="config/ColdSpring_Config.xml" />
    <import requires="config/ColdSpring_Custom.xml" />

    ....
    <!-- The rest of the core files -->

   </beans>
Once you have done this, beans in the external files are loaded as normal. A quick note, and I haven't checked this properly, but this works in the bleeding edge version of ColdSpring which you can get through CVS following the instructions here: http://www.coldspringframework.org/index.cfm?objectid=2DD5F8AF-DD05-F8C8-7860429E21850D7E

Tags: , ,

Tags: coldfusion · coldspring

5 responses

  • 1 Dave Ross // Sep 22, 2008 at 4:13 PM

    I added the link to the nightly build on that page (http://cvs.coldspringframework.org/nightly/coldspring-nightly.zip) - so you can grab w/o CVS.
  • 2 Mark Drew // Sep 22, 2008 at 4:13 PM

    @Dave: Great stuff! I wasn't sure which version supports this, but I just use the latest one :D
  • 3 Mark Drew // Sep 22, 2008 at 4:13 PM

    By the way Dave, the build for the nighly seems to make files named &quot;aop\Advice.cfc&quot; rather than a file under aop called Advice.cfc

    Very odd
  • 4 James Allen // Sep 22, 2008 at 4:13 PM

    Would you recommend using the very latest build?

    I'm currently playing with the main release and so can't use the &lt;import&gt; tag.

    I wasn't sure whether to use the latest as I don't want to come across any bugs in CS which might make developing the huge project I'm about to start work on even more complicated.
    I'm learning Model-Glue on the job so want to try and minimise potential issues as much as possible. :)

    If it's usually pretty stable though it might be worth it. I really just want the &lt;import&gt; tag so that I can mirror how I'm sub-dividing my Model-Glue config files and controllers.
  • 5 Adam Tuttle // Sep 22, 2008 at 4:14 PM

    Not sure if the implementation has changed since your original posting, but for what it's worth, the current implementation uses &amp;lt;import resource=&quot;path/to/xml/file&quot;&amp;gt;, not &amp;lt;import requires=&quot;...&quot;&amp;gt;