title: How can I apply an aspect using annotations in Spring?
body: <p><strong>Update</strong>: I've found the Spring 2.x annotation-based Controllers are horrible for AOP security because you can't make assumptions about the method prototype due to the increased freedom in params and return values. Before 2.x you could intercept <em>handleRequest</em> and know the first param was an <em>HttpServletRequest</em> and the return value was a <em>ModelAndView</em>. This standard allowed you to write simple advices for every controller. Now methods mapped to requests can take anything and return Strings, ModelAndViews, etc.</p>
  
  <p><strong>Original Post</strong>: I have a set of existing aspects which implement AOPAlliance's MethodInterceptor running in Spring. They provide security for my webapp by intercepting .<em>handleRequest.</em> methods in the Controllers and either allowing execution or forwarding to a login page.</p>
  
  <p>With the new annotation-based controllers in Spring, the "handleRequest" method no longer needs to be implemented; the methods of the controller can be named whatever I want. This breaks my existing security model. So, how do I get from this:</p>
  
  <pre><code>    &lt;bean class="com.xxx.aspects.security.LoginAdvice" name="loginAdvice"&gt;
              &lt;property name="loginPath"&gt;
                      &lt;value&gt;/login.htm&lt;/value&gt;
              &lt;/property&gt;
              &lt;property name="authenticationService" ref="authenticationService" /&gt;
      &lt;/bean&gt;
  
      &lt;bean name="loginAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor"&gt;
              &lt;property name="advice" ref="loginAdvice" /&gt;
              &lt;property name="pointcut"&gt;
                      &lt;bean class="org.springframework.aop.support.JdkRegexpMethodPointcut"&gt;
                              &lt;property name="pattern"&gt;
                                      &lt;value&gt;.*handleRequest.*&lt;/value&gt;
                              &lt;/property&gt;
                      &lt;/bean&gt;
              &lt;/property&gt;
      &lt;/bean&gt;
  
      &lt;bean id="someProtectedController" class="org.springframework.aop.framework.ProxyFactoryBean"&gt;
              &lt;property name="target"&gt;
                      &lt;ref local="someProtectedControllerTarget" /&gt;
              &lt;/property&gt;
              &lt;property name="interceptorNames"&gt;
                      &lt;list&gt;
                              &lt;value&gt;loginAdvisor&lt;/value&gt;
                              &lt;value&gt;adminAdvisor&lt;/value&gt;
                      &lt;/list&gt;
              &lt;/property&gt;
      &lt;/bean&gt; 
  </code></pre>
  
  <p>...to being able to reuse my existing aspects and apply them to entire controllers or controller methods using annotations?</p>