title: Java: Spring AOP & Refactoring
body: <p>So I'm starting to get into Spring AOP, and something occurred to me. When configuring an aspect, the annotations all use Strings as parameters, rather than Class objects.</p>
  
  <p>I bring this up because this means that an IDE (I use Eclipse, so I'll just refer to it here) won't be able to refactor the aspect properly. So if I have a class MyClass, with a method public void foo(), an example of a Spring AOP annotation would be this:</p>
  
  <pre><code>@Before ("execution(public void package.MyClass.foo())")
  </code></pre>
  
  <p>Because the param in the annotation is a String, if I refactored the method name to public void foo2(), it would break the binding of this aspect.</p>
  
  <p>I've been scouring various forums and tutorials, but everywhere I look I just see String parameters, which suggests that's the only option here. I guess you could work around this by being a bit more generic in how you declare the binding:</p>
  
  <pre><code>@Before ("exeuction(public void package.MyClass.set*(..))")
  </code></pre>
  
  <p>This new one will work for any setter method in MyClass, with any number of parameters (or no params). Of course, being vague like this might not work all the time.</p>
  
  <p>Anyway, I'm ranting a little bit here, it's late and I'm kind of tired and my brain is all worn out from hunting for an answer to this. But my final question is this: is there any way to set up Spring AOP annotations so that refactoring will affect them?</p>
  
  <p>Thanks.</p>