package org.theonefx.wcframework.aop;
import org.theonefx.wcframework.core.ClassWrapper;
import org.theonefx.wcframework.core.exception.BeansException;
import org.theonefx.wcframework.ioc.InstantiationBeanPostProcessor;
import org.theonefx.wcframework.ioc.MergedBeanDefinitionPostProcessor;
import org.theonefx.wcframework.ioc.RootBeanDefinition;
/**
* @File : AopBeanPostProcessor.java
* @ClassName : AopBeanPostProcessor
* @Author : 陈曦
* @Date : 2012-6-25 下午02:07:44
* @Version : v1.0
* @Description : 为Bean增加AOP功能的地方,主要是postProcessAfterInitialization方法
*/
public class AopBeanPostProcessor implements InstantiationBeanPostProcessor, MergedBeanDefinitionPostProcessor {
private final AopCore core;
public AopBeanPostProcessor(AopCore core) {
this.core = core;
}
@Override
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, ClassWrapper<?> classWrapper, String id) {
}
@Override
public Object postProcessBeforeInstantiation(ClassWrapper<?> wrapper, Object o, String id) throws BeansException {
return o;
}
@Override
public Object postProcessAfterInstantiation(String id, RootBeanDefinition mbd, ClassWrapper<?> classWrapper,Object bean) throws BeansException {
Object o = bean;
if (core.needProxy(id, mbd, classWrapper)) {
o = core.createProxy(id, mbd, classWrapper, bean);
}
return o;
}
}