Due to the discussion on CFINCLUDE inside component methods I've got to
rethink some things and a question began to buzz.

Firstly I had been using DB-specific includes (called dynamically based on a
"DSN.type" property) to handle multiple database engines in my app.  For
example the "DP_Session.save()" method could, depending on the DSN contained
in its parent "DP_App" component could call either the
"MSSQLServer2000/DP_Session_Save.cfm" or the
"MSAccess2000/DP_Session_Save.cfm" include.  These includes would contain
only the DB-specific code for the method.

In effect I was dynamically changing the method bodies depending on the
persistence layer being used.  It worked pretty well, but (considering the
issue with includes) was obviously not thread-safe.

I'm trying to determine the best(and thread safe) way to mimic this.  I've
come up with three potential solutions:

1) Create DB-Specific "Broker" CFCs for each component which are called
dynamically depending the DB-type.  So "DP_Session.cfc" could call
"MSSQLServer2000/DP_Session_Broker.cfc" or
"MSAccess2000/DP_Session_Broker.cfc".

I'd want to call just "DP_Session.save()", not "DP_Session.Broker.save()"
(although I suppose I could do the later) so it would require "Save()"
methods in both components (with one being a simple fa�ade).

Doing it this way (as opposed to "DP_Session.Broker.save()") would also mean
that I could call the component transiently... although I would be passing a
reference to the DP_Session instance for the data.

2) Create a dedicated DB-specific CustomTag (called via CFMODULE) for each
method or component.  This would be thread-safe, but CFMODULE is much slower
than using CFCs and seems to add quite a bit more complexity to the
situation.

3) (I think I can) Create my methods in a separate DB-specific file as a
full function definition (rather than just define the method bodies) then
cfinclude THAT as I would any function library.

Can this work?  Would such injected methods actually work the same as native
methods?  Would the result be thread safe?

This is, so far, the more attractive solution to me.  There's less
duplication than in the Broker CFC method and it doesn't mix metaphors and
add complexity like the Custom Tag method.

But will it work?

Any other options?

Thanks in advance,

Jim Davis



----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to