Injecteer
Dec 30th, 2005, 05:13 AM
Hi gurus :)
in my appContext.xml there's a factory method, that extracts a configuration object out of a DB.
<bean id="contentProvider" class="com.ect.ringBackTones.dao.ContentProviderDAO" factory-method="getEctContentProvider"/>
if the DB is empty, then the method naturally returns null. That causes the Spring's ApplicationContext to cry-out complaining about the exception and die:
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'contentProvider' defined in class path resource [applicationContextRBT.xml]: Factory method 'getEctContentProvider' on class [com.ect.ringBackTones.dao.ContentProviderDAO] returned null
of course, I can make sure, that the method returns a not-null dummy, but are there a respective Spring's functionality to ignore null-beans, so that the responsibility to validate such beans is shifted to the class, where the null gets injected?
ps. I tried to look for some clues in the docs, as well as in the forum but couln't dinf anything similar :confused:
in my appContext.xml there's a factory method, that extracts a configuration object out of a DB.
<bean id="contentProvider" class="com.ect.ringBackTones.dao.ContentProviderDAO" factory-method="getEctContentProvider"/>
if the DB is empty, then the method naturally returns null. That causes the Spring's ApplicationContext to cry-out complaining about the exception and die:
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'contentProvider' defined in class path resource [applicationContextRBT.xml]: Factory method 'getEctContentProvider' on class [com.ect.ringBackTones.dao.ContentProviderDAO] returned null
of course, I can make sure, that the method returns a not-null dummy, but are there a respective Spring's functionality to ignore null-beans, so that the responsibility to validate such beans is shifted to the class, where the null gets injected?
ps. I tried to look for some clues in the docs, as well as in the forum but couln't dinf anything similar :confused: