I am using a fully no-XML Spring setup, and I am successfully using @EnableAspectJAutoProxy
with my @Configuration
class and finding my aspect classes with a combination of @Aspect
and @Component
.
But I have come to a point where I need to on-demand weave/enhance instances that were not created with the spring context, but all I can find is how to do it with ProxyFactory
.
But then I need to manually add advices with ProxyFactory.addAdvice(..)
, which I've already written once with (for example) @Before
.
I don't want to rewrite those again.
Is there a way to get a reference to the factory that is (I guess?) created internally, by using the @EnableAspectJAutoProxy
annotation? So that I could do something like:
@Autowired
private AspectJAutoProxyInstanceFactory f; // made up class, of course
[...]
Object bean = f.weave(obj);
Or instantiate a factory that can figure out what advices are already out there in my application:
// Also a made up class, of course.
ApplicationContextAwareProxyFactory f = new ApplicationContextAwareProxyFactory(applicationContext);
Object bean = f.weave(obj);
I've tried to look around but can't seem to find an answer. Maybe I'm just not good enough at looking. Thanks in advance, if you can help me!