title: A simple pointcut expression in Spring
body: <p>I'm using Spring security 3.2.0 with the same version of the Spring framework. Spring security works well in my project. In order to protect methods in my DAO classes (and others), I want to use the following <em>pointcut</em> approach (in the <code>spring-security.xml</code> file).</p>
  
  <pre><code>&lt;global-method-security&gt;
      &lt;protect-pointcut expression="execution(*controller.*.*(..))" access="ROLE_ADMIN"/&gt;
  &lt;/global-method-security&gt;
  </code></pre>
  
  <p>I expect the pointcut expression as specified to protect all the methods in all classes inside the <code>controller</code> package and to be accessed only by the users who have the authority <code>ROLE_ADMIN</code> as specified.</p>
  
  <p>But when I try to use this expression, the process terminates with following exception on saving my <code>spring-security.xml</code> file.</p>
  
  <blockquote>
    <p>PropertyAccessException 1:
    org.springframework.beans.MethodInvocationException: Property
    'pointcutMap' threw exception; nested exception is
    java.lang.IllegalArgumentException: Pointcut is not well-formed:
    expecting 'name pattern' at character position 26
    execution(<em>controller.</em>.*(..))
                              ^</p>
  </blockquote>
  
  <p>I'm trying to follow the approach as specified by the <a href="http://static.springsource.org/spring-security/site/docs/3.2.x/reference/springsecurity-single.html#ns-global-method" rel="nofollow">reference document</a> in the <em>Adding Security Pointcuts using protect-pointcut</em> sub-section of the <em>3.4.1 The <code>&lt;global-method-security&gt;</code> Element</em> section.</p>
  
  <p>What is correct expression syntax in this scenario?</p>
  
  <hr>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Adding Security Pointcuts using protect-pointcut</p>
  
  <p>The use of protect-pointcut is particularly powerful, as it allows you to apply security to many beans with only a simple declaration. Consider the following example:</p>
  
  <pre><code>&lt;global-method-security&gt;
      &lt;protect-pointcut expression="execution(* com.mycompany.*Service.*(..))" access="ROLE_USER"/&gt;
  &lt;/global-method-security&gt;
  </code></pre>
  
  <p>This will protect all methods on beans declared in the application context whose classes are in the <code>com.mycompany</code> package and whose class names end in "Service". Only users with the <code>ROLE_USER</code> role will be able to invoke these methods. As with URL matching, the most specific matches must come first in the list of pointcuts, as the first matching expression will be used. Security annotations take precedence over pointcuts.</p>
  
  <p><strong>Copy &amp; pasted the section explained in the reference document</strong> (as someone may find it to be tedious to scroll the document).</p>