|
From: <jue...@we...> - 2004-04-28 15:17:40
|
Hi Mike,
That's indeed a fairly typical scenario. I've considered this =
repeatedly, but haven't come to any conclusion yet. "Hiding" certain =
beans in a generic fashion is not as simple as it might seem: After all, =
at least the transactional proxy needs to reference its target, so the =
target can't be completely hidden.
When autowiring bean properties, you could use AUTOWIRE_BY_NAME as =
alternative - matching a "spaceManager" property to a "spaceManager" =
bean. However, with constructors, autowiring constructor arguments by =
type remains the only option.
Note that when auto-proxying targets, for example with =
BeanNameAutoProxyCreator, there's just one visible bean: The target =
automatically gets wrapped with a proxy. However, this is just =
appropriate for transaction demarcation if all your targets stick to the =
same method naming pattern; else, all those different transaction =
attributes in a single TransactionAttributeSource will get messy.
Juergen
-----Original Message-----
From: spr...@li...
[mailto:spr...@li...]On Behalf
Of Mike Cannon-Brookes
Sent: Wednesday, April 28, 2004 4:43 PM
To: <spr...@li...>
<spr...@li...>
Subject: [Springframework-developer] Auto-wiring by type - too many
instances when proxying?
Hey guys,
Just wondering how you get around this scenario.
We were playing around with autowiring today, specifically using the=20
ListableBeanFactory.autowire(Class,=20
AutowiringBeanFactory.AUTOWIRE_CONSTRUCTOR, false) method.
Now the problem is that if I have two beans of effectively the same=20
type (say SpaceManager) - the autowiring no longer works.
The reason we have two beans implementing SpaceManager interface is=20
that there's an implementation defined with all it's properties=20
('spaceManagerTarget') and then a transaction proxy factory bean=20
wrapping the impl with transaction attributes ('spaceManager'). I think=20
this is a fairly standard type of scenario.
However both are exposing the SpaceManager interface, hence the auto=20
wiring fails.
What to do? Has anyone else faced this problem?
I never access the 'spaceManagerTarget' from within my application, is=20
it possible to 'hide' this instance somehow?
Cheers,
Mike
--
ATLASSIAN - http://www.atlassian.com/
Confluence - the professional J2EE wiki - tried it yet?
http://www.atlassian.com/confluence/
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. =
Take an Oracle 10g class now, and we'll give you the exam FREE.=20
http://ads.osdn.com/?ad_id=3D3149&alloc_id=3D8166&op=3Dclick
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|