passing the beanfactory into managed objects

1 view
Skip to first unread message

Chris Blackwell

unread,
Dec 30, 2008, 6:48:30 AM12/30/08
to ColdSpring-Users
Hi,

I'm having a little conversation with myself over on the reactor list
http://groups.google.com/group/reactor-users/browse_thread/thread/d4235d5da06c9740

It boils down to this, do i

1) create setter/getters in my reactor objects for beans that i need
to use in them and then use AOP to intercept the createWhatever()
methods and autowire the objects before returning them. This doesn't
couple my reactor objects to coldspring, although they would still
need to be managed in some way to get the dependencies injected before
they were usable

2) create a dependency on the beanfactory within my reactor objects by
using _getBean() everywhere. This is simpler, and may well perform
better although i have not tested that.

I'm using this with MG:G so cs isn't likely to disappear, but all this
plumbing is happening in an application level parent bean factory.

Anyone care to offer an argument in favor of either option?

Cheers, Chris

Brian Kotek

unread,
Dec 30, 2008, 8:08:22 AM12/30/08
to coldspri...@googlegroups.com
It sounds like my BeanInjector component would handle this? http://coldspringutils.riaforge.org/

Chris Blackwell

unread,
Dec 30, 2008, 8:44:24 AM12/30/08
to coldspri...@googlegroups.com
Hi Brian,

It does indeed, and that's exactly what i am using along with some AOP in option 1.  What i'm trying to get my head around is that in this post loads of the CS team were saying don't inject the beanfactory into a managed object, inject the beans it needs to do its job.  Which i can understand.

But at some point, coldspring gained the ability to wire itself into any bean with a setBeanFactory() method. Reactor makes use of this and provides a _getBean() method in all of its objects so i could dispense with the BeanInjector and all the AOP and just use this to get beans i need in my Records.

So is Reactor encouraging me to do something i shouldn't, or should i stick with my original plan of using your BeanInjector and AOP to manage the dependencies on my Reactor objects.. Was just wondering if anyone had thoughts either way.. i'm sure they do :)


2008/12/30 Brian Kotek <bria...@gmail.com>

Tom Chiverton

unread,
Jan 7, 2009, 11:43:12 AM1/7/09
to coldspri...@googlegroups.com
2008/12/30 Chris Blackwell <ch...@team193.com>:

> But at some point, coldspring gained the ability to wire itself into any
> bean with a setBeanFactory() method.

So called 'bean factory aware', aye.

> Reactor makes use of this and provides
> a _getBean() method in all of its objects so i could dispense with the
> BeanInjector and all the AOP and just use this to get beans i need in my
> Records.

I think this was done with the best of intentions, but, yes...

> So is Reactor encouraging me to do something i shouldn't

:-)
And we can't change it in Reactor now.

--
Tom

Reply all
Reply to author
Forward
0 new messages