There are a few ways to get this done.

You can have a controller listen for the onApplicationStart message
(automatically broadcast by the Model-Glue framework) and perform whatever
you want in your controller.

*ColdSpring.xml*
<bean id="EnvironmentManager"
class="environmentConfig.models.EnvironmentService" />

*Model-Glue.xml*
<controller name="Whatever"
type="Somewhere.over.the.rainbow.WhateverController">
  <message-listener message="onApplicationStart" />
  ....
</controller>

*WhateverController.cfc*
<component beans="EnvironmentService">

<cffunction name="onApplicationStart" returntype="void">
  <cfargument name="Event" type="any" required="true" >
  <cfset beans.EnvironmentService.configureEnvironment(
'/config/environment.xml.cfm' ) />
 ....
</cffunction>

</cfcomponent>


*Big Picture:*

Your application will start up and initialize (calling init) all the beans
in ColdSpring, including your EnvironmentService.
Model-Glue will fully create itself, then broadcast onApplicationStart.
Your controller will catch this message, then run the function called
onApplicationStart (because we didn't specify another function name, it
assumed the function is the same name as the message)
Your application specific code inside the
WhateverController.onApplicationStart method runs, grabbing the reference to
EnvironmentService from ColdSpring (using the beans scope) and running
configureEnvironment thus completing the requirements.


That is the way to get this done without rewriting/extending any of the
environmentService code.

Make sense?


DW






On Mon, Dec 7, 2009 at 5:39 PM, Mike C <[email protected]> wrote:

> Hi,
>
> I am attempting to utilize Rolando Lopez's excellent EnvironmentConfig
> (http://environmentconfig.riaforge.org/) within a MG application. I
> have this up and running outside of MG, but I am unsure as to if,
> where and how I can invoke EC within MG/ColdSpring at application
> startup time.
>
> I'm aware that a ColdSpring bean definition file can be created by
> setting the EC property bCreateColdSpringFile=true, and this can be
> included in the main ColdSpring.xml file. This is precisely the
> mechanism I want to use. My question however, is if, and if so, how
> can I invoke EC itself from within MG so the dynamically generated CFC
> and the ColdSpring file stub get recreated each time the application
> is reinitialized.
>
> In the example provided in the EC download, EC is invoked in
> Application.cfc thus:
>
> oEnvironmentService = createObject( 'component',
> 'environmentConfig.models.EnvironmentService' ).init();
> stResults = stl.oEnvironmentService.configureEnvironment( '/config/
> environment.xml.cfm' );
>
> I'm thinking there must be a much more elegant solution to this
> utilizing ColdSpring, and I would like to invoke and execute this
> within the MG application initialization process, so that the newly-
> generated stub gets included. Does anyone have any pointers that could
> help me in the right direction? I'm hoping I'm not the first to come
> across this issue!
>
> I'm very new to MG/ColdSpring, and any assistance would be very
> gratefully received by this framework newbie!
>
> Many thanks,
>
> Mike.
>
> --
> Model-Glue Sites:
> Home Page: http://www.model-glue.com
> Documentation: http://docs.model-glue.com
> Bug Tracker: http://bugs.model-glue.com
> Blog: http://www.model-glue.com/blog
>
> You received this message because you are subscribed to the Google
> Groups "model-glue" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<model-glue%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/model-glue?hl=en




-- 
“Come to the edge, he said. They said: We are afraid. Come to the edge, he
said. They came. He pushed them and they flew.”

Guillaume Apollinaire quotes

-- 
Model-Glue Sites:
Home Page: http://www.model-glue.com
Documentation: http://docs.model-glue.com
Bug Tracker: http://bugs.model-glue.com
Blog: http://www.model-glue.com/blog

You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

Reply via email to