I'm no expert on this but would suggest you avoid using the Application (as well as form, request, url, cookie etc) in CFC's.
I would use an object factory (Coldspring or your own one) to create instances and compose the objects with other instances (using 'setter injection'). I sometimes use a very simple factory written by Rob Gonda which does the job: http://www.robgonda.com/blog/index.cfm/2007/2/23/Object-Factories-and-Circular-Dependencies I would also suggest you create different service CFC's so each one has ONE specific purpose and this means you will not have to keep changing existing (working) code in the service CFC when itroducing new services (reducing possibilities of introducing bugs to existing code) Alan ________________________________________ From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf Of Dave Phipps [EMAIL PROTECTED] Sent: 14 August 2007 11:14 To: [email protected] Subject: [Reactor for CF] Adding a service layer Hi, I am just starting to put together a new app using FB5.1 and Reactor and I would like to follow Brian's advice and add a service layer (and possibly and remoting layer) between fb and reactor and I have a couple of questions: Do I set the reactorFactory into the application scope and then reference this from within my service layer cfc's? Or is there a better way? Do I need to create different service layer cfc's, for example, for category, product, customer etc? And do I then split these further into a Manager, Gateway setup? I know a lot of this is subjective and I guess it can be done in any number of ways - but this is where I am still learning, so just one way would be good to get me started. Could someone let me know if the above sounds about right and any example snippets/file structure. One thing I am about to try is the following: fusebox.appinit.cfm: application.reactor = createObject(theusual).init(config) Then in my categoryManager.cfc: <cffunction name="init" displayname="Initialise the service layer" access="public" output="false" returntype="com.categoryManager"> <cfargument name="reactor" type="reactor.reactorFactory" required="true" /> <cfset variables.local = StructNew() /> <cfset variables.local.reactor = arguments.reactor /> <cfreturn this /> </cffunction> Would it be better to do this instead?: <cffunction name="init" displayname="Initialise the service layer" access="public" output="false" returntype="com.categoryManager"> <cfset variables.local = StructNew() /> <cfset variables.local.reactor = application.reactor /> <cfreturn this /> </cffunction> Any help would be very much appreciated. Cheers, Dave -- David Phipps, Director [EMAIL PROTECTED] Chapel Studios / London T +44 (0)20 7100 6980 F +44 (0)20 7100 6981 M +44 (0)7765 240899 New Broad Street House, 35 New Broad Street, London, EC2M 1NH, United Kingdom Visit our website: http://www.chapel-studios.co.uk _____________________________________________________________________________ Chapel Studios is a limited company registered in England. The information in this email is confidential, intended solely for the addressee, and may be legally privileged. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose or take any action based upon this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [EMAIL PROTECTED] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Reactor for ColdFusion Mailing List [EMAIL PROTECTED] Archives at: http://www.mail-archive.com/reactor%40doughughes.net/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
