I have parent/child bean,
And Java code to retrieve child bean based on bean id,Code:<bean id="abstractATG" class="poll.atg.AbstractATG" abstract="true" > </bean> <bean id="veederRootATG" parent="abstractATG" > <property name="atgType"><value>test</value></property> </bean> public class AbstractATG { private String atgType = null; /*ignore its setter/getter methods here*/ }
But I always got error about no child(concrete) bean found,Code:public class AtgManagerImpl implements ApplicationContextAware { private ApplicationContext applicationContext = null; public <V> V getAtgById(String beanId) { V atg = (V)getApplicationContext().getBean(beanId); return atg; } public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext=applicationContext; } public ApplicationContext getApplicationContext() { return applicationContext; } }
appfuse] INFO [http-8080-Processor24] ExecuteQuery.info(51) | Exec[0]: AtgManager.getAtgById()
[appfuse] WARN [http-8080-Processor24] ExecuteQuery.warn(67) | Method execution failed:
org.springframework.beans.factory.NoSuchBeanDefini tionException: No bean named 'veederRootATG' is defined
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.getBeanDefinition(DefaultListab leBeanFactory.java:355)
I am using Spring 2.0 and tracked code in getBean(String, Class, final Object[]) of AbstractBeanFactory.java. Problem is in that method code tried to retrieve child bean from singletonCache as below, but neither parent bean or child bean exists in such cache.
My question is how I can configure parent/child bean so they can be located in singletonCache? What class should I extend for AbstractATG? Thanks!Code:public Object getSingleton(String beanName) { synchronized (this.singletonCache) { return this.singletonCache.get(beanName); } }


Reply With Quote
. Thanks for pointing that out btw.