|
From: Rajeev K. <Ra...@cu...> - 2003-11-20 19:04:33
|
I have implemented this in my version of the spring framework. If there =
is interest, I will be happy to submit the code.
----- Original Message -----=20
From: Rajeev Kaul=20
To: spr...@li...=20
Sent: Wednesday, November 19, 2003 4:33 PM
Subject: Re: [Springframework-developer] AutoProxyCreator problem
I am thinking of a solution for condensing the verbose configuration =
(shown below) for prototype business logic beans I am using in my =
application. A shared controller instance (singelton) creates the =
business logic bean. However the business logic bean must be =
instantiated per each thread that runs through the shared controller. I =
have been using the configuration shown below:
<bean id=3D"prototypeBean" class=3D"xyz.BusLogicBean" =
singleton=3D"false">=20
<property name=3D"count"><value>10</value></property>
</bean>
<bean id=3D"prototypeInvokerInterceptor" =
class=3D"org.springframework.aop.interceptor.PrototypeInvokerInterceptor"=
>=20
<property =
name=3D"targetBeanName"><value>prototypeBean</value></property>
</bean>
<bean id=3D"prototype" =
class=3D"org.springframework.aop.framework.ProxyFactoryBean">=20
<property =
name=3D"interceptorNames"><value>prototypeInvokerInterceptor</value></pro=
perty>
</bean>
As you can see this is very verbose, especially if you have a lot of =
these business logic beans in your application. I tried using a derived =
version of BeanNameAutoProxyCreator to solve this, but ran into =
problems. I would like to replace this configuration with something =
shown below:
<bean id=3D"prototypeBean" class=3D"xyz.BusLogicBean" =
singleton=3D"false" proxy=3D"prototype">=20
<property name=3D"count"><value>10</value></property>
</bean>
This would involve adding a "PROXY" attribute which would specify the =
type of proxy interceptor desired for the bean. For example, =
"prototype" would mean ProxyFactoryBean with =
PrototypeInvokerInterceptor, "default" would mean ProxyFactoryBean with =
InvokerInterceptor, etc. In loadBeanDefinition() method of the =
XmlBeanFactory class, the supporting proxy classes (ProxyFactoryBean =
and PrototypeInvokerInterceptor) could be automatically generated and =
registered.
Any suggestions, comments, ...?
Rajeev
----- Original Message -----=20
From: Rajeev Kaul=20
To: spr...@li...=20
Sent: Tuesday, November 18, 2003 1:29 PM
Subject: [Springframework-developer] AutoProxyCreator problem
I have been trying to use BeanNameAutoProxyCreator class (I noticed =
there are no test cases for it) to create proxies for "prototype" =
business objects. I extended the BeanNameAutoProxyCreator class to use =
the PrototypeInvokerInterceptor in the "createInvokerInterceptor()" =
method. However, this results in an infinite loop, as the =
PrototypeInvokerInterceptor calls the beanFactory getBean() method which =
in turn triggers the beanPostProcessor and the cycle repeats endlessly.
Any suggestions on getting around this problem?
It would have been better, if the BeanNameAutoProxyCreator class was =
designed to take invokerInterceptor as a property, which could be =
specified in the configuration, instead of having to subclass it to use =
other invokerInterceptor(s).=20
Rajeev Kaul
|