Announcement Announcement Module
Collapse
No announcement yet.
BeanNameAutoProxyCreator not active ??? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • BeanNameAutoProxyCreator not active ???

    Hello,

    I try to implement a simple performance loggigng profiler in my spring app by autoproxying, but nothing happens. I have the followowing configuration, but if I run the application ... nothing happens. Can anybody help me?

    Code:
    ....
    <bean id="profilingLogger" class="de.idon.www.achenwall.aop.interceptors.ProfilingInterceptor" />
    
        <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
    
            <property name="beanNames">
                <value>*</value>
            </property>
    
            <property name="proxyTargetClass">
                <value>true</value>
            </property>
    
            <property name="interceptorNames">
                <list>
                    <value>profilingLogger</value>
                </list>
            </property>
    
        </bean>
    ...
    And my logging profiler has the following code, but it seems that it is never executed because BeanNameAutoProxyCreator is never loaded. Dow I have to start it anywhere?

    Code:
    public class ProfilingInterceptor implements MethodInterceptor&#123;
    
        protected final Log logger = LogFactory.getLog&#40;getClass&#40;&#41;&#41;;
    
        public Object invoke&#40;MethodInvocation methodInvocation&#41; throws Throwable &#123;
    
            // start time
            long start = System.currentTimeMillis&#40;&#41;;
    
            System.out.println&#40;"hallo"&#41;;
    
            // execute method
            Object methodResult =  methodInvocation.proceed&#40;&#41;;
    
            // end time
            long end = System.currentTimeMillis&#40;&#41;;
    
            // log
            logger.info&#40;
                methodInvocation.getMethod&#40;&#41;.getName&#40;&#41;
                    + " - Execution time&#58; "
                    + &#40;end - start&#41;
                    + " ms"
            &#41;;
    
            // return executed method object
            return methodResult;
        &#125;
    &#125;
    Everything else works perfectly and all beans are executed as whished, but the autoproxy seems not to work :-((

    I am using the newset Spring release.

    Thanks,

    Andreas Bednarz
    Hannover

  • #2
    The mechanism of autoproxy works on basis of bean post processors. The bean post processors are automatically reconized only by an application context. if you are using a simple bean factory you have to configure the BeanNameAutoProxyCreator by hand by using the method addBeanPostProcessor of your factory.

    Comment

    Working...
    X