title: Dynamic Pointcut expression.
body: <p>Here's the thing, I've been working on a Monitoring solution with AOP, that can be extended to any kind of component. I'll try to break my concern in areas.</p>
  
  <p>The idea:<br>
  Have a mechanism that allows dynamic pointcut expressions definition based on types, which are Spring beans.</p>
  
  <p>What I did:<br>
  Created a component which implements ApplicationContextAware, that inspects the Spring Context and makes a list of all the bean types and names that should be considered for the Pointcut.  </p>
  
  <p>The problem:<br>
  The problem with this is that, at this point, I can't redefine or use any Pointcut, since the Spring AOP process has already created the proxyed objects.</p>
  
  <p>What I tried:<br>
  • Implemented my own Pointcut, Advisor and Advice, which compares against my list of beans, however, it's being ignored.<br>
  • Implemented a PointcutFactoryBean, which would be the one that provides the Pointcut to the already declared Advisor.<br>
  • Tried modifying an already declared Pointcut (Adding the new expression based on the beanIds) and associating it to a BeanNameAutoProxyCreator, with an Interceptor associated to this Pointcut. So that it'd have, for example:<br>
  bean(bean1) || bean(otherBean), and so on.</p>
  
  <p>With all these tries, I stumbled upon the same problem, everything is already defined and unalterable from the context. </p>
  
  <p>The question:<br>
  Is this even possible to do with Spring AOP? We don't want to involve any AspectJ matter to this, such as weaving and so on...
  To summarize, I'm looking for a way to create a pointcut expression and assign it to a pointcut on the application startup, taking in consideration all the beans. </p>
  
  <p>Hope I was clear, if not, please, let me know and I'll do my best to provide further details or code.</p>
  
  <p>Thanks a lot in advance!</p>