If you rename it to something better, absolutely. That's the way almost all calls to CFCs should be, IMHO. The ability to cache CFCs in shared scopes is just too much of a benefit to not make use of it. There will always be some uses where you need new instances, but in general cache an instance in the app or server scope and use it through out the application.
Two things to watch for: 1) Never reference any shared scopes from inside your CFC. You've already done that, so you're set. 2) Make sure your methods are thread-safe. In other words, if two requests call the same method at the same time, you need to make sure nothing bad happens. ALWAYS using 'var' to scope local variables is the first step, and locking instance variable access were needed seals the deal. Cheers, barneyb > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Ben Densmore > Sent: Friday, April 09, 2004 8:27 AM > To: [EMAIL PROTECTED] > Subject: RE: [CFCDev] Access to Application variables > > Ok, > So that worked. I was trying to call the ordersShipped() method in a > .cfm page using another Creatobject() which is why it wasn't working. > > But is calling application.dsn.ordersShipped() in a .cfm page good > practice with using application or session variables? > > Ben > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On > Behalf Of Barney Boisvert > Sent: Friday, April 09, 2004 11:13 AM > To: [EMAIL PROTECTED] > Subject: RE: [CFCDev] Access to Application variables > > How are you calling the mailer CFC? You should be doing it like this: > > <cfset application.dsn.ordersShipped() /> > > I'm not sure why you named the variable storing it "dsn", but > your code > should work as-is, if you're calling it like that. > > Cheers, > barneyb > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Ben Densmore > > Sent: Friday, April 09, 2004 7:51 AM > > To: [EMAIL PROTECTED] > > Subject: [CFCDev] Access to Application variables > > > > I'm trying to store my Datasource names in my > application.cfm file and > > call them from a cfc but for some reason it doesn't seem to > work. Can > > someone tell me what might be wrong here: > > > > Application.cfm: > > <cfset application.dataSource = "Progress" /> > > <cfset application.dsn = CreateObject("component", > > "mailer").init(application.dataSource) /> > > > > mailer.cfc: > > <cfcomponent> > > <cffunction name="init" output="false" access="public" > > returntype="mailer"> > > <cfargument name="dsn" type="string" required="true"> > > > > <cfset variables.dsn = arguments.dsn /> > > > > <cfreturn this /> > > </cffunction> > > > > > > <cffunction name="ordersShipped" access="public" output="false" > > returntype="query"> > > <cfset var getOrdersShipped = 0 /> > > > > <cfquery name="getOrdersShipped" datasource="#variables.dsn#"> > > Select OrderDtl.PartNum, Customer.Name, CustCnt.Name, > > CustCnt.EmailAddress, OrderHed.Character05, OrderHed.Number01, > > ShipHead.PackNum > > From > > Pub.OrderDtl, Pub.Customer, Pub.CustCnt, Pub.OrderHed, > > Pub.ShipHead > > Where > > ShipHead.Company = 'HMC' > > And ShipHead.ReadyToInvoice = 'yes' > > And ShipHead.ShipDate = '#DateFormat(Now() - 14, "MM/DD/YY")#' > > And Orderhed.Company = ShipHead.Company > > And OrderHed.OrderNum = ShipHead.OrderNum > > And OrderHed.OpenOrder = 'no' > > And OrderHed.number01 != 1 > > And OrderDtl.Company = OrderHed.Company > > And OrderDtl.OrderNum = OrderHed.OrderNum > > And Customer.Company = OrderHed.Company > > And Customer.CustNum = OrderHed.CustNum > > And CustCnt.Company = Customer.Company > > And CustCnt.CustNum = Customer.CustNum > > And CustCnt.ShipToNum = '' > > And CustCnt.ConNum = OrderHed.PrcCntNum > > Order By ShipHead.PackNum > > > > </cfquery> > > > > </cffunction> > > > > </cfcomponent> > > > > Thanks, > > Ben > > ---------------------------------------------------------- > > You are subscribed to cfcdev. To unsubscribe, send an email > > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > > in the message of the email. > > > > CFCDev is run by CFCZone (www.cfczone.org) and supported > > by Mindtool, Corporation (www.mindtool.com). > > > > An archive of the CFCDev list is available at > > www.mail-archive.com/[EMAIL PROTECTED] > > > > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > www.mail-archive.com/[EMAIL PROTECTED] > ---------------------------------------------------------- > You are subscribed to cfcdev. To unsubscribe, send an email > to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' > in the message of the email. > > CFCDev is run by CFCZone (www.cfczone.org) and supported > by Mindtool, Corporation (www.mindtool.com). > > An archive of the CFCDev list is available at > www.mail-archive.com/[EMAIL PROTECTED] > ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com). An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
