Results 1 to 3 of 3

Thread: AspectJ with Spring MVC annotations

  1. #1
    Join Date
    Mar 2006
    Posts
    14

    Default AspectJ with Spring MVC annotations

    Hi all

    I am trying to intercept all calls to methods within net.myapp.web with

    Code:
        <bean id="securityInterceptor" class="net.myapp.web.SecurityInterceptor" />
        
    	<aop:config>
       		<aop:aspect id="securityAspect" ref="securityInterceptor">
          		<aop:pointcut id="securityPointCut" expression="within(net.myapp.web..*)"/>
          		<aop:before pointcut-ref="securityPointCut" method="intercept" />
       		</aop:aspect>
    	</aop:config>
    but none of them are intercepted. I am specifically looking to intercept net.myapp.web.Index which looks like this:

    Code:
    @Controller
    package net.myapp.web.page;
    
    @RequestMapping("/index.html")
    public class Index extends ControllerSupport {
    
    	@RequestMapping(method = RequestMethod.GET)
    	public ModelAndView prepareView() 
    	{
    		//do stuff
    	}
    }
    but the prepareView method is never intercepted, even though it does run.

    If I change my pointcut expression to
    Code:
    <aop:pointcut id="securityPointCut" expression="execution(* *(..))"/>
    then the intercept method (which only prints out a message) will run a bunch of times so there's nothing wrong with the basic setup.

    Any ideas why my controller method isn't being intercepted?

  2. #2
    Join Date
    Mar 2006
    Posts
    14

    Default

    I needed to declare the pointcut in my springmvc-servlet.xml, it apparently doesn't work in applicationContext.xml

  3. #3
    Join Date
    Mar 2006
    Posts
    14

    Default

    now that the SecurityInterceptor class intercepts all requests, how can I access the HttpServletRequest/Response in this specific class?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •