|
From: Ramin F. <aqu...@ya...> - 2007-02-24 06:31:25
|
Dear Spring team,
When it comes to a factoryBean like this :
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="lobHandler" ref="lobHandler"/>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/net/xxx</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<!-- connection options -->
<prop key="hibernate.c3p0.max_size">${hibernate.c3p0.max_size}</prop>
<prop key="hibernate.c3p0.min_size">${hibernate.c3p0.min_size}</prop>
...
</props>
</property>
...
</bean>
what I need to do neatly is
LocalSessionFactoryBean sessionFactoryBean = (LocalSessionFactoryBean) getApplicationContext().getBean("&sessionFactory");
So any xml automagic in the applicationContext.xml might not end up to a clearer way of resolving the bean itself in lieu of its factoryBean. I am sure that changing the BeanFactory interface and coming up with a new method like getBeanFromFactory(String factoryBeanName) is not an easy issue because of backward compatibility. But I know that this is the obscure code and I find Mr. Colin Yates' idea a good solution. If we are restricted, at least a more meaningful prefix can be a better solution.
All The Best,
Ramin Farhanian
|