@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
if (bean instanceof Advised) {
Advised advised = (Advised) bean;
for (Advisor advisor : advised.getAdvisors()) {
if (advisor instanceof AspectJPointcutAdvisor) {
String foundName = ((AbstractAspectJAdvice) ((AspectJPointcutAdvisor) advisor)
.getAdvice()).getAspectName();
if (aspect.getName().equals(foundName)) {
LOG.info("Found bean advised by " + aspect + "; injecting");
try {
aspect.addAdvised(advised.getTargetSource().getTarget(), beanName);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}