Skip to main content
Inspiring
December 21, 2009
Answered

Refreshing all active applications

  • December 21, 2009
  • 1 reply
  • 824 views

Hi all,

I'm a bit stuck with the following problem. I use the application scope to store a rather large collection of labels used in our corporate Intranet. From time to time, I need to refresh this collection as I add new labels. I implemented a refresh switch by writing the following code in my OnRequestStart method of the Application.cfc :

  if (IsDefined("URL.flush"))
    OnApplicationStart(flushed=true);

So on any given page I manually add the 'flush=true' URL parameters and voila, refreshed.


The problem is that different applications exist as people log onto the Intranet via different names (serverName, server IP, DNS alias,...).


I wrote the following to retrieve all active applications :

  appObj = createObject("java", "coldfusion.runtime.ApplicationScopeTracker");
  apps = appObj.getApplicationKeys();
  appsList = "";
  while (apps.hasMoreElements()) {
    appName = apps.nextElement().toString();
    appsList = ListAppend(appsList, appName);
  }
  appsList = listSort(appsList, "textNoCase", "asc");

This returns a list of all active applications. I can retrieve a specific application by calling :

appScope = appObj.getApplicationScope(appName);

However, I would like to invoke the OnApplicationStart method of each of those application scopes...

How can this be achieved?

Thanks for reading so far !

Greetings, Bert.

    This topic has been closed for replies.
    Correct answer

    don't store a variable in a db that has to be checked everytime a page runs, (why would anyone need application vars if this was always done)

    url param refreshing is acceptable using ur script to list the app names and then using the snippet in http://forums.adobe.com/thread/537752?tstart=0

    1 reply

    Inspiring
    December 21, 2009

    Move the label collection to a database and query it when you need it.  Then it will be available to any application that needs it.

    Inspiring
    December 21, 2009

    I 've been thinking about a better strategy for a long time now, but I still would find it more efficient to load the entire label collection into the APPLICATION scope for easy access. Querying the DB for labels on each page request would incur a dramatic increase in DB access. As most of these labels are static and used on several pages/locations in the entire app, it seems a bit over the top. (not to mention a new system to link labels to a module would be needed)

    The labels will go into the DB one day, but just not yet. (as is always the case in Intranet apps, there's a lot of legacy code)

    Thanks for the suggestion though!

    Cheers, Bert.

    Correct answer
    December 30, 2009

    don't store a variable in a db that has to be checked everytime a page runs, (why would anyone need application vars if this was always done)

    url param refreshing is acceptable using ur script to list the app names and then using the snippet in http://forums.adobe.com/thread/537752?tstart=0