Jul 1st, 2005, 09:46 AM
I am having trouble getting the BeanNameAutoProxyCreator to work. When I configure a simple intreceptor with the ProxyBeanFactory it works fine, but when I attempt to do the same thing with the BeanNameAutoProxyCreator my bean is never proxied and the advice is never applied. I am not sure what I am doing wrong. Here is a portion of my configuration.
<bean id="FullBookService" class="com.fmr.fiis.ws.fullbook.facade.CWsIPFullBo okFacadeImpl"/>
<bean id="performanceThreshholdInterceptor" class="com.fmr.fiis.ws.fullbook.aop.CWsPerformance Interceptor">
<bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
Jul 1st, 2005, 10:42 AM
I found the Problem
I failed to call the refresh() method when creating the application context and loading the bean definitions. Apparently this is necessary for auto proxy functions.
Jul 1st, 2005, 11:13 AM
Re: I found the Problem
You shouldn't need to explicitly call refresh on the applicationContext (it is automatically called in the ApplicationContext constructor unless you specified false on one of the arguments).
Originally Posted by rjmoran68
Jul 1st, 2005, 11:21 AM
Thanks for the response
I create the application context as follows:
GenericApplicationContext ac = new GenericApplicationContext();
//Create an XML Bean Definition Reader
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ac);
//Load The Bean Definitions
//Refresh The Context
Perhaps I should a different constructor for the context. As is, it will not work unless I explicitly call refresh().
Jul 1st, 2005, 11:33 AM
Re: Thanks for the response
Looking at the code in GenericApplicationContext, you're right; you need to call refresh since it won't do it automatically.
Why not use:
final BeanFactory beanFactory = new ClassPathXmlApplicationContext(appContextFile);
final BeanFactory beanFactory = new FileSystemXmlApplicationContext(appContextFile);
This will cut your lines of code to one line.
Jul 1st, 2005, 11:37 AM
re: BeanNameAutoProxyCreator Issue
I will give that a try. Thanks for the help!