-
Sep 17th, 2009, 03:34 PM
#1
Creating Sub-Container in XML
Hi there,
i have been using many other IoC-Containers with nice features some time ago but following the mainstream I have switched to springframework after common annotations have been supported and XML-programming-style pain has ended.
Now I am missing a powerful feature. A typical IoC-Container has the concept of creating sub-containers. Now what I would like to do is to create a sub-container within my XML configuration and this way be able to override a bean when importing some other XML-configuration.
To make an example:
I have interface A with AImpl
Then interface B with BImpl that requires an instance of A via @Resource.
therefore I have b.xml as
<beans>
<bean id="A" class="AImpl"/>
<bean id="B" class="BImpl"/>
</beans>
Easy so far.
Now I have C and CImpl that requires an instance of B via @Resource.
But I also have a AImpl2 that extends AImpl and want to use this
for my CImpl.
What I want is something like:
<beans>
<bean id="A" class="AImpl2"/>
<bean id="C" class="CImpl"/>
<!-- Indicates that beans is a sub-container that inherits
from this parent -->
<parent>
<import resource=".../b.xml"/>
</parent>
</beans>
My expectation would be that in the resulting container there is
only one bean with id "A" and only one bean that is instance of A
and therefore @Resource injection is unique but will receive AImpl2 rather than AImpl.
Maybe this can already be expressed in some way.
Or somebody can give me a hint how to solve my problem in another way.
Or it could help as an inspiration for a new feature in further spring versions.
What I am not keen on is a solution that requires my code to depend on springframework.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules