Is possible for a bean to have mutiple parents in Spring?
I have a service that I want to inject into multiple client classes. I don't want to add the property to the 开发者_开发问答bean definitions of all the classes that need this service so I created an interface with a setter method which is implemented by each of the clients classes. In the xml config, I have one abstract bean for the interface which is wired to receive the service as a property. The idea is for client bean to have the bean for the interface as a parent. However many of the clients already have parents. Is it possible for a bean to have multiple parernts is spring - this seems like a reasonable thing to do as a class can implement multiple interfaces in java.
Sounds like what you actually want to do is to implement a BeanPostProcessor. Such component get to inspect any bean that is created in the spring context and sense the presence of the interface, and in that case set the service you need.
精彩评论