Spring aop @args demo 2.0

假如ParentModel的子类没有标注PrintArgs注解,子类作为目标类的入参,目标类会被拦截吗?
我做了一个测试:

子类

@Component("toneModel")
public class ToneModel extends ParentModel
{
    Logger logger = LoggerFactory.getLogger(ToneModel.class);

    public void methodA(String hello)
    {
        logger.info("ToneModel method");
    }
}

test 类:

public class ArgsAspectTest
{
    static Logger logger = LoggerFactory.getLogger(ArgsAspect.class);

    public static void main(String[] args)
    {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-args.xml");

        ArgsModel argsModel = (ArgsModel)context.getBean("argsModel");
        ParentModel parentModel = (ParentModel)context.getBean("parentModel");
        ToneModel toneModel = (ToneModel)context.getBean("toneModel");
        argsModel.testArgs(parentModel);
        argsModel.testArgs(toneModel);
    }

}

切面类,目标类,和上篇文章一样。
测试结果:

18:02:32.129 [main] INFO com.yuan.advice.args.ArgsAspect - void com.yuan.advice.args.ArgsModel.testArgs(ParentModel),此方法入参数标注了PrintArgs注解
18:02:32.165 [main] INFO com.yuan.advice.args.ArgsModel - 入参为com.yuan.advice.args.ParentModel@31e5415e
18:02:32.186 [main] INFO com.yuan.advice.args.ArgsAspect - void com.yuan.advice.args.ArgsModel.testArgs(ParentModel),此方法入参数标注了PrintArgs注解
18:02:32.186 [main] INFO com.yuan.advice.args.ArgsModel - 入参为com.yuan.advice.args.ToneModel@a2431d0

在《spring3.x企业开发实战》 这本书上有详细解释

你可能感兴趣的:(spring,spring,aop)