Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Store ref to java object in session or not?

New Here ,
Jul 18, 2012 Jul 18, 2012

Hi,

In my app I have a java back end layer. It has a java Delegate with a number of methods that I access frequentlly through out my coldfusion components. I was thinking of creating this java object once and storing it in session so I could reuse it.

I'm just wondering if the trade off on having to use cflock around every call to it is worth storing it in session or would I be better off just creating a nw instance of the java object every time I need it?

Thanks in advance

938
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 18, 2012 Jul 18, 2012

It doesn't sound like a session-specific thing?  Is it a different (type of ~) delegate for each user?  or one for the entire application?  I would expect it to be the latter.  That being the case, it's probably better homed in the application scope.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2012 Jul 18, 2012

Hi Adam,

You are correct in saying one delegate is used by the entire application, not per user, and I can see why you suggested Application scope but in the Adobe docs its states:

"Whenever a request is reading or writing an Application scope variable, any other requests that use the variable must wait until the code accessing the variable completes. This problem is increased by the processing time required for locking."

So I'm just not sure it its over-kill to even try to store this object for re-use or if I should just create it each time I need it?

Any other suggestions/knowledge welcome?

Thanks,

Orla

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 18, 2012 Jul 18, 2012

"Whenever a request is reading or writing an Application scope variable, any other requests that use the variable must wait until the code accessing the variable completes. This problem is increased by the processing time required for locking."

That's a load of ballocks.  Where are you reading that from (ie: the URL)?

Create the CFC instance in your onApplicationStart() method (which is single-threaded by default), and there won't be any problem with reads.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 18, 2012 Jul 18, 2012
LATEST

lol..... I got that info from the CF8 docs:

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=sharedVars_01.html (Go to 'Configuring and Using Application variables section and its about the 3rd or 4th last paragraph).

I have just read the docs for onApplicationStart though, and it backs up what you suggested, i.e. no locks required.

Thanks for you help

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources