|
From: Kopylenko, D. <dko...@ac...> - 2003-11-20 01:17:25
|
As to your first problem, you would need to create a new instance of the BeanFactory Consider the following piece of code (taken from EnterpriseServices.createInvokerInterceptor() ): // Infinite cycle: tries to create the bean if we don't use a different factory ListableBeanFactoryImpl bf2 = new ListableBeanFactoryImpl(); bf2.registerBeanDefinition(beanName, definition); cpii.setBeanFactory(bf2); ...where cpii is the reference of type AbstractPoolingInvokerInterceptor which extends PrototypeInvokerInterceptor I guess this is what you need. Dmitriy. -----Original Message----- From: Rajeev Kaul To: spr...@li... Sent: 11/19/2003 7: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="prototypeBean" class="xyz.BusLogicBean" singleton="false"> <property name="count"><value>10</value></property> </bean> <bean id="prototypeInvokerInterceptor" class="org.springframework.aop.interceptor.PrototypeInvokerInterceptor"> <property name="targetBeanName"><value>prototypeBean</value></property> </bean> <bean id="prototype" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="interceptorNames"><value>prototypeInvokerInterceptor</value></prop erty> </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="prototypeBean" class="xyz.BusLogicBean" singleton="false" proxy="prototype"> <property name="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 ----- From: Rajeev Kaul <mailto:Ra...@cu...> To: spr...@li... <mailto:spr...@li...> 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). Rajeev Kaul |