Someone more experienced with CS than me will surely answer your question in
more detail, but I will start it out by saying that you've just stumbled on
what makes CS so beautiful and so valuable: Dependency injection!
In ColdSpring.xml, you're defining that your ContactDAO requires an instance
of the AppConfig object ("bean"). Since CS also knows about the AppConfig
bean, it will load it up and either inject it into the DAO using these
special get/set functions (as seen here) or pass it as a constructor
argument (to init() -- see the documentation on that one).In addition, you can probably make your AppConfig bean a singleton, which will mean CS will only load it up once and cache that instance, passing it to beans that need it as necessary. Finally, in the code of your ContactDAO, you can just assume that the AppConfig object has been set, and reference it. For example, it might contain your mail server settings for use in a mailer function, or datasource information, and so on. <cfquery name="result" datasource="#variables.appConfig.getDatasource()#">...</cfquery> Adam On Thu, Sep 11, 2008 at 9:21 AM, cs01rsw <[EMAIL PROTECTED]> wrote: > > hi > > we have noticed on an example that the following cfc is referenced in > the coldsprings.xml as follows: > > <bean id="ContactDAO" class="ContactManagerMG.model.ContactDAO"> > <property name="AppConfig"><ref bean="AppConfig" /></property> > </bean> > > and in the ContactDAO.cfc there is a setter: > > <cffunction name="setAppConfig" access="public" output="false" > returntype="void"> > <cfargument name="AppConfig" type="any" required="true" /> > <cfset variables.instance.AppConfig = arguments.AppConfig /> > </cffunction> > > however, we cannot find any code that calls the setAppConfig function, > and there is no init function within the ContactDAO.cfc. > > this leads us to believe there must be a direct relationship between > the <property name="AppConfig"><ref bean="AppConfig" /></property> and > the setter function. when the bean is created does it automatically > look for a set function for that property? > > we are a little confused with this and would appreciate the help. this > also then leads us to some confusion about when and why you use the > init function, and when and why do you use properties > > thanks for any help > > richard > > > --~--~---------~--~----~------------~-------~--~----~ 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 For more about Model-Glue, check http://www.model-glue.com . -~----------~----~----~----~------~----~------~--~---
