Announcement Announcement Module
No announcement yet.
interceptor executed too many times - why? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • interceptor executed too many times - why?


    We have a business logic bean 'simpleBean'
    We need to add an advice 'simpleAdvice' to this bean - so we added a 'simpleAdvice' bean.
    We also need a pointcut advisor because we don't want the advice triggered on every method. So we added the 'simplePointcutAdvisor' bean, referencing the 'simpleAdvice' bean.
    Then we created a bean 'simpleBeanProxy' using ProxyFactoryBean and gave it the 'simplePointcutAdvisor' in the interceptors list.

    The problem is:

    It works 100% OK on JUnit tests - advice is executed OK.

    But when we use 'simpleBeanProxy' from our 'Wicket' page (which defines it as @SpringBean) the advice is executed TWICE.

    We also noticed that even if 'simpleBeanProxy' has an EMPTY interceptors list, the advice still gets executed. This might suggest we have an 'autoProxy' factory defined somewhere in the context files, but after chekcing that - we are certain there is no autoProxy defined anywhere.

    Also, we tried specifying the 'simpleAdvice' as the interceptor instead of the advisor. In this case, it does not get executed twice, but then we don't get the added benefit of the the pointcut advisor - so this is not an valid option for us.

    Another strange behavior is that when we added (just for debugging) another proxy between 'simpleBeanProxy' and the original 'simpleBean', the advice was executed 3 times!!

    Any ideas?

  • #2
    Post your configuration please. Please remember to use the [ code][/code ] tags.


    • #3
      Here's the security context xml:

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns=""
      <!-- We define a proxy the the core logic bean which is supposed to filter results from methods-->
      <!-- here we create a proxy to the core logic bean (which appears elsewhere in the context) -->
      	<bean id="logicBeanSecured"
      		<property name="target">
      			<ref bean="logicBean" />
      		<property name="proxyInterfaces">
      		<property name="interceptorNames">
      <!-- The filter interceptor is in charge of filtering results of method after invoking them -->
      	<bean name="filterInterceptor"
      <!-- The pointcut advisor simply checks if the method has a @Filter annotation -->
      	<bean id="filterAdvisor"
      			<ref bean="filterInterceptor" />

      Note that everything works OK when we test the beans in JUNIT, the problem only occurs when using the beans from a Wicket Page (using the '@SpringBean' annotation.

      THANKS for your help!


      • #4
        Just a small follow up:
        The issue was resolved.
        I used an advisor bean after all, extending StaticMethodMatcherPointcutAdvisor
        and having each advisor bean use it as parent bean.
        BUT - there was another problem, where if an xfire web service used a service bean which utilised the proxied bean, we would still get the call twice. Weird? yes. But finally we managed to resolve it by adding lazy-init=true to the service beans, which for some reason solved this issue.