Mike- It's a very interesting approach, but I do see the benefits. I will certainly play around with it. Thank you for the detailed explanation.
Ryan Mike Kear wrote: > The answer is to have a component that IS session-aware. It keeps > all the access of the session scope to one CFC and allows all the > other cfcs that require information from the session scope to have > that injected in by Coldspring. It's called a facade. It separates > the other cfcs from the session scope. They dont know about the > session scope, dont need to know and dont care. All they know is that > the information they require is provided when it's required. The > same would also apply to any other scope too. > > Here's what's in my UserService.cfc: > > <cfcomponent displayname="UserService" output="no" hint="Service > facade for the User functions"> > <cffunction name="getUser" access="public" > returntype="cfcs.Users.user" output="false" hint="Collects the current > user's user bean from the session scope and returns it"> > <cfreturn session.user /> > </cffunction> > </cfcomponent> > > This is the only CFC with knowledge of the session scope. You could > also have methods that access the client scope if you use client > variables or application vars as well if that's relevant to your app. > (altough i pass in application vars with a configbean but that's a > similar concept.). > > > The Coldspring.xml file has these items in it : > > > <beans> > <!-- configuration --> > <bean id="configbean" class="cfcs.config.configbean"> > <constructor-arg > name="argsConfigXMLname"><value>/cfcs/config/AdminConfig.xml</value></constructor-arg> > </bean> > > <bean id="ProductDAO" class="cfcs.Merchandise.ProductDAO"> > <constructor-arg name="argsConfiguration"><ref > bean="configbean"/></constructor-arg> > <property name="UserService"><ref bean="UserService" > /></property> > </bean> > </beans> > > > Then in the various CFCS like for example the products DAO: > > <cfcomponent displayname="Products DAO" output="false"> > <!--- Constructor ---> > <cffunction name="init" access="Public" returntype="MerchProductDAO" > output="false" hint="Initialises the controller"> > <cfargument name="argsConfiguration" required="true" > type="cfcs.config.configbean" /> > <cfset variables.dsn = arguments.argsConfiguration.getDatasource() /> > <cfreturn this /> > </cffunction> > > <cffunction name="setUserService" access="public" output="false" > returntype="void" hint="Dependency: User Service"> > <cfargument name="UserService" type="admin.cfcs.users.UserService" > required="true"/> > <cfset variables.UserService = arguments.UserService/> > </cffunction> > > > > > And throughout the DAO whenever a part of the session scope is needed, > you do this .. (for example in the products DAO, the INSERT and UPDATE > methods require the userid of the person causing the action to take > place, for the audit trail) you have the following: > > > updatedby = <cfqueryparam > value="#variables.userService.getUser().getUserId()#" > cfsqltype="cf_sql_varchar"/> > > It seems very convoluted and long-winded at first. But if you just > humour me for a while and go with it, you'll see that eventually the > light comes on and you see what a terrific benefit it is to separate > your CFCs completely from needing to know about anything except what's > told to them when they're instantiated. > > In the example I've given, ProductsDAO doesnt know anything about the > session scope. It doesnt need to . IT's got a service injected. > > Suppose you have dozens or maybe even hundreds of CFCs scattered > through your site, and your IT architect decides that user > information is now going to be stored in the client scope instead of > the session scope. > > What you'd do is quote them for 6 weeks work, on the basis that it's a > major upheaval to the basic infrastructure, spend 5 minutes changing > and testing the facade UserService.cfc, spend a couple of days > playing computer games, read a book, write a personal site, update > the site for your hobby, write your blog, "work at home" for 4 weeks, > and then give them the bill for $15 grand for 6 weeks work. > > Cheers > Mike Kear > Windsor, NSW, Australia > Adobe Certified Advanced ColdFusion Developer > AFP Webworks > http://afpwebworks.com > ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month > > > > >> On Fri, Apr 4, 2008 at 10:59 AM, Ryan J. Heldt <[EMAIL PROTECTED]> wrote: >> >>> Hey Guys- >>> >>> I'm fairly new to this whole Coldspring business, so I apologize if this >>> is a glaringly obvious question. I have an intranet application that has >>> a AuthenticatedUser CFC that is given to every user that signs in, >>> persisted in the session scope. Is it possible to have Coldspring inject >>> that session-persisted object into another object/bean. Say, for >>> example, I have an object that needs to return information based on the >>> current user. >>> >>> Thanks for your help! >>> Ryan >>> >> > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302967 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

