Why not use ColdSpring to inject the services you need?

Add setFooService() to your CFC and <property> to the ColdSpring
definition for that service.

Dependency Injection is what ColdSpring's all about.

Unless you are dynamically fetching services from ColdSpring, you
should never need a reference to it in your CFCs.

Sean

On Thu, Apr 8, 2010 at 5:42 PM, Nolan Erck <[email protected]> wrote:
> I've got a handful of Service Layer CFCs that all take your pretty standard
> set of arguments on the init() method:
>
> <cfargument name="userDAO" type="model.User.userDAO" required="true" />
> <cfargument name="userGateway" type="model.User.userGateway" required="true"
> />
>
> Once in a while I'll find that I'm in (for example) the UserService, and I
> want to fire off a method in one of the *other* Service CFCs.  Since all of
> them are wired up via ColdSpring, I could just do something like so, inside
> each Service CFC:
>
> <cfset foo = application.coldSpring.getBean( "someOtherService" ) />
>
> ....but that's breaking encapsulation.  Is there a was pass IN a reference
> to ColdSpring via the init() arguments?  This strikes me as probably a
> circular logic problem (how can ColdSpring be passed in as an argument if it
> hasn't finished initializing itself yet?), but I'm hoping there is a
> workaround.  Does that make sense?
>
> How do the rest of you access ColdSpring from within a Service Layer that
> itself was instantiated via ColdSpring?

-- 
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en.

Reply via email to