Copy link to clipboard
Copied
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.
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks for the link, that did it !
I had to add following lines in the while loop and all apps will refresh itself :
appScope = appObj.getApplicationScope(appName);
appObj.cleanUp(appScope);
I could not find any documentation regarding the coldfusion.runtime.ApplicationScopeTracker lib, but tested it out and it kills all apps. Next call to any app will refresh it, without users losing their session.
It pains me that their does not exist any decent documentation for the coldfusion java classes.
Once again, thanks for your input!
Cheers Bert.