I had some similar requirements in the application I was building and finally resolved this by using a ContextSingletonBeanFactoryLocator.
The idea is to create a separate applicationcontext.xml file containing all the bean instances maintained by the factory class. The beanRefContext.xml would then refer to this xml file.
example :
beanRefContext.xml
Code:
<beans>
<bean id="properties-context"
class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg>
<list>
<value>/META-INF/properties-applicationContext.xml</value>
</list>
</constructor-arg>
</bean>
</beans>
properties-applicationcontext.xml
Code:
<beans>
<!-- Mapper implementation for the Party class -->
<bean id="partyPropertyMapper"
class="be.titan.hesperus.general.persistence.XMLPropertyMapper">
<constructor-arg>
<value>
/var/workspace/Hesperus/PropertyMaps/PartyProperties.xml
</value>
</constructor-arg>
</bean>
.....
And using this stuff within your code that requires the factory :
Code:
public void setPropertyMapper(String propertyMapper) {
// this method uses a Spring ContextSingletonBeanLocator
// for retrieving the propertyMapper to associate with this
// handler
BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance("/META-INF/beanRefContext.xml");
BeanFactoryReference bfr = locator.useBeanFactory("properties-context");
BeanFactory factory = bfr.getFactory();
this.setPropertyMapper((PropertyMapper) factory.getBean(propertyMapper));
bfr.release();
}
Hopes this is helpfull since I'm also rather new to Spring coming from an EJB background :lol: