My plugin to create the ReactorGatewayFactory as a property in MachII does the following:
<cffunction name="configure" access="public" returntype="void" output="false">
<cfparam name="application.ReactorGatewayFactory " default=#createObject("component","model.ReactorGatewayFactory").init(getProperty("ReactorFactory"))# />
<cfset setProperty("ReactorGatewayFactory", application.ReactorGatewayFactory) />
</cffunction>
And ReactorGatewayFactory.cfc contains the following:
<cffunction name="init" access="public" output="false" returntype="ReactorGatewayFactory">
<cfargument name="ReactorFactory" required="true" />
<cfset Reactor = arguments.ReactorFactory />
<cfreturn this />
</cffunction>
And a method createGateway():
<cffunction name="createGateway" access="public" output="false" returntype="any">
<cfargument name="name" type="string" required="true" />
<!--- if the Object Gateway doesn't exist in the application scope, instantiate it--->
<cfparam name="application.#arguments.name#Gateway" default=#evaluate("Reactor.createGateway(""" & arguments.name & """)")# />
<cfreturn evaluate("application." & arguments.name & "Gateway") />
</cffunction>
It seems solid to me and seems to work pretty dang well, but if anyone sees any holes in it, don't hold back. :)
~Dave
On 3/1/06, Sean Corfield <[EMAIL PROTECTED]> wrote:
On 3/1/06, Dave Shuck <[EMAIL PROTECTED]> wrote:
> I have created a MachII plugin that creates a Reactor Gateway factory
> property so that the first time a particular gateway is needed in my
> application it creates it, and is then referenced any time in the
> application. This works really smoothly, I was planning to do the same
> thing with my DAO, but I wanted to make sure that I wasn't going to run into
> any problems with overwriting some state that it held. Is this a safe thing
> to do?
Well, if Reactor's code is fully thread-safe then, yes, it's OK.
I just had a look and noticed that in
reactor.base.abstractGateway.getByQuery(), the loop variable x is not
var-declared so it's not currently thread safe. I'd class this as a
bug - I'm sure Doug intended the code to be fully thread-safe.
The DAO code looks thread safe as far as I can tell.
Interesting question tho' - Doug, was it your intention that a DAO and
a gateway could be created once and stored in application scope?
--
Sean A Corfield -- http://corfield.org/
Got frameworks?
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/
--
~Dave Shuck
[EMAIL PROTECTED]
www.daveshuck.com -- Reactor for ColdFusion Mailing List -- [email protected] -- Archives at http://www.mail-archive.com/reactor%40doughughes.net/

