I ran into a problem in class ProxyFactoryBean,
We want to get the class name targetBean ProxyFactoryBean.
When we call getTypeon BeanFactory, giving the name bean, it always returns as null.
Our Java Code
public class TestSpring {
public static void main(String args[]){
TestSpring ts = new TestSpring();
ts.process();
}
private void process() {
BeanFactory factory = new XmlBeanFactory(new FileSystemResource("E:\\beans.xml"));
Class c = factory.getType("scor.imagedev.action.imageDevServerTaskActions");
System.out.println(c);
}
}
Our configuration file is as follows:
<bean id="scor.actionProxyTemplate" class="org.springframework.aop.framework.ProxyFactoryBean" abstract="true" >
<property name="proxyTargetClass" value="true" />
</bean>
<bean id="scor.imagedev.action.imageDevServerTaskActions" parent="scor.actionProxyTemplate" scope="prototype">
<property name="target">
<bean class="test.spring.Foo"/>
</property>
</bean>
Some of the other things I want to add here.
- If we create a bean as a singleton, it works. But in our case, we want it to be a prototype.
- We must use
BeanFactory.getType(<beanName>). This is our basic infrastructure. We cannot change our basic structure. - Can
targetSourcesolve the problem? I tried, but it is useless. Perhaps I used it incorrectly. - I am using Spring 2.0.6.
Relationship Ankit