Results 1 to 6 of 6

Thread: BeanNameAutoProxyCreator Issue

Hybrid View

  1. #1
    Join Date
    Jul 2005
    Posts
    16

    Default BeanNameAutoProxyCreator Issue

    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.

    <beans>
    <bean id="FullBookService" class="com.fmr.fiis.ws.fullbook.facade.CWsIPFullBo okFacadeImpl"/>

    <bean id="performanceThreshholdInterceptor" class="com.fmr.fiis.ws.fullbook.aop.CWsPerformance Interceptor">
    <constructor-arg>
    <value>3000</value>
    </constructor-arg>
    </bean>

    <bean id="autoProxyCreator" class="org.springframework.aop.framework.autoproxy .BeanNameAutoProxyCreator">
    <property name="interceptorNames">
    <list>
    <value>performanceThreshholdInterceptor</value>
    </list>
    </property>
    <property name="beanNames">
    <list>
    <value>FullBookService</value>
    </list>
    </property>

    </bean>

  2. #2
    Join Date
    Jul 2005
    Posts
    16

    Default 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.

  3. #3
    Join Date
    Aug 2004
    Posts
    107

    Default Re: I found the Problem

    Quote Originally Posted by rjmoran68
    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.
    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).

    Dino

  4. #4
    Join Date
    Jul 2005
    Posts
    16

    Default 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
    xmlReader.loadBeanDefinitions(new InputStreamResource(input));

    //Refresh The Context
    ac.refresh();

    Perhaps I should a different constructor for the context. As is, it will not work unless I explicitly call refresh().

  5. #5
    Join Date
    Aug 2004
    Posts
    107

    Default 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);

    or
    final BeanFactory beanFactory = new FileSystemXmlApplicationContext(appContextFile);

    This will cut your lines of code to one line.

    Dino

  6. #6
    Join Date
    Jul 2005
    Posts
    16

    Default re: BeanNameAutoProxyCreator Issue

    I will give that a try. Thanks for the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •