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

  • interceptor executed too many times - why?

    Hi,

    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.

    Comment


    • #3
      Here's the security context xml:

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:tx="http://www.springframework.org/schema/tx"
             xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
      				http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
      
      
      
      <!-- 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"
      		class="org.springframework.aop.framework.ProxyFactoryBean">
      		<property name="target">
      			<ref bean="logicBean" />
      		</property>
      		<property name="proxyInterfaces">
      			<value>com.acme.logic.Logic</value>
      		</property>
      		<property name="interceptorNames">
      			<list>
      				<value>filterAdvisor</value>
      			</list>
      		</property>
      	</bean>
      
      
      <!-- The filter interceptor is in charge of filtering results of method after invoking them -->
      	<bean name="filterInterceptor"
      		class="com.acme.security.aop.FilterInterceptor">
      	</bean>
      
      
      <!-- The pointcut advisor simply checks if the method has a @Filter annotation -->
      	<bean id="filterAdvisor"
      		class="com.acme.security.aop.FilterPointcutAdvisor">
      		<constructor-arg>
      			<ref bean="filterInterceptor" />
      		</constructor-arg>
      	</bean> 
      		
      	
      </beans>

      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!

      Comment


      • #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.
        Thanks

        Comment

        Working...
        X