Gotcha.

Jaime

-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] Behalf Of Barney
Boisvert
Sent: Monday, 5 March 2007 2:45 PM
To: [email protected]
Subject: [coldspring-dev] Refreshing beans


It's only thread-unsafe if you application isn't enforcing thread
safety already.  I assume you want to see this:

<cfset factory = ... make a new factory ... />
<cfset application.factory = factory />

This will replace the factory inline, ensuring that it's never in a
"doesn't exist" state.  But that's still not thread safe, because a
single request could be accessing two different factories (potentially
getting two different results from two identical invocations).

I'd say that you shouldn't use application.factory directly, you
should copy it to request.factory at the top of the request, so that
request always gets a consistent set of beans, even if the factory is
reloaded.

<cflock ...>
   ... ensure ColdSpring is loaded ...
   <cfset request.factory = application.factory />
</cflock>
...
<cfset x = request.factory.getBean("myBean") />

This ensures not only that a factory always exists, but that a given
request will always access the same factory (which means the same
beans).  If you have long-running processes, you can get some really
weird bugs if your bean factory gets switched in the middle so the
first and second halves of the process are actually happening with
different code versions.

cheers,
barneyb

On 3/4/07, Jaime Metcher <[EMAIL PROTECTED]> wrote:
> You're going to just kill it and leave it dead?  Hardly thread-safe, is
it?
>
> Jaime Metcher

--

Barney Boisvert
[EMAIL PROTECTED]
http://www.barneyb.com/

Got Gmail? I have 100 invites.




Reply via email to