Tuesday, 17 September 2013

How to check condition in "ref" attribute in Spring

How to check condition in "ref" attribute in Spring

I'm new to Spring. Just wondering, is it possible to check condition
within the "ref" attribute as follows?
<bean id="dbInfo" class="DatabaseProperties"
factory-method="initDatabaseInformation"/>
<bean id="b1" class="someClass" >
<property name="prop1" ref="#{ dbInfo.isValidUser? 'bean2' : 'bean3' }"
</bean>
<bean id="bean2" class="someClass1" >
</bean>
<bean id="bean3" class="someClass2" >
</bean>
I'm getting BeanCreationException by doing above. What would be the best
practice to do so?

No comments:

Post a Comment