Spring: register advice programmatically at runtime
Is it possible to register AOP advices programmatically, after the application has booted and the context has been initialized? When I tried, the advices didn't work, supposedly because they need to wrap the bean BEFORE it gets available in the context. Something like this (it doesn't work): @Bean private AspectJExpressionPointcutAdvisor createPointcutAdvisor(AWSXRayRecorder awsxRayRecorder, String name, String pointcut) { AspectJExpressionPointcutAdvisor advisor = new AspectJExpressionPointcutAdvisor(); advisor.setExpression("execution ...()"); advisor.setAdvice(new CustomAdvice("custom bean"