Announcement Announcement Module
Collapse
No announcement yet.
Combine execution() and bean() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Combine execution() and bean()

    Hi,

    Am trying to combine execution and bean in a pointcut.
    With the code below, the aspect is fine with Endpoints but not getting called for the Dao's.

    Code:
    <aop:pointcut id="samplePointCut" expression="execution(* com.xxx.yyy..*Endpoint.handle*(..)) or bean(*Dao)" />
    Is it valid to combine execution & bean ?

    Thanks,
    Aravind

  • #2
    This is valid and should have worked. Please show more details to check if you are hitting a bug.

    Also, which version of Spring and AspectJ you are using?

    -Ramnivas

    Comment


    • #3
      Am using aspectjweaver-1.6.3 & Spring -2.5.6.

      Code:
      <!-- Aop Config -->
      <bean id="performanceAspectBean" class="com.xxx.yyy.aspect.PerformanceAspect" />
      
      <aop:config>
      	<aop:pointcut id="samplePointCut" expression="execution(* com.xxx.yyy..*Endpoint.handle*(..)) or bean(*Dao)" />
      	
      	<aop:aspect id="performanceAspect" ref="performanceAspectBean" order="11">
      		<aop:around pointcut-ref="samplePointCut" method="logExecutionTime" />
      	</aop:aspect>
      </aop:config>
      
      
      
      
      <bean id="sampleFunction" class="com.xxx.yyy.function.SampleFunctionImpl">
      		<property name="sampleDao" ref="sampleDao" />
      </bean>		
      
      
      <bean id="sampleDao" class="com.xxx.yyy.dao.SampleDaoImpl">
      ....
      ....
      </bean>

      For every Endpoint & Dao call, am expecting 'performanceAspectBean' to be invoked.

      Right now the behavior is fine for the endpoint; but for sampleDao, the performanceAspectBean is not getting invoked.

      Comment


      • #4
        I have seen the same behaviour where if you try to combine bean() and execution in the XML configuration it does not work but if you move it to use annotation it does. You can try annotation-based configuration and see if that works for you as well.

        Comment

        Working...
        X