You have many options. Your factory (the CFC that creates CFCs) can be
injected with the dependency by CS and then set that into the objects
it creates:
<cfcomponent name="a factory">
<cffunction name="init" returntype="SignMeUp.model.BlockService"
output="false" access="public">
<cfreturn this/>
</cffunction>
<cffunction name="setSomeService">
<cfargument name="someService"/>
<cfset variables.someService = arguments.someService/>
</cffunction>
<cffunction name="createSomeObject">
<cfset var newObject =
createObject("component","someObject").init()/>
<cfset newObject.setSomeService(variables.someService)/>
<cfreturn newObject/>
</cffunction>
</cfcomponent>
You could also use CS's factory-bean/factory-method features, but it
depends on what you are doing with the objects your factory creates.
Hope that helps,
Dave
On 10/2/06, Ryan Miller <[EMAIL PROTECTED]> wrote:
forgive me if this is in the docs or covered by the mailing list... I
couldn't find anything on this.
We have a function inside a CFC that needs to create multiple instances of
another CFC. Each of these instances needs a reference to another object
which is a singleton. We've been setting all our service-type CFCs in CS,
so the dependence of these multiple unique instances on the singleton is
handled, but putting
application.serviceFactory.getBean('someCFC') inside a CFC
to generate these unique instances doesn't seem like the right way to go.
Any ideas?