House of Fusion
Home of the ColdFusion Community
Hostmysite Dedicated Hosting

Search cf-talk

September 06, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30         

Subscribe Now
Fusion Authority Quarterly Update - ColdFusion 8 Special Edition

For ColdFusion hosting try HostMySite.com.
Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

Coldspring Question

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Hey Guys-
Ryan J. Heldt
04/04/08 12:01 P
Mike-
Ryan J. Heldt
04/08/08 01:23 P
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Ryan J. Heldt
04/04/2008 12:01 PM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Matt Williams
04/04/2008 12:59 PM

ColdSpring is best suited for managing the CFCs that need to be in application scope and their inter-related dependencies. Anything session related would still have to be done manually as ColdSpring is not really session aware. Matt On Fri, Apr 4, 2008 at 10:59 AM, Ryan J. Heldt <rheldt@globalreach.com> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Mike Kear
04/05/2008 12:16 AM

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 ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Ryan J. Heldt
04/08/2008 01:23 PM

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: ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists