Hi
I am facing problem in ProxyFactoryBean
class,
We want to get the class name of the targetBean
of the ProxyFactoryBean
.
When we invoke getType
on BeanFactory
giving the bean name , it always return as null.
Our Java code is
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 that i want to add here.
- If we make the bean as singleton , it works. But in our case we want it to be a prototype.
- We have to use
BeanFactory.getType(<beanName>)
. This is our base framework make a call. We cannot change in our base framework. - Will
targetSource
can solve the problem? I tried it but it is of no use. May be I used it incorrectly - I am using Spring 2.0.6.
Regards Ankit