Yep.  That sounds exactly right. 

I did discover that if I turned autowiring on (byName in this case) for
the subClasses then they instantiate correctly. (Well, sort of, if I
want the mockObjects injected I have to explicitly define those...) This
makes sense since "setFoo()" is being called when the bean is loaded.

I had turned global autowiring off because I just read on the Mach-II
group that there can be a substantial performance hit, so I'll just do
it on a case by case basis.

It still seems like one should be able to define a base class and
inherit from it with properties intact, but there may be something I'm
just not "getting" about the Coldspring paradigm.  

For now, I think autowiring will work in those cases where I'm using
inheritance and I'll explicitly define my mock objects in my unit test
xml.

Thanks for the link. It validated my confusion and pointed me in the
direction of a workaround.

Oh, and the version I quoted originally was my Mach-II version, not
Coldspring. I'm using CS 1.0.

anthony

-----Original Message-----
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Doug Boude
Sent: Monday, June 11, 2007 1:09 PM
To: [email protected]
Subject: [coldspring-dev] Config/Inheritance Question

Anthony,
it sounds like you're running into the same exact thing that I did a
while back. If so, I'd say that Coldspring is behaving as it should.
See if this sounds at all familiar:
http://www.dougboude.com/blog/1/2007/03/Coldspring-automagic-lesson.cfm

Doug  :0)

On 6/11/07, Anthony Israel-Davis <[EMAIL PROTECTED]> wrote:
>
>
>
> I'm running into a problem and I don't know if it's a problem in my 
> code or a misunderstanding about how the Coldspring beanfactory wires
up components.
> I'm using version 1.1.1.
>
> I have two subclasses that use components that are composed into the 
> base class. I'm unit testing using CFCUnit, but my tests are returning

> errors saying "ComposedClassA is undefined in variables." despite a 
> setComposedClassA method in the base class.
>
> My bean definition looks something like this:
>
> <beans>
>         <bean id="ComposedClassA" class="path.to.ComposedClassA" />
>         <bean id="ComposedClassB" class="path.to.ComposedClassB" />
>         <bean id="MockComposedClassA"
class="path.to.MockComposedClassA" />
>         <bean id="MockComposedClassb"
class="path.to.MockComposedClassB" />
>         <bean id="BaseClass" class="path.to.BaseClass">
>                 <property name="ComposedClassA">
>                         <ref bean="MockComposedClassA"/>
>                 </property>
>                 <property name="ComposedClassB">
>                         <ref bean="MockComposedClassB"/>
>                 </property>
>         </bean>
>         <bean id="SubClassA" class="path.to.SubClassA"/>
>         <bean id="SubClassB" class="path.to.SubClassB" /> </beans>
>
> There are getters and setters in BaseClass for ComposedClass(A-B), so 
> my question is when I call local.beanFactory.getBean('SubClassA') 
> (which extends BaseClass) does Coldspring call the BaseClass' setters?

> It seems to not call inherited setters, but if, in the config file, I 
> put the properties in SubClassA it configures the bean correctly.
>
> So am I doing something wrong or is Coldspring performing as expected?

> I couldn't find anything in the documentation or in the forums 
> specifically about this, so any help would be appreciated.
>
> Thanks,
> anthony




Reply via email to