if you really, really, really
don't have the ability to modify your bean to implement BeanFactoryAware, you can create a bean that implements BeanFactoryAware and then injects the BeanFactory it receive into your bean (lot of indirections!!!)
Code:
<-- MySetterBean implements BeanFactoryAware -->
<bean name="mySetter" class="MySetterBean">
<property name="myBean">
<ref local="myBean" />
</property>
</bean>
<-- My initial Bean -->
<bean name="myBean" class="MyBean"/>
public class MySessterBean implements BeanFactoryAware {
...
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
myBean.setSomeProperty(beanFactory);
}
hhmm, one last thing, If setBeanFactory is fired before setMyBean (I am not sure of the order), you will need to implement InitializingBean and use afterPropertiesSet to inject the BeanFactory into your bean.