3

I have a general understanding of the ColdFusion Application Workflow. But some parts remain unclear to me. The general workflow is as follows...

  1. Public Application Settings are set (I.E this.name, this.mappings ext.)
  2. onApplicationStart
  3. onSessionStart
  4. onRequestStart

I have a sub-directory with an Application.cfc that extends a root Application.cfc that exists at the web-root

After reading tons of blogs that describe this design pattern....

In the last link (some answers offer some basic insight,but none really touch on using this scope with an extended Application.cfc . One of the the following answer throws me off..(it might not be correct as no upvotes)

Anything in the this scope inside an Application.cfc file becomes an application varialbe and is only created ONCE per application life cycle. After the application starts, there is no other user for this within Application.cfc

I dumped the #application# scope and it is different then #this#

getApplicationMetaData() seems to dumps the same data <cfdump var=#this#> so im guessing thisMetadata is the global config variables initially set.

1) If the Application.cfc is extending a root Application.cfc using a proxy, is thethis scope (used to set name of application ) shared by extended components? (If I set this.name = "root" in the root component and this.name = "user"in the derived one, does cold fusion see this as two different applications or is the only effect that simply the value of the application name changes?

2) Is there anyway to change the Application MetaData on the this scope in any of the Applicaiton.cfc functions post psudo constructor (onApplicationStart ,onSessionStart ,onRequestStart)?

I'm looking at trying to set the application specific mappings in the the root component using the onApplicationStart() so that the mappings are only set once.

Hedge7707
  • 557
  • 1
  • 5
  • 17
  • 2
    Trying to set the mappings in the root cfc, or use them? – Dan Bracuk Jan 08 '18 at 22:48
  • I was experimenting with trying to set them in the root onApplicationStart()... I know I can set them on the "this" scope outside the functions, but I believe the mappings gets reinitialized on every request (Don't think there is too much overhead), but would be cool if I could just set them once ... ( Had the mappings previously set in the CF admin page, but wanted to try Application specific mappings) – Hedge7707 Jan 08 '18 at 23:33
  • I suspect you are right about `this` scope, but ... set up a simple test and dump `this` scope in both Application.cfc's to verify. Other than the coolness factor, any reason not to just set them in the parent like Dan suggested? – SOS Jan 09 '18 at 03:06
  • @Ageax So my reasoning was to reduce overhead associated with initializing mappings, which from my understanding are reinitialized every time the Application.cfc is hit ( they aren't dynamic through the runtime of the application, so I don't see why they cant be set once when the application initially starts up). I could just set up mappings in the ColdFusion Admin console, but that adds another step for whoever later deploys the application. – Hedge7707 Jan 09 '18 at 13:10
  • 2
    @Hedge7707 you may be interested in reading [Mapping to a CFC in ColdFusion](https://stackoverflow.com/q/7814357/923833) and [Is premature optimization really the root of all evil?](https://softwareengineering.stackexchange.com/q/80084/173058) – Twillen Jan 09 '18 at 14:59
  • What did you end up doing with this? – James A Mohler Jan 11 '18 at 15:00
  • ATM I set the mappings and ColdFusion configuration on the "this" scope in the root Application.cfc outside the component functions( But from what I can tell, I am able to modify those settings from the extended Application.cfc outside of any component functions. – Hedge7707 Jan 11 '18 at 18:33
  • "why they cant be set once when the application initially starts up" @Hedge7707 - I don't think Adobe implemented it that way, so ... unless it's causing an issue or performance problems, I wouldn't worry about it. – SOS Jan 11 '18 at 22:06

0 Answers0