without even looking at the code, this is probably because of finnicky
auto-wiring code in the framework (we need to make sure it doesn't
autowire beans unless told to, which I don't think is the case right
now).

the constructor-arg vs. property debate is an old one - and it's
mostly stylistic. Yes, you can't have circular dependencies if you use
constructor-args. Yes, using setter-methods leaves a situation where
you could have an object created which doesn't have its dependencies
satisfied. That's why we support both! My only real advice is that you
should stick to one approach (within a given project/codebase).

yes I'm alive (sorta)

-Dave

On 4/5/06, Sean Corfield <[EMAIL PROTECTED]> wrote:
> On 4/5/06, Matt Williams <[EMAIL PROTECTED]> wrote:
> > I am able to duplicate Brian's issue using stable release 0.5. If I use
> > constructor-arg to pass a bean, and have a private setter for that bean, it
> > throws the error saying "The method 'setPersonGateway' could not be found in
> > component".
>
> OK, I have a small test case that shows that if ColdSpring is told to
> run a constructor and also finds that there is a public setter, it
> calls the setter *as well*.
>
> Here's the example:
>
> === test/cs/Application.cfc ===
> <cfcomponent>
>        <cfset this.name = "cs_tests" />
> </cfcomponent>
>
> === test/cs/cs.xml ===
> <beans>
>        <bean id="stuff" class="test.cs.stuff">
>                <constructor-arg name="something">
>                        <ref bean="thing" />
>                </constructor-arg>
>        </bean>
>        <bean id="thing" class="test.cs.thing" />
> </beans>
>
> === test/cs/index.cfm ===
> <cfset cs = 
> createObject("component","coldspring.beans.DefaultXmlBeanFactory").init()
> />
> <cfset cs.loadBeans(expandPath("cs.xml")) />
> <cfset stuff = cs.getBean("stuff") />
> <cfoutput>
>        <p>#stuff.getLog()#</p>
> </cfoutput>
>
> === test/cs/stuff.cfc ===
> <cfcomponent>
>        <cfset variables.log = arrayNew(1) />
>        <cffunction name="init" returntype="stuff" access="public"
> output="false">
>                <cfargument name="something" type="thing" required="true" />
>                <cfset arrayAppend(variables.log,"init() called") />
>                <cfreturn this />
>        </cffunction>
>        <cffunction name="setThing" returntype="void" access="public"
> output="false">
>                <cfargument name="thing" type="thing" required="true" />
>                <cfset arrayAppend(variables.log,"setThing() called") />
>                <cfset variables.thing = arguments.thing />
>        </cffunction>
>        <cffunction name="getLog" returntype="string" access="public"
> output="false">
>                <cfreturn arrayToList(variables.log) />
>        </cffunction>
> </cfcomponent>
>
> === test/cs/thing.cfc ===
> <cfcomponent>
> </cfcomponent>
> --
> Sean A Corfield -- http://corfield.org/
> Got frameworks?
>
> "If you're not annoying somebody, you're not really alive."
> -- Margaret Atwood
>
>

Reply via email to