Announcement Announcement Module
Collapse
No announcement yet.
changing pointcut from service layer to controller layer issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • changing pointcut from service layer to controller layer issue

    Hey everyone

    I am using AOP for logging purporses. currently my pointcut is defined on the service layer which has a typical service interface/implementation structure.

    my pointcut is as follows

    Code:
    	@Pointcut("execution(* org.xyz.service.*.*(..))")
    	public void cut() {
    	}
    This works fine

    I am trying to change it so that i log my mvc controllers instead.
    I thought that the following syntax would work

    @Pointcut("within(* org.xyz.controller..*)")

    But when i use it, nothing happens, nothing gets logged anymore

    I even tried playing around with the execution(..) syntax with no luck

    Can someone please shed some light on if i am doing something wrong here ? sorry this is my first encounter with aop, so some of the concepts are still not clear, thanks for the help!

  • #2
    Have you tried the same pointcut signature as the service one?
    Code:
    @Pointcut("execution(* org.xyz.controller.*.*(..))")
    	public void cut() {
    	}
    How have configured your controllers?

    Comment


    • #3
      Originally posted by masterofpuppets View Post
      ...
      I am trying to change it so that i log my mvc controllers instead.
      I thought that the following syntax would work

      @Pointcut("within(* org.xyz.controller..*)")

      But when i use it, nothing happens, nothing gets logged anymore

      I even tried playing around with the execution(..) syntax with no luck

      Can someone please shed some light on if i am doing something wrong here ? sorry this is my first encounter with aop, so some of the concepts are still not clear, thanks for the help!
      The most probable answer is that the methods matched by the pointcut are self-calls, i.e. they are called from the same object. Feel free to read reference to get more on that - 6.6.1. Understanding AOP proxies.

      Comment


      • #4
        Originally posted by amin View Post
        Have you tried the same pointcut signature as the service one?
        Code:
        @Pointcut("execution(* org.xyz.controller.*.*(..))")
        	public void cut() {
        	}
        How have configured your controllers?
        Yes i did try that but it didnt work either, my controllers are simply configured through SimpleURLMapping in the xml file

        Code:
        <bean id="simpleUrlMapping"
        class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        	<property name="mappings">
        		<props>
        		<prop key="index.htm">homepageController</prop>
        ...
        ...
        </bean>
        
        <bean id="homepageController"
           class="org.xyz.controller.web.HomepageController">
           <property name="patientService" ref="patientService" />
        </bean>

        Originally posted by denis.zhdanov View Post
        The most probable answer is that the methods matched by the pointcut are self-calls, i.e. they are called from the same object. Feel free to read reference to get more on that - 6.6.1. Understanding AOP proxies.
        Thanks for pointing that out, i am going through that now chapter again .

        thanks!

        Comment

        Working...
        X